6 'require modemmanager_helper as helper';
10 return helper
.getModems().then(function (modems
) {
11 return Promise
.all(modems
.filter(function (modem
){
13 }).map(function (modem
) {
14 return helper
.getModemSims(modem
.modem
).then(function (sims
) {
15 modem
.sims
= sims
.filter(function (sim
) {
19 return helper
.getModemLocation(modem
.modem
).then(function (location
) {
20 modem
.location
= location
;
28 pollData: function (container
) {
29 poll
.add(L
.bind(function () {
30 return this.load().then(L
.bind(function (modems
) {
31 dom
.content(container
, this.renderContent(modems
));
36 renderSections: function (name
, sections
) {
37 if (sections
.length
== 0) {
38 sections
.push(E('div', { 'class': 'cbi-section' }, [
39 E('span', {}, _('Section %s is empty.').format(name
))
43 return E('div', { 'class': 'cbi-section' }, [
49 renderSection: function (name
, table
) {
50 var rowNodes
= table
.filter(function (row
) {
51 return row
[1] != null;
52 }).map(function (row
) {
53 return E('tr', { 'class': 'tr' }, [
54 E('td', { 'class': 'td', 'width': '33%' }, E('strong', {}, [row
[0]])),
55 E('td', { 'class': 'td' }, [row
[1]])
60 if (rowNodes
.length
== 0) {
61 tableNode
= E('div', { 'class': 'cbi-section' }, [
62 E('span', {}, _('Section %s is empty.').format(name
))
65 tableNode
= E('table', { 'class': 'table', }, rowNodes
);
68 return E('div', { 'class': 'cbi-section' }, [
74 renderContent: function (modems
) {
75 var node
= E('div', {}, E('div'));
77 modems
.forEach(L
.bind(function (modem
) {
78 var generic
= modem
.modem
.generic
;
79 var modem3gpp
= modem
.modem
['3gpp'];
81 var modemSection
= this.renderSection(_('Modem Info'), [
82 [_('Manufacturer'), generic
.manufacturer
],
83 [_('Model'), generic
.model
],
84 [_('Revision'), generic
.revision
],
85 [E('abbr', { 'title': _('International Mobile Station Equipment Identity') }, [
88 [_('Device Identifier'), generic
['device-identifier']],
89 [_('Power State'), generic
['power-state']],
90 [_('State'), generic
.state
],
91 [_('Failed Reason'), generic
['state-failed-reason']]
94 var ownNumbersStr
= generic
['own-numbers'].join(', ');
95 var accessTechnologiesStr
= generic
['access-technologies'].join(', ');
96 var signalQualityValue
= parseInt(generic
['signal-quality'].value
);
97 var networkSection
= this.renderSection(_('Network Registration'), [
98 [_('Own Numbers'), ownNumbersStr
],
99 [_('Access Technologies'), accessTechnologiesStr
],
100 [_('Operator') , modem3gpp
['operator-name']],
101 [_('Operator Code'), modem3gpp
['operator-code']],
102 [_('Registration State'), modem3gpp
['registration-state']],
103 [_('Packet Service State'), modem3gpp
['packet-service-state']],
104 [_('Signal Quality'), E('div', { 'class': 'cbi-progressbar', 'title': '%d %'.format(signalQualityValue
) }, [
105 E('div', { 'style': 'width: %d%%'.format(signalQualityValue
) })
109 var location3gpp
= {};
110 if (modem
.location
!= null) {
111 location3gpp
= modem
.location
.modem
.location
['3gpp'];
113 var locationSection
= this.renderSection(_('Cell Location'), [
114 [E('abbr', { 'title': _('Cell ID') }, [
116 ]), location3gpp
.cid
],
117 [E('abbr', { 'title': _('Location Area Code') }, [
119 ]), location3gpp
.lac
],
120 [E('abbr', { 'title': _('Mobile Country Code') }, [
122 ]), location3gpp
.mcc
],
123 [E('abbr', { 'title': _('Mobile Network Code') }, [
125 ]), location3gpp
.mnc
],
126 [E('abbr', { 'title': _('Tracking Area Code') }, [
128 ]), location3gpp
.tac
]
131 var simTables
= modem
.sims
.map(function (sim
) {
132 var properties
= sim
.sim
.properties
;
134 [_('Active'), properties
.active
],
135 [_('Operator Name'), properties
['operator-name']],
136 [E('abbr', { 'title': _('Integrated Circuit Card Identifier') }, [
138 ]), properties
.iccid
],
139 [E('abbr', { 'title': _('International Mobile Subscriber Identity') }, [
144 var simSubSections
= simTables
.map(L
.bind(function (table
, index
) {
145 return this.renderSection(_('SIM %d').format(index
+ 1), table
)
147 var simSection
= this.renderSections(_('SIMs'), simSubSections
);
150 E('div', { 'class': 'cbi-map-descr'}, []),
155 ].filter(function (section
) {
156 return section
!= null;
158 node
.firstElementChild
.appendChild(E('div', { 'data-tab': generic
.device
, 'data-tab-title': generic
.device
}, sections
));
160 ui
.tabs
.initTabGroup(node
.firstElementChild
.childNodes
);
165 render: function (modems
) {
166 var content
= E([], [
167 E('h2', {}, [_('Cellular Network')]),
170 var container
= content
.lastElementChild
;
172 dom
.content(container
, this.renderContent(modems
));
173 this.pollData(container
);
178 handleSaveApply
: null,