Skip to content

Commit

Permalink
luci-mod-status: Hide Active DHCP Leases table(s) if there are no act…
Browse files Browse the repository at this point in the history
…ive leases

If the DHCP Server is disabled, showing empty lease table on status page will be redundant.

Signed-off-by: CharlesMengCA <CharlesMeng@outlook.com>
  • Loading branch information
CharlesMengCA committed May 23, 2024
1 parent 9247bf4 commit 4d36274
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ return baseclass.extend({
hosts = uci.sections('dhcp', 'host'),
isReadonlyView = !L.hasViewPermission();

if (leases.length < 1 && leases6.length < 1) {
return E([]);
}

for (var i = 0; i < hosts.length; i++) {
var host = hosts[i];

Expand Down Expand Up @@ -178,12 +182,17 @@ return baseclass.extend({
return rows;
}, this)), E('em', _('There are no active leases')));

return E([
E('h3', _('Active DHCP Leases')),
table,
E('h3', _('Active DHCPv6 Leases')),
table6
]);
var result = [];

if (leases.length > 0) {
result.push(E('h3', _('Active DHCP Leases')), table)
}

if (leases6.length > 0) {
result.push(E('h3', _('Active DHCPv6 Leases')), table6)
}

return E(result);
},

render: function(data) {
Expand Down

0 comments on commit 4d36274

Please sign in to comment.