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 <jo@mein.io>
This commit is contained in:
parent
be340ed9c4
commit
0bf5e5ca06
1 changed files with 5 additions and 4 deletions
|
@ -209,7 +209,7 @@ function buildInterfaceMapping(zones, networks) {
|
||||||
return portmap;
|
return portmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSpeed(speed, duplex) {
|
function formatSpeed(carrier, speed, duplex) {
|
||||||
if (speed && duplex) {
|
if (speed && duplex) {
|
||||||
var d = (duplex == 'half') ? '\u202f(H)' : '',
|
var d = (duplex == 'half') ? '\u202f(H)' : '',
|
||||||
e = E('span', { 'title': _('Speed: %d Mibit/s, Duplex: %s').format(speed, duplex) });
|
e = E('span', { 'title': _('Speed: %d Mibit/s, Duplex: %s').format(speed, duplex) });
|
||||||
|
@ -229,7 +229,7 @@ function formatSpeed(speed, duplex) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _('no link');
|
return carrier ? _('Connected') : _('no link');
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatStats(portdev) {
|
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) {
|
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(),
|
var speed = port.netdev.getSpeed(),
|
||||||
duplex = port.netdev.getDuplex(),
|
duplex = port.netdev.getDuplex(),
|
||||||
|
carrier = port.netdev.getCarrier(),
|
||||||
pmap = port_map[port.netdev.getName()],
|
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 ];
|
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' }, [
|
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-head', 'style': 'font-weight:bold' }, [ port.netdev.getName() ]),
|
||||||
E('div', { 'class': 'ifacebox-body' }, [
|
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'),
|
E('br'),
|
||||||
formatSpeed(speed, duplex)
|
formatSpeed(carrier, speed, duplex)
|
||||||
]),
|
]),
|
||||||
E('div', { 'class': 'ifacebox-head cbi-tooltip-container', 'style': 'display:flex' }, [
|
E('div', { 'class': 'ifacebox-head cbi-tooltip-container', 'style': 'display:flex' }, [
|
||||||
E([], pzones.map(function(zone) {
|
E([], pzones.map(function(zone) {
|
||||||
|
|
Loading…
Reference in a new issue