luci-mod-status: rework interface status info

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald 2024-11-05 19:06:49 +01:00
parent 247820d854
commit 7dde3239e0

View File

@ -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
]),