summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/view/admin_status
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-06-25 09:01:33 +0200
committerJo-Philipp Wich <jo@mein.io>2018-06-25 09:01:33 +0200
commite5ba594d77eed77d31d4b9b8c0e86026eb5a5fac (patch)
tree024000a15cab5bec318352d76b15ed9a0ff91072 /modules/luci-mod-admin-full/luasrc/view/admin_status
parent86c6c60a0d3aded629efbf4bd5e4145dc077a29d (diff)
luci-base, luci-mod-admin-full: unify wifi assoclist code
Merge the assoclist code of the status overview and wireless overview pages into a single shared partial template. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc/view/admin_status')
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm109
1 files changed, 2 insertions, 107 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
index 7c4a5bfc98..6083a8a2c5 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
@@ -140,24 +140,6 @@
);
}
- function wifirate(bss, rx) {
- var p = rx ? 'rx_' : 'tx_',
- s = '%.1f <%:Mbit/s%>, %d<%:MHz%>'
- .format(bss[p+'rate'] / 1000, bss[p+'mhz']),
- ht = bss[p+'ht'], vht = bss[p+'vht'],
- mhz = bss[p+'mhz'], nss = bss[p+'nss'],
- mcs = bss[p+'mcs'], sgi = bss[p+'short_gi'];
-
- if (ht || vht) {
- if (vht) s += ', VHT-MCS %d'.format(mcs);
- if (nss) s += ', VHT-NSS %d'.format(nss);
- if (ht) s += ', MCS %s'.format(mcs);
- if (sgi) s += ', <%:Short GI%>';
- }
-
- return s;
- }
-
function duid2mac(duid) {
// DUID-LLT / Ethernet
if (duid.length === 28 && duid.substr(0, 8) === '00010001')
@@ -402,8 +384,6 @@
<% end %>
<% if has_wifi then %>
- var assoclist = [ ];
-
var ws = document.getElementById('wifi_status_table');
if (ws)
{
@@ -420,21 +400,6 @@
{
var net = dev.networks[nidx];
var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
- var num_assoc = 0;
-
- for (var bssid in net.assoclist)
- {
- var bss = net.assoclist[bssid];
-
- bss.bssid = bssid;
- bss.link = net.link;
- bss.name = net.name;
- bss.ifname = net.ifname;
- bss.radio = dev.name;
-
- assoclist.push(bss);
- num_assoc++;
- }
var icon;
if (!is_assoc)
@@ -457,7 +422,7 @@
'<%:Mode%>', net.mode,
'<%:BSSID%>', is_assoc ? (net.bssid || '-') : null,
'<%:Encryption%>', is_assoc ? net.encryption : null,
- '<%:Associations%>', is_assoc ? (num_assoc || '-') : null,
+ '<%:Associations%>', is_assoc ? (net.num_assoc || '-') : null,
null, is_assoc ? null : E('em', '<%:Wireless is disabled or not associated%>')));
}
@@ -472,63 +437,6 @@
if (!ws.lastElementChild)
ws.appendChild(E('<em><%:No information available%></em>'));
}
-
- var ac = document.getElementById('wifi_assoc_table');
- if (ac)
- {
- var rows = [];
-
- assoclist.sort(function(a, b) {
- return (a.name == b.name)
- ? (a.bssid < b.bssid)
- : (a.name > b.name )
- ;
- });
-
- for (var i = 0; i < assoclist.length; i++)
- {
- var icon;
- var q = (-1 * (assoclist[i].noise - assoclist[i].signal)) / 5;
- if (q < 1)
- icon = "<%=resource%>/icons/signal-0.png";
- else if (q < 2)
- icon = "<%=resource%>/icons/signal-0-25.png";
- else if (q < 3)
- icon = "<%=resource%>/icons/signal-25-50.png";
- else if (q < 4)
- icon = "<%=resource%>/icons/signal-50-75.png";
- else
- icon = "<%=resource%>/icons/signal-75-100.png";
-
- var host = hosts[assoclist[i].bssid],
- name = host ? (host.name || host.ipv4 || host.ipv6) : null,
- hint = (host && host.name && (host.ipv4 || host.ipv6)) ? (host.ipv4 || host.ipv6) : null;
-
- rows.push([
- '<span class="ifacebadge" title="%q"><img src="<%=resource%>/icons/wifi.png" /> <a href="%s">%h</a><small>&#160;(%h)</small></span>'.format(
- assoclist[i].radio,
- assoclist[i].link,
- assoclist[i].name,
- assoclist[i].ifname),
- assoclist[i].bssid,
- hint ? '%h (%h)'.format(name || '?', hint) : (name || '?'),
- '<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%> / <%:SNR%>: %d"><img src="%s" /> %d / %d <%:dBm%></span>'.format(
- assoclist[i].signal,
- assoclist[i].noise,
- assoclist[i].signal - assoclist[i].noise,
- icon,
- assoclist[i].signal,
- assoclist[i].noise),
- E('span', {}, [
- E('span', wifirate(assoclist[i], true)),
- E('br'),
- E('span', wifirate(assoclist[i], false))
- ])
- ]);
- }
-
- cbi_update_table(ac, rows, '<em><%:No information available%></em>');
- }
<% end %>
var e;
@@ -709,20 +617,7 @@
<div class="cbi-section">
<h3><%:Associated Stations%></h3>
- <div class="cbi-section-node">
- <div class="table" id="wifi_assoc_table">
- <div class="tr table-titles">
- <div class="th nowrap"><%:Network%></div>
- <div class="th hide-xs"><%:MAC-Address%></div>
- <div class="th nowrap"><%:Host%></div>
- <div class="th nowrap"><%:Signal%> / <%:Noise%></div>
- <div class="th nowrap"><%:RX Rate%> / <%:TX Rate%></div>
- </div>
- <div class="tr">
- <div class="td" colspan="6"><em><br /><%:Collecting data...%></em></div>
- </div>
- </div>
- </div>
+ <%+admin_network/wifi_assoclist%>
</div>
<% end %>