diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-08-14 23:02:06 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-08-14 23:02:25 +0200 |
commit | d19e97bcb096a01fa0d08825fb787b04e7324d9e (patch) | |
tree | 54274ecdcbbaa4011ba78491707d88da090240ba /modules/luci-base/htdocs | |
parent | 7179d2e6dd1d9baf1f7e8f6862f702588eb5d69c (diff) |
luci-base: widgets.js: support alias interfaces in CBIDeviceSelect
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/tools/widgets.js | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js index 39e5aa1655..2da9e7435f 100644 --- a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js +++ b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js @@ -420,8 +420,12 @@ var CBIDeviceSelect = form.ListValue.extend({ __name__: 'CBI.DeviceSelect', load: function(section_id) { - return network.getDevices().then(L.bind(function(devices) { - this.devices = devices; + return Promise.all([ + network.getDevices(), + this.noaliases ? null : network.getNetworks() + ]).then(L.bind(function(data) { + this.devices = data[0]; + this.networks = data[1]; return this.super('load', section_id); }, this)); @@ -483,6 +487,35 @@ var CBIDeviceSelect = form.ListValue.extend({ order.push(name); } + if (this.networks != null) { + for (var i = 0; i < this.networks.length; i++) { + var net = this.networks[i], + device = network.instantiateDevice('@%s'.format(net.getName()), net), + name = device.getName(); + + if (name == '@loopback' || name == this.exclude || !this.filter(section_id, name)) + continue; + + if (this.noinactive && net.isUp() == false) + continue; + + var item = E([ + E('img', { + 'title': device.getI18n(), + 'src': L.resource('icons/alias%s.png'.format(net.isUp() ? '' : '_disabled')) + }), + E('span', { 'class': 'hide-open' }, [ name ]), + E('span', { 'class': 'hide-close'}, [ device.getI18n() ]) + ]); + + if (checked[name]) + values.push(name); + + choices[name] = item; + order.push(name); + } + } + if (!this.nocreate) { var keys = Object.keys(checked).sort(); |