diff options
Diffstat (limited to 'modules/luci-mod-status')
-rw-r--r-- | modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js | 50 |
1 files changed, 33 insertions, 17 deletions
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 b226e4f3c6..1351ab935a 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 @@ -3,9 +3,16 @@ 'require fs'; 'require ui'; 'require uci'; +'require rpc'; 'require network'; 'require firewall'; +var callGetBuiltinEthernetPorts = rpc.declare({ + object: 'luci', + method: 'getBuiltinEthernetPorts', + expect: { result: [] } +}); + function isString(v) { return typeof(v) === 'string' && v !== ''; @@ -284,6 +291,7 @@ return baseclass.extend({ load: function() { return Promise.all([ + L.resolveDefault(callGetBuiltinEthernetPorts(), []), L.resolveDefault(fs.read('/etc/board.json'), '{}'), firewall.getZones(), network.getNetworks(), @@ -295,28 +303,36 @@ return baseclass.extend({ if (L.hasSystemFeature('swconfig')) return null; - var board = JSON.parse(data[0]), + var board = JSON.parse(data[1]), known_ports = [], - port_map = buildInterfaceMapping(data[1], data[2]); - - if (L.isObject(board) && L.isObject(board.network)) { - for (var k = 'lan'; k != null; k = (k == 'lan') ? 'wan' : null) { - if (!L.isObject(board.network[k])) - continue; + port_map = buildInterfaceMapping(data[2], data[3]); - if (Array.isArray(board.network[k].ports)) - for (let i = 0; i < board.network[k].ports.length; i++) + if (Array.isArray(data[0]) && data[0].length > 0) { + known_ports = data[0].map(port => ({ + ...port, + netdev: network.instantiateDevice(port.device) + })); + } + else { + if (L.isObject(board) && L.isObject(board.network)) { + for (var k = 'lan'; k != null; k = (k == 'lan') ? 'wan' : null) { + if (!L.isObject(board.network[k])) + continue; + + if (Array.isArray(board.network[k].ports)) + for (let i = 0; i < board.network[k].ports.length; i++) + known_ports.push({ + role: k, + device: board.network[k].ports[i], + netdev: network.instantiateDevice(board.network[k].ports[i]) + }); + else if (typeof(board.network[k].device) == 'string') known_ports.push({ role: k, - device: board.network[k].ports[i], - netdev: network.instantiateDevice(board.network[k].ports[i]) + device: board.network[k].device, + netdev: network.instantiateDevice(board.network[k].device) }); - else if (typeof(board.network[k].device) == 'string') - known_ports.push({ - role: k, - device: board.network[k].device, - netdev: network.instantiateDevice(board.network[k].device) - }); + } } } |