2 Copyright
2010-
2018 Jo-Philipp Wich
<jo@mein.io
>
3 Licensed to the public under the Apache License
2.0.
6 <script type=
"text/javascript">//<![CDATA[
7 function iface_reconnect(id) {
10 var d = document.getElementById(id + '-ifc-description');
11 if (d) d.innerHTML = '
<em><%:Interface is reconnecting...%
></em>';
13 (new XHR()).post('<%=url('admin/network/iface_reconnect')%
>/' + id,
14 { token: '<%=token%
>' }, XHR.run);
17 function iface_delete(ev) {
18 if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%
>)) {
23 ev.target.previousElementSibling.value = '
1';
29 document.querySelectorAll('[data-network]').forEach(function(n) {
30 networks.push(n.getAttribute('data-network'));
33 function render_iface(ifc) {
34 return E('span', { class: 'cbi-tooltip-container' }, [
35 E('img', { 'class' : 'middle', 'src': '<%=resource%
>/icons/%s%s.png'.format(
36 ifc.is_alias ? 'alias' : ifc.type,
37 ifc.is_up ? '' : '_disabled') }),
38 E('span', { 'class': 'cbi-tooltip ifacebadge large' }, [
39 E('img', { 'src': '<%=resource%
>/icons/%s%s.png'.format(
40 ifc.type, ifc.is_up ? '' : '_disabled') }),
41 E('span', { 'class': 'left' }, [
42 E('strong', '<%:Type%
>: '), ifc.typename, E('br'),
43 E('strong', '<%:Device%
>: '), ifc.ifname, E('br'),
44 E('strong', '<%:Connected%
>: '), ifc.is_up ? '<%:yes%
>' : '<%:no%
>', E('br'),
45 ifc.macaddr ? E('strong', '<%:MAC%
>: ') : '',
46 ifc.macaddr ? ifc.macaddr : '',
47 ifc.macaddr ? E('br') : '',
48 E('strong', '<%:RX%
>: '), '%
.2mB (%d <%:Pkts.%
>)'.format(ifc.rx_bytes, ifc.rx_packets), E('br'),
49 E('strong', '<%:TX%
>: '), '%
.2mB (%d <%:Pkts.%
>)'.format(ifc.tx_bytes, ifc.tx_packets)
55 XHR.poll(
5, '<%=url('admin/network/iface_status')%
>/' + networks.join(','), null,
60 for (var idx =
0; idx < ifcs.length; idx++)
65 var s = document.getElementById(ifc.id + '-ifc-devices');
69 s.removeChild(s.firstChild);
71 s.appendChild(render_iface(ifc));
73 if (ifc.subdevices && ifc.subdevices.length)
77 for (var j =
0; j < ifc.subdevices.length; j++)
78 sifs.push(render_iface(ifc.subdevices[j]));
82 s.appendChild(E('span', {}, sifs));
85 s.appendChild(E('br'));
86 s.appendChild(E('small', {}, ifc.is_alias ? '<%:Alias of
"%s"%
>'.format(ifc.is_alias) : ifc.name));
89 var d = document.getElementById(ifc.id + '-ifc-description');
90 if (d && ifc.proto && ifc.ifname)
95 desc = '<%:Virtual dynamic interface%
>';
96 else if (ifc.is_alias)
97 desc = '<%:Alias Interface%
>';
100 desc = desc ? '%s (%s)'.format(desc, ifc.desc) : ifc.desc;
102 html += String.format('
<strong><%:Protocol%
>:
</strong> %h
<br />', desc || '?');
106 html += String.format('
<strong><%:Uptime%
>:
</strong> %t
<br />', ifc.uptime);
110 if (!ifc.is_dynamic && !ifc.is_alias)
113 html += String.format('
<strong><%:MAC-Address%
>:
</strong> %s
<br />', ifc.macaddr);
115 html += String.format(
116 '
<strong><%:RX%
>:
</strong> %
.2mB (%d <%:Pkts.%
>)
<br />' +
117 '
<strong><%:TX%
>:
</strong> %
.2mB (%d <%:Pkts.%
>)
<br />',
118 ifc.rx_bytes, ifc.rx_packets,
119 ifc.tx_bytes, ifc.tx_packets
123 if (ifc.ipaddrs && ifc.ipaddrs.length)
125 for (var i =
0; i < ifc.ipaddrs.length; i++)
126 html += String.format(
127 '
<strong><%:IPv4%
>:
</strong> %s
<br />',
132 if (ifc.ip6addrs && ifc.ip6addrs.length)
134 for (var i =
0; i < ifc.ip6addrs.length; i++)
135 html += String.format(
136 '
<strong><%:IPv6%
>:
</strong> %s
<br />',
142 html += String.format('
<strong><%:IPv6-PD%
>:
</strong> %s
<br />', ifc.ip6prefix);
146 for (var i =
0; i < ifc.errors.length; i++)
147 html += String.format(
148 '
<em class=
"error"><strong><%:Error%
>:
</strong> %h
</em><br />',
155 else if (d && !ifc.proto)
157 var e = document.getElementById(ifc.id + '-ifc-edit');
161 d.innerHTML = String.format(
162 '
<em><%:Unsupported protocol type.%
></em><br />' +
163 '
<a href=
"%h"><%:Install protocol extensions...%
></a>',
164 '<%=url(
"admin/system/packages")%
>?query=luci-proto&display=available'
167 else if (d && !ifc.ifname)
169 d.innerHTML = String.format(
170 '
<em><%:Network without interfaces.%
></em><br />' +
171 '
<a href=
"<%=url("admin/network/network/%s
")%>?tab.network.%s=physical"><%:Assign interfaces...%
></a>',
177 d.innerHTML = '
<em><%:Interface not present or not connected yet.%
></em>';