diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-10-11 23:43:23 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-10-11 23:47:30 +0200 |
commit | 5ac9fd7b3b593b86dc540c9e9d9e5ec725f8cff8 (patch) | |
tree | eef28044caf3faecb70a2bc147eecf6604708d1e /modules/luci-mod-network | |
parent | 22b74420116f561b3f024ee6c27f9adb4e97352f (diff) |
luci-mod-network: diagnostics: remove arp-scan install placeholder
We do not want to advertise functionality that is not installed as it may
have been left out intentionally. Referring to "Missing" functionality
is confusing in this case. It is also not comparable to missing protocol
extension hints as those are backed by actual user configuration.
Also replace the freetext input with a dropdown of known network devices
as the hardcoded `br-lan` is not universally applicable to all setups.
In general we want to avoid hardcoding defaults which might deviate from
the system state.
Finaly drop the superfluous width annotations and add a missing space
to the RPC command declaration.
Fixes: 22b7442011 ("luci-mod-admin-full: add arp-scan to network diagnostic")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js index af61390220..5855ee96af 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js @@ -4,6 +4,7 @@ 'require fs'; 'require ui'; 'require uci'; +'require network'; return view.extend({ handleCommand: function(exec, args) { @@ -50,7 +51,7 @@ return view.extend({ handleArpScan: function(ev, cmd) { var addr = ev.currentTarget.parentNode.previousSibling.value; - return this.handleCommand('arp-scan', [ '-l', '-I', addr]); + return this.handleCommand('arp-scan', [ '-l', '-I', addr ]); }, load: function() { @@ -60,6 +61,7 @@ return view.extend({ L.resolveDefault(fs.stat('/bin/traceroute6'), {}), L.resolveDefault(fs.stat('/usr/bin/traceroute6'), {}), L.resolveDefault(fs.stat('/usr/bin/arp-scan'), {}), + network.getDevices(), uci.load('luci') ]); }, @@ -68,6 +70,7 @@ return view.extend({ var has_ping6 = res[0].path || res[1].path, has_traceroute6 = res[2].path || res[3].path, has_arpscan = res[4].path, + devices = res[5], dns_host = uci.get('luci', 'diag', 'dns') || 'openwrt.org', ping_host = uci.get('luci', 'diag', 'ping') || 'openwrt.org', route_host = uci.get('luci', 'diag', 'route') || 'openwrt.org'; @@ -76,7 +79,7 @@ return view.extend({ E('h2', {}, [ _('Network Utilities') ]), E('table', { 'class': 'table' }, [ E('tr', { 'class': 'tr' }, [ - E('td', { 'class': 'td left', 'width': '25%' }, [ + E('td', { 'class': 'td left' }, [ E('input', { 'style': 'margin:5px 0', 'type': 'text', @@ -99,7 +102,7 @@ return view.extend({ ]) ]), - E('td', { 'class': 'td left', 'width': '25%' }, [ + E('td', { 'class': 'td left' }, [ E('input', { 'style': 'margin:5px 0', 'type': 'text', @@ -122,7 +125,7 @@ return view.extend({ ]) ]), - E('td', { 'class': 'td left', 'width': '25%' }, [ + E('td', { 'class': 'td left' }, [ E('input', { 'style': 'margin:5px 0', 'type': 'text', @@ -136,24 +139,23 @@ return view.extend({ ]) ]), - E('td', { 'class': 'td left', 'width': '25%' }, has_arpscan ? [ - E('input', { + has_arpscan ? E('td', { 'class': 'td left' }, [ + E('select', { 'style': 'margin:5px 0', - 'type': 'text', - 'value': 'br-lan' - }), + 'type': 'text' + }, devices.map(function(device) { + if (!device.isUp()) + return E([]); + + return E('option', { 'value': device.getName() }, [ device.getI18n() ]); + })), E('span', { 'class': 'diag-action' }, [ E('button', { 'class': 'cbi-button cbi-button-action', 'click': ui.createHandlerFn(this, 'handleArpScan') }, [ _('Arp-scan') ]) - ])] : E('p', {}, [ - E('em', _('Missing ARP scan')), E('br'), - E('a', { - href: L.url('admin/system/opkg') + '?query=arp-scan' - }, _('Install `arp-scan`...')) ]) - ), + ]) : E([]), ]) ]), E('pre', { 'class': 'command-output', 'style': 'display:none' }) |