diff options
Diffstat (limited to 'modules/luci-mod-status')
9 files changed, 128 insertions, 132 deletions
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/bandwidth.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/bandwidth.js index 18e2160b51..0d89ae8ae8 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/bandwidth.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/bandwidth.js @@ -233,7 +233,7 @@ return L.view.extend({ return E('div', { 'style': 'width:100%;height:300px;border:1px solid #000;background:#fff' - }, response.text()); + }, E(response.text())); }); }, diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/connections.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/connections.js index 96dee1db77..458437ede0 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/connections.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/connections.js @@ -306,7 +306,7 @@ return L.view.extend({ return E('div', { 'style': 'width:100%;height:300px;border:1px solid #000;background:#fff' - }, response.text()); + }, E(response.text())); }); }, diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js index 8ac7e7cdae..4a35175290 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js @@ -34,13 +34,28 @@ return L.Class.extend({ return l.replace(/^\s*\w+\s*=\s*['"]([^'"]+)['"].*$/, '$1'); }).join(' '); + var datestr = null; + + if (systeminfo.localtime) { + var date = new Date(systeminfo.localtime * 1000); + + datestr = '%04d-%02d-%02d %02d:%02d:%02d'.format( + date.getUTCFullYear(), + date.getUTCMonth() + 1, + date.getUTCDate(), + date.getUTCHours(), + date.getUTCMinutes(), + date.getUTCSeconds() + ); + } + var fields = [ _('Hostname'), boardinfo.hostname, _('Model'), boardinfo.model, _('Architecture'), boardinfo.system, _('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''), _('Kernel Version'), boardinfo.kernel, - _('Local Time'), systeminfo.localtime ? (new Date(systeminfo.localtime * 1000)).toLocaleString() : null, + _('Local Time'), datestr, _('Uptime'), systeminfo.uptime ? '%t'.format(systeminfo.uptime) : null, _('Load Average'), Array.isArray(systeminfo.load) ? '%.2f, %.2f, %.2f'.format( systeminfo.load[0] / 65535.0, diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js index 2e84774346..b2ebdec710 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js @@ -31,24 +31,24 @@ return L.Class.extend({ swap = L.isObject(systeminfo.swap) ? systeminfo.swap : {}; var fields = [ - _('Total Available'), (mem.available) ? mem.available : (mem.total && mem.free && mem.buffered) ? mem.free + mem.buffered : null, - _('Free'), (mem.total && mem.free) ? mem.free : null, - _('Buffered'), (mem.total && mem.buffered) ? mem.buffered : null + _('Total Available'), (mem.available) ? mem.available : (mem.total && mem.free && mem.buffered) ? mem.free + mem.buffered : null, mem.total, + _('Free'), (mem.total && mem.free) ? mem.free : null, mem.total, + _('Buffered'), (mem.total && mem.buffered) ? mem.buffered : null, mem.total ]; if (mem.cached) - fields.push(_('Cached'), mem.cached); + fields.push(_('Cached'), mem.cached, mem.total); if (swap.total > 0) - fields.push(_('Swap free'), swap.free); + fields.push(_('Swap free'), swap.free, swap.total); var table = E('div', { 'class': 'table' }); - for (var i = 0; i < fields.length; i += 2) { + for (var i = 0; i < fields.length; i += 3) { table.appendChild(E('div', { 'class': 'tr' }, [ E('div', { 'class': 'td left', 'width': '33%' }, [ fields[i] ]), E('div', { 'class': 'td left' }, [ - (fields[i + 1] != null) ? progressbar(fields[i + 1], mem.total, true) : '?' + (fields[i + 1] != null) ? progressbar(fields[i + 1], fields[i + 2], true) : '?' ]) ])); } diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index 1a2f70fbfa..83c0c151eb 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -81,7 +81,7 @@ return L.Class.extend({ return [ host || '-', - lease.ip6addr, + lease.ip6addrs ? lease.ip6addrs.join(' ') : lease.ip6addr, lease.duid, exp ]; diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js index 8242711b6a..e73f57712b 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js @@ -1,15 +1,14 @@ 'use strict'; -'require rpc'; 'require network'; -function renderbox(radio) { +function renderbox(radio, networks) { var chan = null, freq = null, rate = null, badges = []; - for (var i = 0; i < radio.networks.length; i++) { - var net = radio.networks[i], + for (var i = 0; i < networks.length; i++) { + var net = networks[i], is_assoc = (net.getBSSID() != '00:00:00:00:00:00' && net.getChannel() && !net.isDisabled()), quality = net.getSignalPercent(); @@ -37,9 +36,6 @@ function renderbox(radio) { _('Associations'), is_assoc ? (net.assoclist.length || '-') : null, null, is_assoc ? null : E('em', net.isDisabled() ? _('Wireless is disabled') : _('Wireless is not associated'))); - badge.lastElementChild.style.overflow = 'hidden'; - badge.lastElementChild.style.textOverflow = 'ellipsis'; - badges.push(badge); chan = (chan != null) ? chan : net.getChannel(); @@ -80,152 +76,137 @@ function wifirate(rt) { return L.Class.extend({ title: _('Wireless'), - handleDelClient: function(ifname, mac, ev) { + handleDelClient: function(wifinet, mac, ev) { + L.dom.parent(ev.currentTarget, '.tr').style.opacity = 0.5; ev.currentTarget.classList.add('spinning'); ev.currentTarget.disabled = true; ev.currentTarget.blur(); - return rpc.declare({ - object: 'hostapd.%s'.format(ifname), - method: 'del_client', - params: [ 'addr', 'deauth', 'reason', 'ban_time' ] - })(mac, true, 5, 60000); + wifinet.disconnectClient(mac, true, 5, 60000); }, load: function() { - return L.resolveDefault(network.getWifiDevices(), []).then(function(devices) { + return Promise.all([ + network.getWifiDevices(), + network.getWifiNetworks(), + network.getHostHints() + ]).then(function(radios_networks_hints) { var tasks = []; - for (var i = 0; i < devices.length; i++) - tasks.push(L.resolveDefault(devices[i].getWifiNetworks(), []).then(L.bind(function(r, l) { - r.networks = l; - }, this, devices[i]))); + for (var i = 0; i < radios_networks_hints[1].length; i++) + tasks.push(L.resolveDefault(radios_networks_hints[1][i].getAssocList(), []).then(L.bind(function(net, list) { + net.assoclist = list.sort(function(a, b) { return a.mac > b.mac }); + }, this, radios_networks_hints[1][i]))); return Promise.all(tasks).then(function() { - return devices; - }); - }).then(function(devices) { - var tasks = [], deauth = {}; - - for (var i = 0; i < devices.length; i++) { - for (var j = 0; j < devices[i].networks.length; j++) { - tasks.push(L.resolveDefault(devices[i].networks[j].getAssocList(), []).then(L.bind(function(n, l) { - n.assoclist = l.sort(function(a, b) { return a.mac > b.mac }); - }, this, devices[i].networks[j]))); - - tasks.push(L.resolveDefault(rpc.list('hostapd.%s'.format(devices[i].networks[j].getIfname())), {}).then(L.bind(function(n, l) { - for (var k in L.isObject(l) ? l : {}) - n.supports_deauth = l[k].hasOwnProperty('del_client'); - }, this, devices[i].networks[j]))); - } - } - - return Promise.all(tasks).then(function() { - return network.getHostHints().then(function(hosthints) { - return [ devices, hosthints ]; - }); + return radios_networks_hints; }); }); }, render: function(data) { - var devices = data[0], - hosthints = data[1]; + var seen = {}, + radios = data[0], + networks = data[1], + hosthints = data[2]; var table = E('div', { 'class': 'network-status-table' }); - for (var i = 0; i < devices.length; i++) - table.appendChild(renderbox(devices[i])); + for (var i = 0; i < radios.sort(function(a, b) { a.getName() > b.getName() }).length; i++) + table.appendChild(renderbox(radios[i], + networks.filter(function(net) { return net.getWifiDeviceName() == radios[i].getName() }))); if (!table.lastElementChild) return null; - var supports_deauth = false; - - for (var i = 0; i < devices.length; i++) - for (var j = 0; j < devices[i].networks.length; j++) - supports_deauth = supports_deauth || devices[i].networks[j].supports_deauth; - var assoclist = E('div', { 'class': 'table' }, [ E('div', { 'class': 'tr table-titles' }, [ E('div', { 'class': 'th nowrap' }, _('Network')), E('div', { 'class': 'th hide-xs' }, _('MAC-Address')), E('div', { 'class': 'th' }, _('Host')), E('div', { 'class': 'th nowrap' }, '%s / %s'.format(_('Signal'), _('Noise'))), - E('div', { 'class': 'th nowrap' }, '%s / %s'.format(_('RX Rate'), _('TX Rate'))), - supports_deauth ? E('div', { 'class': 'th nowrap right' }, _('Disconnect')) : null + E('div', { 'class': 'th nowrap' }, '%s / %s'.format(_('RX Rate'), _('TX Rate'))) ]) ]); var rows = []; - for (var i = 0; i < devices.length; i++) { - for (var j = 0; j < devices[i].networks.length; j++) { - for (var k = 0; k < devices[i].networks[j].assoclist.length; k++) { - var bss = devices[i].networks[j].assoclist[k], - name = hosthints.getHostnameByMACAddr(bss.mac), - ipv4 = hosthints.getIPAddrByMACAddr(bss.mac), - ipv6 = hosthints.getIP6AddrByMACAddr(bss.mac); - - var icon; - var q = (-1 * (bss.noise - bss.signal)) / 5; - if (q < 1) - icon = L.resource('icons/signal-0.png'); - else if (q < 2) - icon = L.resource('icons/signal-0-25.png'); - else if (q < 3) - icon = L.resource('icons/signal-25-50.png'); - else if (q < 4) - icon = L.resource('icons/signal-50-75.png'); - else - icon = L.resource('icons/signal-75-100.png'); - - var sig_title, sig_value; - - if (bss.noise) { - sig_value = '%d / %d %s'.format(bss.signal, bss.noise, _('dBm')); - sig_title = '%s: %d %s / %s: %d %s / %s %d'.format( - _('Signal'), bss.signal, _('dBm'), - _('Noise'), bss.noise, _('dBm'), - _('SNR'), bss.signal - bss.noise); - } - else { - sig_value = '%d %s'.format(bss.signal, _('dBm')); - sig_title = '%s: %d %s'.format(_('Signal'), bss.signal, _('dBm')); - } - - var hint; - - if (name && ipv4 && ipv6) - hint = '%s (%s, %s)'.format(name, ipv4, ipv6); - else if (name && (ipv4 || ipv6)) - hint = '%s (%s)'.format(name, ipv4 || ipv6); - else - hint = name || ipv4 || ipv6 || '?'; - - rows.push([ - E('span', { 'class': 'ifacebadge', 'title': devices[i].networks[j].getI18n() }, [ - E('img', { 'src': L.resource('icons/wifi.png') }), - ' ', devices[i].networks[j].getShortName(), - E('small', {}, [ ' (', devices[i].networks[j].getIfname(), ')' ]) - ]), - bss.mac, - hint, - E('span', { 'class': 'ifacebadge', 'title': sig_title }, [ - E('img', { 'src': icon }), - ' ', sig_value - ]), - E('span', {}, [ - E('span', wifirate(bss.rx)), - E('br'), - E('span', wifirate(bss.tx)) - ]), - devices[i].networks[j].supports_deauth ? E('button', { - 'class': 'cbi-button cbi-button-remove', - 'click': L.bind(this.handleDelClient, this, devices[i].networks[j].getIfname(), bss.mac) - }, [ _('Disconnect') ]) : '-' - ]); + for (var i = 0; i < networks.length; i++) { + for (var k = 0; k < networks[i].assoclist.length; k++) { + var bss = networks[i].assoclist[k], + name = hosthints.getHostnameByMACAddr(bss.mac), + ipv4 = hosthints.getIPAddrByMACAddr(bss.mac), + ipv6 = hosthints.getIP6AddrByMACAddr(bss.mac); + + var icon; + var q = (-1 * (bss.noise - bss.signal)) / 5; + if (q < 1) + icon = L.resource('icons/signal-0.png'); + else if (q < 2) + icon = L.resource('icons/signal-0-25.png'); + else if (q < 3) + icon = L.resource('icons/signal-25-50.png'); + else if (q < 4) + icon = L.resource('icons/signal-50-75.png'); + else + icon = L.resource('icons/signal-75-100.png'); + + var sig_title, sig_value; + + if (bss.noise) { + sig_value = '%d / %d %s'.format(bss.signal, bss.noise, _('dBm')); + sig_title = '%s: %d %s / %s: %d %s / %s %d'.format( + _('Signal'), bss.signal, _('dBm'), + _('Noise'), bss.noise, _('dBm'), + _('SNR'), bss.signal - bss.noise); + } + else { + sig_value = '%d %s'.format(bss.signal, _('dBm')); + sig_title = '%s: %d %s'.format(_('Signal'), bss.signal, _('dBm')); + } + + var hint; + + if (name && ipv4 && ipv6) + hint = '%s (%s, %s)'.format(name, ipv4, ipv6); + else if (name && (ipv4 || ipv6)) + hint = '%s (%s)'.format(name, ipv4 || ipv6); + else + hint = name || ipv4 || ipv6 || '?'; + + var row = [ + E('span', { 'class': 'ifacebadge', 'title': networks[i].getI18n() }, [ + E('img', { 'src': L.resource('icons/wifi.png') }), + ' ', networks[i].getShortName(), + E('small', {}, [ ' (', networks[i].getIfname(), ')' ]) + ]), + bss.mac, + hint, + E('span', { 'class': 'ifacebadge', 'title': sig_title }, [ + E('img', { 'src': icon }), + ' ', sig_value + ]), + E('span', {}, [ + E('span', wifirate(bss.rx)), + E('br'), + E('span', wifirate(bss.tx)) + ]) + ]; + + if (networks[i].isClientDisconnectSupported()) { + if (assoclist.firstElementChild.childNodes.length < 6) + assoclist.firstElementChild.appendChild(E('div', { 'class': 'th nowrap right' }, [ _('Disconnect') ])); + + row.push(E('button', { + 'class': 'cbi-button cbi-button-remove', + 'click': L.bind(this.handleDelClient, this, networks[i], bss.mac) + }, [ _('Disconnect') ])); + } + else { + row.push('-'); } + + rows.push(row); } } diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js index a742243a03..eaeba578fe 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js @@ -194,7 +194,7 @@ function parse_output(table, s) srcnet, dstnet, options, - comment + [ comment ] ]); if (target) { diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/load.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/load.js index a1ed43478d..646d256d60 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/load.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/load.js @@ -211,7 +211,7 @@ return L.view.extend({ return E('div', { 'style': 'width:100%;height:300px;border:1px solid #000;background:#fff' - }, response.text()); + }, E(response.text())); }); }, diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/wireless.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/wireless.js index ce0c72bc3b..cd8cff133b 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/wireless.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/wireless.js @@ -227,7 +227,7 @@ return L.view.extend({ return E('div', { 'style': 'width:100%;height:300px;border:1px solid #000;background:#fff' - }, response.text()); + }, E(response.text())); }); }, |