From 0bf5e5ca06a53140667f12fd728257157a3d945e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 31 Oct 2023 23:53:25 +0100 Subject: luci-mod-status: 29_ports.js: handle devices without speed indication Use carrier state to distinguish connected/no link states and simply print "Connected" if no speed indication is available. Fixes: #6663 Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/resources/view/status/include/29_ports.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules/luci-mod-status/htdocs') diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js index 9ea5555deb..ab1852323b 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js @@ -209,7 +209,7 @@ function buildInterfaceMapping(zones, networks) { return portmap; } -function formatSpeed(speed, duplex) { +function formatSpeed(carrier, speed, duplex) { if (speed && duplex) { var d = (duplex == 'half') ? '\u202f(H)' : '', e = E('span', { 'title': _('Speed: %d Mibit/s, Duplex: %s').format(speed, duplex) }); @@ -229,7 +229,7 @@ function formatSpeed(speed, duplex) { return e; } - return _('no link'); + return carrier ? _('Connected') : _('no link'); } function formatStats(portdev) { @@ -352,15 +352,16 @@ return baseclass.extend({ return E('div', { 'style': 'display:grid;grid-template-columns:repeat(auto-fit, minmax(70px, 1fr));margin-bottom:1em' }, known_ports.map(function(port) { var speed = port.netdev.getSpeed(), duplex = port.netdev.getDuplex(), + carrier = port.netdev.getCarrier(), pmap = port_map[port.netdev.getName()], pzones = (pmap && pmap.zones.length) ? pmap.zones.sort(function(a, b) { return L.naturalCompare(a.getName(), b.getName()) }) : [ null ]; return E('div', { 'class': 'ifacebox', 'style': 'margin:.25em;min-width:70px;max-width:100px' }, [ E('div', { 'class': 'ifacebox-head', 'style': 'font-weight:bold' }, [ port.netdev.getName() ]), E('div', { 'class': 'ifacebox-body' }, [ - E('img', { 'src': L.resource('icons/port_%s.png').format((speed && duplex) ? 'up' : 'down') }), + E('img', { 'src': L.resource('icons/port_%s.png').format(carrier ? 'up' : 'down') }), E('br'), - formatSpeed(speed, duplex) + formatSpeed(carrier, speed, duplex) ]), E('div', { 'class': 'ifacebox-head cbi-tooltip-container', 'style': 'display:flex' }, [ E([], pzones.map(function(zone) { -- cgit v1.2.3