modules/admin-full: use luci.tools.status for remaining wifi status displays
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / iface_status.htm
1 <%+cbi/valueheader%>
2
3 <script type="text/javascript">//<![CDATA[
4 var iwxhr = new XHR();
5 var update_status = function() {
6 iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "iface_status", self.network)%>', null,
7 function(x, ifc)
8 {
9 if (ifc && (ifc = ifc[0]))
10 {
11 var is_up = (ifc.flags && ifc.flags.up);
12 var rxb = ifc.stats ? (ifc.stats["rx_bytes"] / 1024) : 0;
13 var txb = ifc.stats ? (ifc.stats["tx_bytes"] / 1024) : 0;
14 var rxp = ifc.stats ? ifc.stats["rx_packets"] : 0;
15 var txp = ifc.stats ? ifc.stats["tx_packets"] : 0;
16 var mac = ifc.macaddr ? ifc.macaddr : '00:00:00:00:00:00';
17 var upt = '-';
18
19 var icon;
20 if (is_up)
21 {
22 if (ifc.uptime)
23 upt = String.format('%t', ifc.uptime);
24
25 icon = "<%=resource%>/icons/ethernet.png";
26 }
27 else
28 {
29 icon = "<%=resource%>/icons/ethernet_disabled.png";
30 }
31
32 var s = document.getElementById('<%=self.option%>-ifc-signal');
33 if (s)
34 s.innerHTML = String.format(
35 '<img src="%s" style="width:16px; height:16px" /><br />' +
36 '<small>%s</small>', icon, ifc.ifname ? ifc.ifname : '?'
37 );
38
39 var d = document.getElementById('<%=self.option%>-ifc-description');
40 if (d && ifc.ifname)
41 {
42 d.innerHTML = String.format(
43 '<strong><%:Uptime%>:</strong> %s<br />' +
44 '<strong><%:MAC Address%>:</strong> %s<br />' +
45 '<strong><%:RX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />' +
46 '<strong><%:TX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />',
47 upt, mac, rxb, rxp, txb, txp
48 );
49
50 if (ifc.ipaddrs && ifc.ipaddrs.length)
51 {
52 d.innerHTML += '<strong><%:IPv4%>: </strong>';
53
54 for (var i = 0; i < ifc.ipaddrs.length; i++)
55 d.innerHTML += String.format(
56 '%s%s/%d',
57 i ? ', ' : '',
58 ifc.ipaddrs[i].addr,
59 ifc.ipaddrs[i].prefix
60 );
61
62 d.innerHTML += '<br />';
63 }
64
65 if (ifc.ip6addrs && ifc.ip6addrs.length)
66 {
67 d.innerHTML += '<strong><%:IPv6%>: </strong>';
68
69 for (var i = 0; i < ifc.ip6addrs.length; i++)
70 d.innerHTML += String.format(
71 '%s%s/%d',
72 i ? ', ' : '',
73 ifc.ip6addrs[i].addr.toUpperCase(),
74 ifc.ip6addrs[i].prefix
75 );
76
77 d.innerHTML += '<br />';
78 }
79 }
80 else if (d)
81 d.innerHTML = '<%:Interface not present or not connected yet.%>';
82 }
83
84 window.setTimeout(update_status, 5000);
85 }
86 )
87 };
88
89 update_status();
90 //]]></script>
91
92 <table>
93 <tr class="cbi-section-table">
94 <td></td>
95 <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
96 <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
97 <small>?</small>
98 </td>
99 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
100 <em><%:Collecting data...%></em>
101 </td>
102 </tr>
103 </table>
104
105 <%+cbi/valuefooter%>