modules: Make luci-base sufficient to use luci apps
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_network / wifi_assoclist.htm
1 <script type="text/javascript">//<![CDATA[
2 function wifirate(bss, rx) {
3 var p = rx ? 'rx_' : 'tx_',
4 s = '%.1f <%:Mbit/s%>, %d<%:MHz%>'
5 .format(bss[p+'rate'] / 1000, bss[p+'mhz']),
6 ht = bss[p+'ht'], vht = bss[p+'vht'],
7 mhz = bss[p+'mhz'], nss = bss[p+'nss'],
8 mcs = bss[p+'mcs'], sgi = bss[p+'short_gi'];
9
10 if (ht || vht) {
11 if (vht) s += ', VHT-MCS %d'.format(mcs);
12 if (nss) s += ', VHT-NSS %d'.format(nss);
13 if (ht) s += ', MCS %s'.format(mcs);
14 if (sgi) s += ', <%:Short GI%>';
15 }
16
17 return s;
18 }
19
20 XHR.poll(5, '<%=url('admin/network/wireless_assoclist')%>', null,
21 function(x, st)
22 {
23 var tb = document.getElementById('wifi_assoclist_table');
24 if (st && tb)
25 {
26 var rows = [];
27
28 st.forEach(function(bss) {
29 var icon;
30 var q = (-1 * (bss.noise - bss.signal)) / 5;
31 if (q < 1)
32 icon = "<%=resource%>/icons/signal-0.png";
33 else if (q < 2)
34 icon = "<%=resource%>/icons/signal-0-25.png";
35 else if (q < 3)
36 icon = "<%=resource%>/icons/signal-25-50.png";
37 else if (q < 4)
38 icon = "<%=resource%>/icons/signal-50-75.png";
39 else
40 icon = "<%=resource%>/icons/signal-75-100.png";
41
42 rows.push([
43 '<span class="ifacebadge" title="%q"><img src="<%=resource%>/icons/wifi.png" /> <a href="%s">%h</a><small>&#160;(%h)</small></span>'.format(
44 bss.radio,
45 bss.link,
46 bss.name,
47 bss.ifname),
48 bss.bssid,
49 bss.host_hint ? '%h (%h)'.format(bss.host_name || '?', bss.host_hint) : (bss.host_name || '?'),
50 '<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%> / <%:SNR%>: %d"><img src="%s" /> %d / %d <%:dBm%></span>'.format(
51 bss.signal,
52 bss.noise,
53 bss.signal - bss.noise,
54 icon,
55 bss.signal,
56 bss.noise),
57 E('span', {}, [
58 E('span', wifirate(bss, true)),
59 E('br'),
60 E('span', wifirate(bss, false))
61 ])
62 ]);
63 });
64
65 cbi_update_table(tb, rows, '<em><%:No information available%></em>');
66 }
67 }
68 );
69 //]]></script>
70
71 <div class="table" id="wifi_assoclist_table">
72 <div class="tr table-titles">
73 <div class="th nowrap"><%:Network%></div>
74 <div class="th hide-xs"><%:MAC-Address%></div>
75 <div class="th nowrap"><%:Host%></div>
76 <div class="th nowrap"><%:Signal%> / <%:Noise%></div>
77 <div class="th nowrap"><%:RX Rate%> / <%:TX Rate%></div>
78 </div>
79 <div class="tr placeholder">
80 <div class="td"><em><%:Collecting data...%></em></div>
81 </div>
82 </div>