X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=blobdiff_plain;f=luci2%2Fhtdocs%2Fluci2%2Fluci2.js;h=f094b0099bb593ff1723c34695c808d6369b388e;hp=fc3c3fc7eef8a955f67be77b2593743ad8aa10ab;hb=ba6f9903982c5ed30a380b80cf7bd74c8843afa6;hpb=24108a53232127daf90db3b6f798443fa23a4aa3 diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index fc3c3fc..f094b00 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -5933,49 +5933,14 @@ function LuCI2() this.cbi.NetworkList = this.cbi.AbstractValue.extend({ load: function(sid) { - var self = this; - - if (!self.interfaces) - { - self.interfaces = [ ]; - return _luci2.network.getNetworkStatus().then(function(ifaces) { - self.interfaces = ifaces; - self = null; - }); - } - - return undefined; + return _luci2.NetworkModel.init(); }, _device_icon: function(dev) { - var type = 'ethernet'; - var desc = _luci2.tr('Ethernet device'); - - if (dev.type == 'IP tunnel') - { - type = 'tunnel'; - desc = _luci2.tr('Tunnel interface'); - } - else if (dev['bridge-members']) - { - type = 'bridge'; - desc = _luci2.tr('Bridge'); - } - else if (dev.wireless) - { - type = 'wifi'; - desc = _luci2.tr('Wireless Network'); - } - else if (dev.device.indexOf('.') > 0) - { - type = 'vlan'; - desc = _luci2.tr('VLAN interface'); - } - return $('') - .attr('src', _luci2.globals.resource + '/icons/' + type + (dev.up ? '' : '_disabled') + '.png') - .attr('title', '%s (%s)'.format(desc, dev.device)); + .attr('src', dev.icon()) + .attr('title', '%s (%s)'.format(dev.description(), dev.name() || '?')); }, widget: function(sid) @@ -5995,34 +5960,36 @@ function LuCI2() for (var i = 0; i < value.length; i++) check[value[i]] = true; - if (this.interfaces) + var interfaces = _luci2.NetworkModel.getInterfaces(); + + for (var i = 0; i < interfaces.length; i++) { - for (var i = 0; i < this.interfaces.length; i++) - { - var iface = this.interfaces[i]; - var badge = $('') - .addClass('badge') - .text('%s: '.format(iface['interface'])); - - if (iface.device && iface.device.subdevices) - for (var j = 0; j < iface.device.subdevices.length; j++) - badge.append(this._device_icon(iface.device.subdevices[j])); - else if (iface.device) - badge.append(this._device_icon(iface.device)); - else - badge.append($('').text(_luci2.tr('(No devices attached)'))); + var iface = interfaces[i]; + var badge = $('') + .addClass('badge') + .text('%s: '.format(iface.name())); - $('
') - .append($('') - .addClass(itype + ' inline') - .append($('') - .attr('name', itype + id) - .attr('type', itype) - .attr('value', iface['interface']) - .prop('checked', !!check[iface['interface']])) - .append(badge)) - .appendTo(ul); - } + var dev = iface.getDevice(); + var subdevs = iface.getSubdevices(); + + if (subdevs.length) + for (var j = 0; j < subdevs.length; j++) + badge.append(this._device_icon(subdevs[j])); + else if (dev) + badge.append(this._device_icon(dev)); + else + badge.append($('').text(_luci2.tr('(No devices attached)'))); + + $('') + .append($('') + .addClass(itype + ' inline') + .append($('') + .attr('name', itype + id) + .attr('type', itype) + .attr('value', iface.name()) + .prop('checked', !!check[iface.name()])) + .append(badge)) + .appendTo(ul); } if (!this.options.multiple) @@ -6034,7 +6001,7 @@ function LuCI2() .attr('name', itype + id) .attr('type', itype) .attr('value', '') - .prop('checked', !value)) + .prop('checked', $.isEmptyObject(check))) .append(_luci2.tr('unspecified'))) .appendTo(ul); }