luci-mod-admin-full: always indicate missing DHCPv6 hostname

Don't show a DHCPv6 supplied hostname if none was send. It happens in
case the DUID can be mapped to the MAC-Address of an existing host and
the existing host has a name set.

Signed-off-by: Mathias Kresin <dev@kresin.me>
This commit is contained in:
Mathias Kresin 2017-11-16 07:32:58 +01:00
parent a1ee8e16b6
commit 9f5a1de8b1
2 changed files with 12 additions and 16 deletions

View file

@ -78,15 +78,13 @@
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
var host = hosts[duid2mac(st[1][i].duid)]; var host = hosts[duid2mac(st[1][i].duid)];
if (!st[1][i].hostname && host) if (!st[1][i].hostname)
tr.insertCell(-1).innerHTML = String.format( tr.insertCell(-1).innerHTML =
'<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>', (host && (host.name || host.ipv4 || host.ipv6))
((host.name && (host.ipv4 || host.ipv6)) ? '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">? (%h)</div>'.format(host.name || host.ipv4 || host.ipv6)
? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6) : '?';
: '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
);
else else
tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?'; tr.insertCell(-1).innerHTML = st[1][i].hostname;
tr.insertCell(-1).innerHTML = st[1][i].ip6addr; tr.insertCell(-1).innerHTML = st[1][i].ip6addr;
tr.insertCell(-1).innerHTML = st[1][i].duid; tr.insertCell(-1).innerHTML = st[1][i].duid;

View file

@ -417,15 +417,13 @@
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
var host = hosts[duid2mac(info.leases6[i].duid)]; var host = hosts[duid2mac(info.leases6[i].duid)];
if (!info.leases6[i].hostname && host) if (!info.leases6[i].hostname)
tr.insertCell(-1).innerHTML = String.format( tr.insertCell(-1).innerHTML =
'<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>', (host && (host.name || host.ipv4 || host.ipv6))
((host.name && (host.ipv4 || host.ipv6)) ? '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">? (%h)</div>'.format(host.name || host.ipv4 || host.ipv6)
? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6) : '?';
: '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
);
else else
tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?'; tr.insertCell(-1).innerHTML = info.leases6[i].hostname;
tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr; tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr;
tr.insertCell(-1).innerHTML = info.leases6[i].duid; tr.insertCell(-1).innerHTML = info.leases6[i].duid;