luci-base: CBIDeviceSelect includes each device IP when includeips=true
authorPaul Donald <[email protected]>
Mon, 7 Apr 2025 18:15:28 +0000 (20:15 +0200)
committerPaul Donald <[email protected]>
Mon, 7 Apr 2025 18:15:28 +0000 (20:15 +0200)
For use when daemons whose interface config paradigm accept IP also.

Signed-off-by: Paul Donald <[email protected]>
modules/luci-base/htdocs/luci-static/resources/tools/widgets.js

index 171cd4bf9f1f5cbb045611c5f91869861f2a240e..0d8dba323ab890542764b4ccc803ffe7456f783e 100644 (file)
@@ -551,6 +551,20 @@ var CBIDeviceSelect = form.ListValue.extend({
                        }
                }
 
+               if (this.includeips) {
+                       this.devices.forEach(net_dev => {
+                               ['getIPAddrs', 'getIP6Addrs'].forEach(fn => {
+                                       net_dev[fn]().forEach(addr => {
+                                               const name = addr.split('/')[0];
+                                               if (checked[name]) values.push(name);
+
+                                               choices[name] = E([], [name, ' (', E('strong', net_dev.getName()), ')']);
+                                               order.push(name);
+                                       });
+                               });
+                       });
+               }
+
                if (!this.nocreate) {
                        var keys = Object.keys(checked).sort(L.naturalCompare);