From: Jo-Philipp Wich Date: Fri, 11 Oct 2013 14:57:04 +0000 (+0000) Subject: luci2: add port status to switch configuration view X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=commitdiff_plain;h=f4cf4279c0b9b774ee2242c8b9f0cd31b4daf479 luci2: add port status to switch configuration view --- diff --git a/luci2/htdocs/luci2/view/network.switch.js b/luci2/htdocs/luci2/view/network.switch.js index 659c431..c1f04d7 100644 --- a/luci2/htdocs/luci2/view/network.switch.js +++ b/luci2/htdocs/luci2/view/network.switch.js @@ -74,6 +74,8 @@ L.ui.view.extend({ for (var i = 0; i < switches.length; i++) { + var swname = switches[i]['switch']; + var vid_opt = 'vlan'; var v4k_opt = undefined; var pvid_opt = undefined; @@ -106,7 +108,7 @@ L.ui.view.extend({ var sw = m.section(L.cbi.TypedSection, 'switch', { caption: L.tr('Switch "%s"').format(switches[i].model), - swname: switches[i]['switch'] + swname: swname }); sw.filter = function(section) { @@ -148,7 +150,7 @@ L.ui.view.extend({ var vlans = m.section(L.cbi.TableSection, 'switch_vlan', { caption: L.tr('VLANs on "%s"').format(switches[i].model), - swname: switches[i]['switch'], + swname: swname, addremove: true, add_caption: L.tr('Add VLAN entry …') }); @@ -273,14 +275,33 @@ L.ui.view.extend({ label = L.trc('Switch port label', 'CPU'); var po = vlans.option(self.switchPortState, j.toString(), { - caption: label + caption: label + '
'.format(swname, j) }); port_opts.push(po); } } - return m.insertInto('#map'); + m.insertInto('#map'); + + self.repeat(function() { + return L.network.getSwitchStatus(swname).then(function(ports) { + for (var j = 0; j < ports.length; j++) + { + var s = L.tr('No link'); + var d = ' '; + + if (ports[j].link) + { + s = '%dbaseT'.format(ports[j].speed); + d = ports[j].full_duplex ? L.tr('Full-duplex') : L.tr('Half-duplex'); + } + + $('#portstatus-%s-%d'.format(swname, j)) + .empty().append(s + '
' + d); + } + }); + }, 5000); }); } });