luci-mod-network,-status: expose the lease interface
authorDavid Härdeman <[email protected]>
Sun, 30 Nov 2025 19:03:03 +0000 (20:03 +0100)
committerPaul Donald <[email protected]>
Wed, 3 Dec 2025 12:36:29 +0000 (13:36 +0100)
This adds support to LuCI for showing the interface which a given lease
corresponds to (assuming that odhcpd is providing the DHCPv4/6 services,
which the code also checks for).

Signed-off-by: David Härdeman <[email protected]>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js

index 3ed5999f3bc279c94dd7696e3b1cbe4cc910b39e..e4ae4567ebb62fa9f1c07c26a4fddb393d30c7be 100644 (file)
@@ -39,6 +39,7 @@ const CBILeaseStatus = form.DummyValue.extend({
                        E('h4', _('Active DHCPv4 Leases')),
                        E('table', { 'id': 'lease_status_table', 'class': 'table' }, [
                                E('tr', { 'class': 'tr table-titles' }, [
+                                       L.hasSystemFeature('odhcpd', 'dhcpv4') ? E('th', { 'class': 'th' }, _('Interface')) : E([]),
                                        E('th', { 'class': 'th' }, _('Hostname')),
                                        E('th', { 'class': 'th' }, _('IPv4 address')),
                                        E('th', { 'class': 'th' }, _('MAC address')),
@@ -58,6 +59,7 @@ const CBILease6Status = form.DummyValue.extend({
                        E('h4', _('Active DHCPv6 Leases')),
                        E('table', { 'id': 'lease6_status_table', 'class': 'table' }, [
                                E('tr', { 'class': 'tr table-titles' }, [
+                                       L.hasSystemFeature('odhcpd', 'dhcpv6') ? E('th', { 'class': 'th' }, _('Interface')) : E([]),
                                        E('th', { 'class': 'th' }, _('Hostname')),
                                        E('th', { 'class': 'th' }, _('IPv6 addresses')),
                                        E('th', { 'class': 'th' }, _('DUID')),
@@ -249,12 +251,17 @@ return view.extend({
                                                        else if (lease.hostname)
                                                                host = lease.hostname;
 
-                                                       return [
+                                                       const columns = [
                                                                host || '-',
                                                                lease.ipaddr,
                                                                vendor ? lease.macaddr + vendor : lease.macaddr,
                                                                exp
                                                        ];
+
+                                                       if (L.hasSystemFeature('odhcpd', 'dhcpv4'))
+                                                               columns.unshift(lease.interface || '-');
+
+                                                       return columns;
                                                }),
                                                E('em', _('There are no active leases'))
                                        );
@@ -281,13 +288,18 @@ return view.extend({
                                                        else if (name)
                                                                host = name;
 
-                                                       return [
+                                                       const columns = [
                                                                host || '-',
                                                                lease.ip6addrs ? lease.ip6addrs.join('<br />') : lease.ip6addr,
                                                                lease.duid,
                                                                lease.iaid,
                                                                exp
                                                        ];
+
+                                                       if (L.hasSystemFeature('odhcpd', 'dhcpv6'))
+                                                               columns.unshift(lease.interface || '-');
+
+                                                       return columns;
                                                }),
                                                E('em', _('There are no active leases'))
                                        );
index abd2476eaa3c5b43f069c0ab803d20fa6b87b776..3cbc0c31ae583257b35f666fbaeb82247cee581a 100644 (file)
@@ -106,6 +106,7 @@ return baseclass.extend({
 
                const table = E('table', { 'id': 'status_leases', 'class': 'table lases' }, [
                        E('tr', { 'class': 'tr table-titles' }, [
+                               L.hasSystemFeature('odhcpd', 'dhcpv4') ? E('th', { 'class': 'th' }, _('Interface')) : E([]),
                                E('th', { 'class': 'th' }, _('Hostname')),
                                E('th', { 'class': 'th' }, _('IPv4 address')),
                                E('th', { 'class': 'th' }, _('MAC address')),
@@ -145,6 +146,9 @@ return baseclass.extend({
                                exp,
                        ];
 
+                       if (L.hasSystemFeature('odhcpd', 'dhcpv4'))
+                               columns.unshift(lease.interface || '-');
+
                        if (!isReadonlyView && lease.macaddr != null) {
                                columns.push(E('button', {
                                        'class': 'cbi-button cbi-button-apply',
@@ -159,6 +163,7 @@ return baseclass.extend({
 
                const table6 = E('table', { 'id': 'status_leases6', 'class': 'table leases6' }, [
                        E('tr', { 'class': 'tr table-titles' }, [
+                               L.hasSystemFeature('odhcpd', 'dhcpv6') ? E('th', { 'class': 'th' }, _('Interface')) : E([]),
                                E('th', { 'class': 'th' }, _('Host')),
                                E('th', { 'class': 'th' }, _('IPv6 addresses')),
                                E('th', { 'class': 'th' }, _('DUID')),
@@ -208,6 +213,9 @@ return baseclass.extend({
                                exp
                        ];
 
+                       if (L.hasSystemFeature('odhcpd', 'dhcpv6'))
+                               columns.unshift(lease.interface || '-');
+
                        if (!isReadonlyView && lease.duid) {
                                columns.push(E('button', {
                                        'class': 'cbi-button cbi-button-apply',