luci-mod-status: reuse the already provided band info

iwinfo already provides the band information with every channel, so just
use that instead.

Signed-off-by: Andre Heider <a.heider@gmail.com>
This commit is contained in:
Andre Heider 2023-07-31 15:23:57 +02:00 committed by Christian Marangi
parent 4e9dac1b6e
commit 9f8a553d19

View file

@ -97,9 +97,8 @@ return view.extend({
}) })
}, },
create_channel_graph: function(chan_analysis, freq_tbl, freq) { create_channel_graph: function(chan_analysis, freq_tbl, band) {
var is5GHz = freq == '5GHz', var columns = (band != 2) ? freq_tbl.length * 4 : freq_tbl.length + 3,
columns = is5GHz ? freq_tbl.length * 4 : freq_tbl.length + 3,
chan_graph = chan_analysis.graph, chan_graph = chan_analysis.graph,
G = chan_graph.firstElementChild, G = chan_graph.firstElementChild,
step = (chan_graph.offsetWidth - 2) / columns, step = (chan_graph.offsetWidth - 2) / columns,
@ -131,7 +130,7 @@ return view.extend({
var channel = freq_tbl[i] var channel = freq_tbl[i]
chan_analysis.offset_tbl[channel] = curr_offset+step; chan_analysis.offset_tbl[channel] = curr_offset+step;
if (is5GHz) { if (band != 2) {
createGraphHLine(G,curr_offset+step, 0.1, 3); createGraphHLine(G,curr_offset+step, 0.1, 3);
if (channel < 100) if (channel < 100)
createGraphText(G,curr_offset-(step/2), channel); createGraphText(G,curr_offset-(step/2), channel);
@ -143,7 +142,7 @@ return view.extend({
} }
curr_offset += step; curr_offset += step;
if (is5GHz && freq_tbl[i+1]) { if ((band != 2) && freq_tbl[i+1]) {
var next_channel = freq_tbl[i+1]; var next_channel = freq_tbl[i+1];
/* Check if we are transitioning to another 5Ghz band range */ /* Check if we are transitioning to another 5Ghz band range */
if ((next_channel - channel) == 4) { if ((next_channel - channel) == 4) {
@ -193,7 +192,8 @@ return view.extend({
local_wifi = data[1], local_wifi = data[1],
table = radio.table, table = radio.table,
chan_analysis = radio.graph, chan_analysis = radio.graph,
scanCache = radio.scanCache; scanCache = radio.scanCache,
band = radio.band;
var rows = []; var rows = [];
@ -376,22 +376,19 @@ return view.extend({
var tabs = E('div', {}, E('div')); var tabs = E('div', {}, E('div'));
for (var ifname in wifiDevs) { for (var ifname in wifiDevs) {
var freq_tbl = { var bands = {
['2.4GHz'] : [], [2] : { title: '2.4GHz', channels: [] },
['5GHz'] : [], [5] : { title: '5GHz', channels: [] },
}; };
/* Split FrequencyList in Bands */ /* Split FrequencyList in Bands */
wifiDevs[ifname].freq.forEach(function(freq) { wifiDevs[ifname].freq.forEach(function(freq) {
if (freq.mhz >= 5000) { if (bands[freq.band])
freq_tbl['5GHz'].push(freq.channel); bands[freq.band].channels.push(freq.channel);
} else {
freq_tbl['2.4GHz'].push(freq.channel);
}
}); });
for (var freq in freq_tbl) { for (var band in bands) {
if (freq_tbl[freq].length == 0) if (bands[band].channels.length == 0)
continue; continue;
var csvg = svg.cloneNode(true), var csvg = svg.cloneNode(true),
@ -405,7 +402,7 @@ return view.extend({
E('th', { 'class': 'th col-3 middle left hide-xs' }, _('BSSID')) E('th', { 'class': 'th col-3 middle left hide-xs' }, _('BSSID'))
]) ])
]), ]),
tab = E('div', { 'data-tab': ifname+freq, 'data-tab-title': ifname+' ('+freq+')' }, tab = E('div', { 'data-tab': ifname+band, 'data-tab-title': ifname+' ('+bands[band].title+')' },
[E('br'),csvg,E('br'),table,E('br')]), [E('br'),csvg,E('br'),table,E('br')]),
graph_data = { graph_data = {
graph: csvg, graph: csvg,
@ -414,8 +411,9 @@ return view.extend({
tab: tab, tab: tab,
}; };
this.radios[ifname+freq] = { this.radios[ifname+band] = {
dev: wifiDevs[ifname].dev, dev: wifiDevs[ifname].dev,
band: band,
graph: graph_data, graph: graph_data,
table: table, table: table,
scanCache: {}, scanCache: {},
@ -426,7 +424,7 @@ return view.extend({
tabs.firstElementChild.appendChild(tab) tabs.firstElementChild.appendChild(tab)
requestAnimationFrame(L.bind(this.create_channel_graph, this, graph_data, freq_tbl[freq], freq)); requestAnimationFrame(L.bind(this.create_channel_graph, this, graph_data, bands[band].channels, band));
} }
} }