5836d41459990919c41b59ac279dd98e83f51203
[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 (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
18 var icon;
19 if (is_up)
20 icon = "<%=resource%>/icons/ethernet.png";
21 else
22 icon = "<%=resource%>/icons/ethernet_disabled.png";
23
24 var s = document.getElementById('<%=self.option%>-ifc-signal');
25 if (s)
26 s.innerHTML = String.format(
27 '<img src="%s" style="width:16px; height:16px" /><br />' +
28 '<small>%s</small>', icon, ifc.ifname ? ifc.ifname : '?'
29 );
30
31 var d = document.getElementById('<%=self.option%>-ifc-description');
32 if (d && ifc.ifname)
33 {
34 d.innerHTML = String.format(
35 '<strong><%:MAC Address%>:</strong> %s<br />' +
36 '<strong><%:RX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />' +
37 '<strong><%:TX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />',
38 mac, rxb, rxp, txb, txp
39 );
40
41 if (ifc.ipaddrs && ifc.ipaddrs.length)
42 {
43 d.innerHTML += '<strong><%:IPv4%>: </strong>';
44
45 for (var i = 0; i < ifc.ipaddrs.length; i++)
46 d.innerHTML += String.format(
47 '%s%s/%d',
48 i ? ', ' : '',
49 ifc.ipaddrs[i].addr,
50 ifc.ipaddrs[i].prefix
51 );
52
53 d.innerHTML += '<br />';
54 }
55
56 if (ifc.ip6addrs && ifc.ip6addrs.length)
57 {
58 d.innerHTML += '<strong><%:IPv6%>: </strong>';
59
60 for (var i = 0; i < ifc.ip6addrs.length; i++)
61 d.innerHTML += String.format(
62 '%s%s/%d',
63 i ? ', ' : '',
64 ifc.ip6addrs[i].addr,
65 ifc.ip6addrs[i].prefix
66 );
67
68 d.innerHTML += '<br />';
69 }
70 }
71 else if (d)
72 d.innerHTML = '<%:Interface not present or not connected yet.%>';
73 }
74 }
75 )
76
77 window.setTimeout(arguments.callee, 5000);
78 })();
79 ]]></script>
80
81 <table>
82 <tr class="cbi-section-table">
83 <td></td>
84 <td class="cbi-value-field" style="width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
85 <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
86 <small>?</small>
87 </td>
88 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
89 <em><%:Collecting data...%></em>
90 </td>
91 </tr>
92 </table>
93
94 <%+cbi/valuefooter%>