From 4f47a18bb1a98ed263559e1cb40b5b5efc43f14b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 25 Jan 2016 17:07:40 +0100 Subject: [PATCH] luci-mod-admin-full: fix displaying of VHT rates (#533) Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/admin_network/wifi_overview.htm | 26 ++++++++--- .../luasrc/view/admin_status/index.htm | 50 ++++++++++++---------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm index 4632673a7..1df6b2884 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm @@ -121,6 +121,24 @@ return s.replace(/ /g, ' '); } + 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 wifi_shutdown(id, toggle) { var reconnect = (toggle.getAttribute('active') == 'false'); @@ -331,13 +349,7 @@ assoclist[j].signal, assoclist[j].noise ); - tr.insertCell(-1).innerHTML = nowrap((assoclist[j].rx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[j].rx_rate / 1000, assoclist[j].rx_mcs, assoclist[j].rx_40mhz ? 40 : 20) - : String.format('%.1f <%:Mbit/s%>', assoclist[j].rx_rate / 1000) - ) + '
' + nowrap((assoclist[j].tx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[j].tx_rate / 1000, assoclist[j].tx_mcs, assoclist[j].tx_40mhz ? 40 : 20) - : String.format('%.1f <%:Mbit/s%>', assoclist[j].tx_rate / 1000) - ); + tr.insertCell(-1).innerHTML = nowrap(wifirate(assoclist[j], true)) + '
' + nowrap(wifirate(assoclist[j], false)); rowstyle = (rowstyle == 1) ? 2 : 1; } 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 0429f4871..a37982e1d 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 @@ -126,6 +126,24 @@ ); } + 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; + } + var npoll = 1; var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>; @@ -419,21 +437,15 @@ for (var bssid in net.assoclist) { - assoclist.push({ - bssid: bssid, - signal: net.assoclist[bssid].signal, - noise: net.assoclist[bssid].noise, - rx_rate: net.assoclist[bssid].rx_rate, - rx_mcs: net.assoclist[bssid].rx_mcs, - rx_40mhz: net.assoclist[bssid].rx_40mhz, - tx_rate: net.assoclist[bssid].tx_rate, - tx_mcs: net.assoclist[bssid].tx_mcs, - tx_40mhz: net.assoclist[bssid].tx_40mhz, - link: net.link, - name: net.name, - ifname: net.ifname, - radio: dev.name - }); + 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); } } @@ -507,13 +519,7 @@ assoclist[i].signal, assoclist[i].noise ); - tr.insertCell(-1).innerHTML = ((assoclist[i].rx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].rx_rate / 1000, assoclist[i].rx_mcs, assoclist[i].rx_40mhz ? 40 : 20).nobr() - : String.format('%.1f <%:Mbit/s%>', assoclist[i].rx_rate / 1000).nobr() - ).nobr() + '
' + ((assoclist[i].tx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].tx_rate / 1000, assoclist[i].tx_mcs, assoclist[i].tx_40mhz ? 40 : 20).nobr() - : String.format('%.1f <%:Mbit/s%>', assoclist[i].tx_rate / 1000).nobr() - ).nobr(); + tr.insertCell(-1).innerHTML = wifirate(assoclist[i], true).nobr() + '
' + wifirate(assoclist[i], false).nobr(); } if (ac.rows.length == 1) -- 2.11.0