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