luci-mod-network: Rework the (multi) mac for static leases
authorPaul Donald <[email protected]>
Thu, 7 Dec 2023 00:06:16 +0000 (01:06 +0100)
committerPaul Donald <[email protected]>
Thu, 28 Dec 2023 18:43:26 +0000 (18:43 +0000)
+i18n

Removed Jows widget which hindered management of multi mac entries.

Signed-off-by: Paul Donald <[email protected]>
(cherry picked from commit d5db17361a556f9c7eda8fa1a0b0c59d57034633)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js

index 074bfbc71bf7691224c513e7936418de7219254a..c78738b9cca31ead43a2da0240cc3f6bc3c14a9d 100644 (file)
@@ -913,7 +913,8 @@ return view.extend({
                        uci.unset('dhcp', section, 'dns');
                };
 
-               so = ss.option(form.Value, 'mac',
+               //this can be a .DynamicList or a .Value with a widget and dnsmasq handles multimac OK.
+               so = ss.option(form.DynamicList, 'mac',
                        _('MAC address(es)'),
                        _('The hardware address(es) of this entry/host.') + '<br /><br />' + 
                        _('In DHCPv4, it is possible to include more than one mac address. This allows an IP address to be associated with multiple macaddrs, and dnsmasq abandons a DHCP lease to one of the macaddrs when another asks for a lease. It only works reliably if only one of the macaddrs is active at any time.'));
@@ -923,30 +924,7 @@ return view.extend({
                        var macs = L.toArray(uci.get('dhcp', section, 'mac'));
                        return expandAndFormatMAC(macs);
                };
-               so.renderWidget = function(section_id, option_index, cfgvalue) {
-                       var node = form.Value.prototype.renderWidget.apply(this, [section_id, option_index, cfgvalue]),
-                           ipopt = this.section.children.filter(function(o) { return o.option == 'ip' })[0];
-
-                       node.addEventListener('cbi-dropdown-change', L.bind(function(ipopt, section_id, ev) {
-                               var mac = ev.detail.value.value;
-                               if (mac == null || mac == '' || !hosts[mac])
-                                       return;
-
-                               var iphint = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4)[0];
-                               if (iphint == null)
-                                       return;
-
-                               var ip = ipopt.formvalue(section_id);
-                               if (ip != null && ip != '')
-                                       return;
-
-                               var node = ipopt.map.findElement('id', ipopt.cbid(section_id));
-                               if (node)
-                                       dom.callClassMethod(node, 'setValue', iphint);
-                       }, this, ipopt, section_id));
-
-                       return node;
-               };
+               //removed jows renderwidget function which hindered multi-mac entry
                so.validate = validateMACAddr.bind(so, pools);
                Object.keys(hosts).forEach(function(mac) {
                        var hint = hosts[mac].name || L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4)[0];