modules: Make luci-base sufficient to use luci apps
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_network / iface_status.htm
1 <%+cbi/valueheader%>
2
3 <script type="text/javascript">//<![CDATA[
4 XHR.poll(5, '<%=url('admin/network/iface_status', self.network)%>', null,
5 function(x, ifc)
6 {
7 if (ifc && (ifc = ifc[0]))
8 {
9 var s = document.getElementById('<%=self.option%>-ifc-status'),
10 img = s.querySelector('img'),
11 info = s.querySelector('span'),
12 html = '<strong><%:Device%>:</strong> %h<br />'.format(ifc.ifname);
13
14 if (ifc.ifname)
15 {
16 if (ifc.is_up)
17 html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
18
19 if (ifc.macaddr)
20 html += String.format('<strong><%:MAC%>:</strong> %s<br />', ifc.macaddr);
21
22 html += String.format(
23 '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
24 '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
25 ifc.rx_bytes, ifc.rx_packets,
26 ifc.tx_bytes, ifc.tx_packets
27 );
28
29 if (ifc.ipaddrs && ifc.ipaddrs.length)
30 for (var i = 0; i < ifc.ipaddrs.length; i++)
31 html += String.format(
32 '<strong><%:IPv4%>:</strong> %s<br />',
33 ifc.ipaddrs[i]
34 );
35
36 if (ifc.ip6addrs && ifc.ip6addrs.length)
37 for (var i = 0; i < ifc.ip6addrs.length; i++)
38 html += String.format(
39 '<strong><%:IPv6%>:</strong> %s<br />',
40 ifc.ip6addrs[i]
41 );
42
43 if (ifc.ip6prefix)
44 html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
45
46 info.innerHTML = html;
47 }
48 else
49 {
50 info.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
51 }
52
53 img.src = '<%=resource%>/icons/%s%s.png'.format(ifc.type, ifc.is_up ? '' : '_disabled');
54 }
55 }
56 );
57 //]]></script>
58
59 <span class="ifacebadge large" id="<%=self.option%>-ifc-status">
60 <img src="<%=resource%>/icons/ethernet_disabled.png" />
61 <span>
62 <em><%:Collecting data...%></em>
63 </span>
64 </span>
65
66 <%+cbi/valuefooter%>