Skip to content

Commit

Permalink
luci-mod-status: rework interface status info
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Donald <[email protected]>
  • Loading branch information
systemcrash committed Nov 5, 2024
1 parent 247820d commit 7dde323
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,20 @@ function renderbox(ifc, ipv6) {
expires = ifc.getExpiry(),
uptime = ifc.getUptime();

function addEntries(label, array) {
return Array.isArray(array) ? array.flatMap((item) => [label, item]) : [label, null];
}

return E('div', { class: 'ifacebox' }, [
E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
E('strong', ipv6 ? _('IPv6 Upstream') : _('IPv4 Upstream'))),
E('div', { class: 'ifacebox-body left' }, [
L.itemlist(E('span'), [
_('Protocol'), ifc.getI18n() || E('em', _('Not connected')),
_('Prefix Delegated'), ipv6 ? ifc.getIP6Prefix() : null,
_('Address'), addrs[0],
_('Address'), addrs[1],
_('Address'), addrs[2],
_('Address'), addrs[3],
_('Address'), addrs[4],
_('Address'), addrs[5],
_('Address'), addrs[6],
_('Address'), addrs[7],
_('Address'), addrs[8],
_('Address'), addrs[9],
...addEntries(_('Prefix Delegated'), ipv6 ? ifc.getIP6Prefixes?.() : null),
...addEntries(_('Address'), addrs),
_('Gateway'), ipv6 ? (ifc.getGateway6Addr() || '::') : (ifc.getGatewayAddr() || '0.0.0.0'),
_('DNS') + ' 1', dnssrv[0],
_('DNS') + ' 2', dnssrv[1],
_('DNS') + ' 3', dnssrv[2],
_('DNS') + ' 4', dnssrv[3],
_('DNS') + ' 5', dnssrv[4],
...addEntries(_('DNS'), dnssrv),
_('Expires'), (expires != null && expires > -1) ? '%t'.format(expires) : null,
_('Connected'), (uptime > 0) ? '%t'.format(uptime) : null
]),
Expand Down

0 comments on commit 7dde323

Please sign in to comment.