diff options
author | Stan Grishin <stangri@melmac.ca> | 2023-12-11 01:03:00 +0000 |
---|---|---|
committer | Stan Grishin <stangri@melmac.ca> | 2023-12-11 01:03:28 +0000 |
commit | 061a5dc40487fbe63e4ce2314b3c95e0293c1a4e (patch) | |
tree | 1a157d722903bde17df366fa2f29b5d45ba01014 /applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast | |
parent | c5b5640f17dad81d2f10a76dcdb9da694baa8991 (diff) |
luci-app-adblock-fast: improve dnsmasq/smartdns instances selection
* create UI elements with an option to pick multiple instances for
dnsmasq and smartdns
Signed-off-by: Stan Grishin <stangri@melmac.ca>
Diffstat (limited to 'applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast')
-rw-r--r-- | applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast/overview.js | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast/overview.js b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast/overview.js index 086200aa89..ceaa75b037 100644 --- a/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast/overview.js +++ b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/adblock-fast/overview.js @@ -179,17 +179,46 @@ return view.extend({ o = s1.taboption( "tab_basic", form.ListValue, - "dnsmasq_instance", + "dnsmasq_instance_option", _("Use AdBlocking on the dnsmasq instance(s)"), _( - "You can limit the AdBlocking to a specific dnsmasq instance(s) (%smore information%s)." + "You can limit the AdBlocking to the specific dnsmasq instance(s) (%smore information%s)." ).format( '<a href="' + pkg.URL + "#dnsmasq_instance" + '" target="_blank">', "</a>" ) ); o.value("*", _("AdBlock on all instances")); + o.value("+", _("AdBlock on select instances")); + o.value("-", _("No AdBlock on dnsmasq")); + o.default = "*"; + o.depends("dns", "dnsmasq.addnhosts"); + o.depends("dns", "dnsmasq.servers"); + o.retain = true; + o.cfgvalue = function (section_id) { + let val = this.map.data.get( + this.map.config, + section_id, + "dnsmasq_instance" + ); + switch (val) { + case "*": + case "-": + return val; + default: + return "+"; + } + }; + o.write = function (section_id, formvalue) { + L.uci.set(pkg.Name, section_id, "dnsmasq_instance", formvalue); + }; + o = s1.taboption( + "tab_basic", + form.MultiValue, + "dnsmasq_instance", + _("Pick the dnsmasq instance(s) for AdBlocking") + ); Object.values(L.uci.sections("dhcp", "dnsmasq")).forEach(function ( element ) { @@ -202,28 +231,55 @@ return view.extend({ key = element[".name"]; description = element[".name"]; } - o.value(key, _("AdBlock on %s only").format(description)); + o.value(key, _("%s").format(description)); }); - o.value("-", _("No AdBlock on dnsmasq")); - o.default = "*"; - o.depends("dns", "dnsmasq.addnhosts"); - o.depends("dns", "dnsmasq.servers"); + o.depends("dnsmasq_instance_option", "+"); o.retain = true; o = s1.taboption( "tab_basic", form.ListValue, - "smartdns_instance", + "smartdns_instance_option", _("Use AdBlocking on the SmartDNS instance(s)"), _( - "You can limit the AdBlocking to a specific SmartDNS instance(s) (%smore information%s)." + "You can limit the AdBlocking to the specific SmartDNS instance(s) (%smore information%s)." ).format( '<a href="' + pkg.URL + "#smartdns_instance" + '" target="_blank">', "</a>" ) ); o.value("*", _("AdBlock on all instances")); + o.value("+", _("AdBlock on select instances")); + o.value("-", _("No AdBlock on SmartDNS")); + o.default = "*"; + o.depends("dns", "smartdns.domainset"); + o.depends("dns", "smartdns.ipset"); + o.depends("dns", "smartdns.nftset"); + o.retain = true; + o.cfgvalue = function (section_id) { + let val = this.map.data.get( + this.map.config, + section_id, + "smartdns_instance" + ); + switch (val) { + case "*": + case "-": + return val; + default: + return "+"; + } + }; + o.write = function (section_id, formvalue) { + L.uci.set(pkg.Name, section_id, "smartdns_instance", formvalue); + }; + o = s1.taboption( + "tab_basic", + form.MultiValue, + "smartdns_instance", + _("Pick the SmartDNS instance(s) for AdBlocking") + ); Object.values(L.uci.sections("smartdns", "smartdns")).forEach(function ( element ) { @@ -236,13 +292,9 @@ return view.extend({ key = element[".name"]; description = element[".name"]; } - o.value(key, _("AdBlock on %s only").format(description)); + o.value(key, _("%s").format(description)); }); - o.value("-", _("No AdBlock on SmartDNS")); - o.default = "*"; - o.depends("dns", "smartdns.domainset"); - o.depends("dns", "smartdns.ipset"); - o.depends("dns", "smartdns.nftset"); + o.depends("smartdns_instance_option", "+"); o.retain = true; o = s1.taboption( |