summaryrefslogtreecommitdiffstats
path: root/modules/admin-full/luasrc/view/admin_network/iface_status.htm
blob: 8136383969176013f130388949c6a4c1cc8b9746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<%+cbi/valueheader%>

<script type="text/javascript">//<![CDATA[
	XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", self.network)%>', null,
		function(x, ifc)
		{
			if (ifc && (ifc = ifc[0]))
			{
				var html = '';

				var s = document.getElementById('<%=self.option%>-ifc-signal');
				if (s)
					s.innerHTML = String.format(
						'<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px" />' +
						'<br /><small>%s</small>',
							ifc.type, ifc.is_up ? '' : '_disabled',
							ifc.name
					);

				var d = document.getElementById('<%=self.option%>-ifc-description');
				if (d && ifc.ifname)
				{
					if (ifc.is_up)
					{
						html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
					}

					if (ifc.type != 'tunnel')
					{
						html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
					}

					html += String.format(
						'<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
						'<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
							ifc.rx_bytes, ifc.rx_packets,
							ifc.tx_bytes, ifc.tx_packets
					);

					if (ifc.ipaddrs && ifc.ipaddrs.length)
					{
						html += '<strong><%:IPv4%>: </strong>';

						for (var i = 0; i < ifc.ipaddrs.length; i++)
							html += String.format(
								'%s%s/%d',
								i ? ', ' : '',
								ifc.ipaddrs[i].addr,
								ifc.ipaddrs[i].prefix
							);

						html += '<br />';
					}

					if (ifc.ip6addrs && ifc.ip6addrs.length)
					{
						html += '<strong><%:IPv6%>: </strong>';

						for (var i = 0; i < ifc.ip6addrs.length; i++)
							html += String.format(
								'%s%s/%d',
								i ? ', ' : '',
								ifc.ip6addrs[i].addr.toUpperCase(),
								ifc.ip6addrs[i].prefix
							);

						html += '<br />';
					}

					d.innerHTML = html;
				}
				else if (d)
				{
					d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
				}
			}
		}
	);
//]]></script>

<table>
	<tr class="cbi-section-table">
		<td></td>
		<td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
			<img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
			<small>?</small>
		</td>
		<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
			<em><%:Collecting data...%></em>
		</td>
	</tr>
</table>

<%+cbi/valuefooter%>