diff options
| author | Paul Donald <newtwen@gmail.com> | 2023-12-04 04:51:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-04 04:51:03 +0100 |
| commit | d353bc50cd45bd0863170a0fa2f4e474405f8354 (patch) | |
| tree | c31e712c2040857e249c531461ffead6550811aa /modules | |
| parent | 6ddbb30ac360393a69bfc4c0566b32bd23d9bcd0 (diff) | |
| parent | 0fb8b1f9ad6875a325fa99557a7ea21de04b8710 (diff) | |
Merge pull request #6579 from systemcrash/fix_dnsmasq_instance_fields
luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index da0eeabb5a..538b1b0d55 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -89,6 +89,21 @@ function calculateNetwork(addr, mask) { ]; } +function generateDnsmasqInstanceEntry(data) { + const nameValueMap = new Map(Object.entries(data)); + let formatString = nameValueMap.get('.index') + ' (' + _('Name') + (nameValueMap.get('.anonymous') ? ': dnsmasq[' + nameValueMap.get('.index') + ']': ': ' + nameValueMap.get('.name')); + + if (data.domain) { + formatString += ', ' + _('Domain') + ': ' + data.domain; + } + if (data.local) { + formatString += ', ' + _('Local') + ': ' + data.local; + } + formatString += ')'; + + return nameValueMap.get('.name'), formatString; +} + function getDHCPPools() { return uci.load('dhcp').then(function() { let sections = uci.sections('dhcp', 'dhcp'), @@ -630,7 +645,7 @@ return view.extend({ so.optional = true; Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) { - so.value(index, '%s (Domain: %s, Local: %s)'.format(index, val.domain || '?', val.local || '?')); + so.value(generateDnsmasqInstanceEntry(val)); }); o = s.taboption('srvhosts', form.SectionValue, '__srvhosts__', form.TableSection, 'srvhost', null, @@ -932,7 +947,7 @@ return view.extend({ so.optional = true; Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) { - so.value(index, '%s (Domain: %s, Local: %s)'.format(index, val.domain || '?', val.local || '?')); + so.value(generateDnsmasqInstanceEntry(val)); }); |
