1 function iface_reconnect(id) {
3 L.dom.content(document.getElementById(id + '-ifc-description'), E('em', _('Interface is reconnecting...')));
4 L.post(L.url('admin/network/iface_reconnect', id), L.run);
7 function iface_delete(ev) {
8 if (!confirm(_('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))) {
13 ev.target.previousElementSibling.value = '1';
19 document.querySelectorAll('[data-network]').forEach(function(n) {
20 networks.push(n.getAttribute('data-network'));
23 function render_iface(ifc) {
24 return E('span', { class: 'cbi-tooltip-container' }, [
25 E('img', { 'class' : 'middle', 'src': L.resource('icons/%s%s.png').format(
26 ifc.is_alias ? 'alias' : ifc.type,
27 ifc.is_up ? '' : '_disabled') }),
28 E('span', { 'class': 'cbi-tooltip ifacebadge large' }, [
29 E('img', { 'src': L.resource('icons/%s%s.png').format(
30 ifc.type, ifc.is_up ? '' : '_disabled') }),
31 L.itemlist(E('span', { 'class': 'left' }), [
32 _('Type'), ifc.typename,
33 _('Device'), ifc.ifname,
34 _('Connected'), ifc.is_up ? _('yes') : _('no'),
35 _('MAC'), ifc.macaddr,
36 _('RX'), '%.2mB (%d %s)'.format(ifc.rx_bytes, ifc.rx_packets, _('Pkts.')),
37 _('TX'), '%.2mB (%d %s)'.format(ifc.tx_bytes, ifc.tx_packets, _('Pkts.'))
43 L.poll(5, L.url('admin/network/iface_status', networks.join(',')), null,
46 for (var idx = 0; idx < ifcs.length; idx++) {
49 var s = document.getElementById(ifc.id + '-ifc-devices');
51 var c = [ render_iface(ifc) ];
53 if (ifc.subdevices && ifc.subdevices.length)
57 for (var j = 0; j < ifc.subdevices.length; j++)
58 sifs.push(render_iface(ifc.subdevices[j]));
62 c.push(E('span', {}, sifs));
66 c.push(E('small', {}, ifc.is_alias ? _('Alias of "%s"').format(ifc.is_alias) : ifc.name));
71 var d = document.getElementById(ifc.id + '-ifc-description');
72 if (d && ifc.proto && ifc.ifname) {
73 var desc = null, c = [];
76 desc = _('Virtual dynamic interface');
77 else if (ifc.is_alias)
78 desc = _('Alias Interface');
81 desc = desc ? '%s (%s)'.format(desc, ifc.desc) : ifc.desc;
84 _('Protocol'), '%h'.format(desc || '?'),
85 _('Uptime'), ifc.is_up ? '%t'.format(ifc.uptime) : null,
86 _('MAC'), (!ifc.is_dynamic && !ifc.is_alias && ifc.macaddr) ? ifc.macaddr : null,
87 _('RX'), (!ifc.is_dynamic && !ifc.is_alias) ? '%.2mB (%d %s)'.format(ifc.rx_bytes, ifc.rx_packets, _('Pkts.')) : null,
88 _('TX'), (!ifc.is_dynamic && !ifc.is_alias) ? '%.2mB (%d %s)'.format(ifc.tx_bytes, ifc.tx_packets, _('Pkts.')) : null,
89 _('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[0] : null,
90 _('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[1] : null,
91 _('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[2] : null,
92 _('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[3] : null,
93 _('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[4] : null,
94 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[0] : null,
95 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[1] : null,
96 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[2] : null,
97 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[3] : null,
98 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[4] : null,
99 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[5] : null,
100 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[6] : null,
101 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[7] : null,
102 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[8] : null,
103 _('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[9] : null,
104 _('IPv6-PD'), ifc.ip6prefix,
105 _('Error'), ifc.errors ? ifc.errors[0] : null,
106 _('Error'), ifc.errors ? ifc.errors[1] : null,
107 _('Error'), ifc.errors ? ifc.errors[2] : null,
108 _('Error'), ifc.errors ? ifc.errors[3] : null,
109 _('Error'), ifc.errors ? ifc.errors[4] : null,
112 else if (d && !ifc.proto) {
113 var e = document.getElementById(ifc.id + '-ifc-edit');
114 if (e) e.disabled = true;
116 var link = L.url('admin/system/opkg') + '?query=luci-proto';
118 E('em', _('Unsupported protocol type.')), E('br'),
119 E('a', { href: link }, _('Install protocol extensions...'))
122 else if (d && !ifc.ifname) {
123 var link = L.url('admin/network/network', ifc.name) + '?tab.network.%s=physical'.format(ifc.name);
125 E('em', _('Network without interfaces.')), E('br'),
126 E('a', { href: link }, _('Assign interfaces...'))
130 L.dom.content(d, E('em' ,_('Interface not present or not connected yet.')));