Skip to content

Commit

Permalink
luci-mod-network: Rework the (multi) mac for static leases
Browse files Browse the repository at this point in the history
+i18n

Removed Jows widget which hindered management of multi mac entries.

Signed-off-by: Paul Donald <newtwen@gmail.com>
  • Loading branch information
systemcrash committed Dec 28, 2023
1 parent bcaa445 commit d5db173
Showing 1 changed file with 3 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
Expand All @@ -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];
Expand Down

0 comments on commit d5db173

Please sign in to comment.