summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-network/htdocs/luci-static
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-network/htdocs/luci-static')
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js55
1 files changed, 20 insertions, 35 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
index 96dc72b99d..6f9f2df941 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
@@ -65,46 +65,31 @@ function render_status(node, ifc, with_device) {
null, E('em', _('Interface is marked for deletion'))
]);
- var i18n = ifc.getI18n();
- if (i18n)
- desc = desc ? '%s (%s)'.format(desc, i18n) : i18n;
+ desc = desc ? '%s (%s)'.format(desc, ifc.getI18n()) : ifc.getI18n();
- var changecount = with_device ? 0 : count_changes(ifc.getName()),
- ipaddrs = changecount ? [] : ifc.getIPAddrs(),
- ip6addrs = changecount ? [] : ifc.getIP6Addrs(),
- errors = ifc.getErrors(),
- maindev = ifc.getL3Device() || ifc.getDevice(),
- macaddr = maindev ? maindev.getMAC() : null;
+ const changecount = with_device ? 0 : count_changes(ifc.getName());
+ const maindev = ifc.getL3Device() || ifc.getDevice();
+ const macaddr = maindev ? maindev.getMAC() : null;
+ const cond00 = !changecount && !ifc.isDynamic() && !ifc.isAlias();
+ const cond01 = cond00 && macaddr;
+ const cond02 = cond00 && maindev;
+
+ function addEntries(label, array) {
+ return Array.isArray(array) ? array.flatMap((item) => [label, item]) : [label, null];
+ }
return L.itemlist(node, [
_('Protocol'), with_device ? null : (desc || '?'),
- _('Device'), with_device ? (maindev ? maindev.getShortName() : E('em', _('Not present'))) : null,
- _('Uptime'), (!changecount && ifc.isUp()) ? '%t'.format(ifc.getUptime()) : null,
- _('MAC'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && macaddr) ? macaddr : null,
- _('RX'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && maindev) ? '%.2mB (%d %s)'.format(maindev.getRXBytes(), maindev.getRXPackets(), _('Pkts.')) : null,
- _('TX'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && maindev) ? '%.2mB (%d %s)'.format(maindev.getTXBytes(), maindev.getTXPackets(), _('Pkts.')) : null,
- _('IPv4'), ipaddrs[0],
- _('IPv4'), ipaddrs[1],
- _('IPv4'), ipaddrs[2],
- _('IPv4'), ipaddrs[3],
- _('IPv4'), ipaddrs[4],
- _('IPv6'), ip6addrs[0],
- _('IPv6'), ip6addrs[1],
- _('IPv6'), ip6addrs[2],
- _('IPv6'), ip6addrs[3],
- _('IPv6'), ip6addrs[4],
- _('IPv6'), ip6addrs[5],
- _('IPv6'), ip6addrs[6],
- _('IPv6'), ip6addrs[7],
- _('IPv6'), ip6addrs[8],
- _('IPv6'), ip6addrs[9],
- _('IPv6-PD'), changecount ? null : ifc.getIP6Prefix(),
+ _('Device'), with_device ? (maindev ? maindev.getShortName() : E('em', _('Not present'))) : null,
+ _('Uptime'), (!changecount && ifc.isUp()) ? '%t'.format(ifc.getUptime()) : null,
+ _('MAC'), (cond01) ? macaddr : null,
+ _('RX'), (cond02) ? '%.2mB (%d %s)'.format(maindev.getRXBytes(), maindev.getRXPackets(), _('Pkts.')) : null,
+ _('TX'), (cond02) ? '%.2mB (%d %s)'.format(maindev.getTXBytes(), maindev.getTXPackets(), _('Pkts.')) : null,
+ ...addEntries(_('IPv4'), changecount ? [] : ifc.getIPAddrs()),
+ ...addEntries(_('IPv6'), changecount ? [] : ifc.getIP6Addrs()),
+ ...addEntries(_('IPv6-PD'), changecount ? null : ifc.getIP6Prefixes?.()),
_('Information'), with_device ? null : (ifc.get('auto') != '0' ? null : _('Not started on boot')),
- _('Error'), errors ? errors[0] : null,
- _('Error'), errors ? errors[1] : null,
- _('Error'), errors ? errors[2] : null,
- _('Error'), errors ? errors[3] : null,
- _('Error'), errors ? errors[4] : null,
+ ...addEntries(_('Error'), ifc.getErrors()),
null, changecount ? E('a', {
href: '#',
click: L.bind(ui.changes.displayChanges, ui.changes)