luci-mod-admin-full: fix displaying of VHT rates (#533)
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 25 Jan 2016 16:07:40 +0000 (17:07 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 25 Jan 2016 16:07:40 +0000 (17:07 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm
modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm

index 4632673a7f7fd4c683bd998dfe1c64763fb94cfd..1df6b288460b55341a211f9fed0cf340b67a1d70 100644 (file)
                return s.replace(/ /g, '&#160;');
        }
 
+       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');
 
                                                                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)
-                                                       ) + '<br />' + 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)) + '<br />' + nowrap(wifirate(assoclist[j], false));
 
                                                        rowstyle = (rowstyle == 1) ? 2 : 1;
                                                }
index 0429f48716e96f2e72e5e84a188de0bf8f5e58c5..a37982e1dc0a3ee580e0124ac3bc886de5ce53e0 100644 (file)
                );
        }
 
+       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())%>;
 
 
                                                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);
                                                }
                                        }
 
                                                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() + '<br />' + ((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() + '<br />' + wifirate(assoclist[i], false).nobr();
                                }
 
                                if (ac.rows.length == 1)