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>
This commit is contained in:
Jo-Philipp Wich 2021-10-11 23:43:23 +02:00
parent 22b7442011
commit 5ac9fd7b3b

View file

@ -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' })