chan_analysis.tab.addEventListener('cbi-tab-active', L.bind(function(ev) {
this.active_tab = ev.detail.tab;
+ if (!this.radios[this.active_tab].loadedOnce)
+ poll.start();
}, this));
},
if (!this.active_tab)
return;
- var radioDev = this.radios[this.active_tab].dev,
- table = this.radios[this.active_tab].table,
- chan_analysis = this.radios[this.active_tab].graph,
- scanCache = this.radios[this.active_tab].scanCache;
+ var radio = this.radios[this.active_tab];
return Promise.all([
- radioDev.getScanList(),
- this.callInfo(radioDev.getName())
+ radio.dev.getScanList(),
+ this.callInfo(radio.dev.getName())
]).then(L.bind(function(data) {
var results = data[0],
- local_wifi = data[1];
+ local_wifi = data[1],
+ table = radio.table,
+ chan_analysis = radio.graph,
+ scanCache = radio.scanCache;
var rows = [];
scanCache[results[i].bssid] = {};
scanCache[results[i].bssid].data = results[i];
+ scanCache[results[i].bssid].data.stale = false;
}
if (scanCache[local_wifi.bssid] == null)
if (chan_analysis.offset_tbl[local_wifi.channel] != null && local_wifi.center_chan1) {
var center_channels = [local_wifi.center_chan1],
- chan_width_text = local_wifi.htmode.replace(/(V)*HT/,''),
+ chan_width_text = local_wifi.htmode.replace(/(V)*H[TE]/,''), /* Handle HT VHT HE */
chan_width = parseInt(chan_width_text)/10;
if (local_wifi.center_chan2) {
}
for (var k in scanCache)
- if (scanCache[k].stale)
+ if (scanCache[k].data.stale)
results.push(scanCache[k].data);
results.sort(function(a, b) {
- var diff = (b.quality - a.quality) || (a.channel - b.channel);
-
- if (diff)
- return diff;
+ if (a.channel - b.channel)
+ return 1;
if (a.ssid < b.ssid)
return -1;
E('span', { 'style': s }, '%h'.format(res.bssid))
]);
- res.stale = true;
+ scanCache[results[i].bssid].data.stale = true;
}
cbi_update_table(table, rows);
+
+ if (!radio.loadedOnce) {
+ radio.loadedOnce = true;
+ poll.stop();
+ }
}, this))
},
var svg = data[0],
wifiDevs = data[1];
- var v = E('div', {}, E('div'));
+ var h2 = E('div', {'class' : 'cbi-title-section'}, [
+ E('h2', {'class': 'cbi-title-field'}, [ _('Channel Analysis') ]),
+ E('div', {'class': 'cbi-title-buttons' }, [
+ E('button', {
+ 'class': 'cbi-button cbi-button-edit',
+ 'click': ui.createHandlerFn(this, 'handleScanRefresh')
+ }, [ _('Refresh Channels') ])])
+ ]);
+
+ var tabs = E('div', {}, E('div'));
for (var ifname in wifiDevs) {
var freq_tbl = {
dev: wifiDevs[ifname].dev,
graph: graph_data,
table: table,
- scanCache: {}
+ scanCache: {},
+ loadedOnce: false,
};
cbi_update_table(table, [], E('em', { class: 'spinning' }, _('Starting wireless scan...')));
- v.firstElementChild.appendChild(tab)
+ tabs.firstElementChild.appendChild(tab)
requestAnimationFrame(L.bind(this.create_channel_graph, this, graph_data, freq_tbl[freq], freq));
}
}
- ui.tabs.initTabGroup(v.firstElementChild.childNodes);
+ ui.tabs.initTabGroup(tabs.firstElementChild.childNodes);
this.pollFn = L.bind(this.handleScanRefresh, this);
-
poll.add(this.pollFn);
- poll.start();
- return v;
+ return E('div', {}, [h2, tabs]);
},
handleSaveApply: null,