diff options
author | Dirk Brenken <dev@brenken.org> | 2017-03-27 11:36:41 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2017-03-27 11:36:41 +0200 |
commit | f2264da43cd521bd64e687c91bc7b94c3e28e7b3 (patch) | |
tree | a1009d4d8c50dd3b5f851c313cfa2cf489e455cb /applications/luci-app-adblock/luasrc/model | |
parent | 65a089d6798e60a807fa250c5789dee52bb735f5 (diff) |
luci-app-adblock: small fixes in overview tab
* mute stderr in syscalls
* better suspend/resume button handling
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-adblock/luasrc/model')
-rw-r--r-- | applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua index 51039232a..7919b7151 100644 --- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua +++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua @@ -5,8 +5,8 @@ local sys = require("luci.sys") local util = require("luci.util") local data = util.ubus("service", "get_data", "name", "adblock") or { } -local dnsFile1 = sys.exec("find '/tmp/dnsmasq.d' -maxdepth 1 -type f -name 'adb_list*' -print") -local dnsFile2 = sys.exec("find '/var/lib/unbound' -maxdepth 1 -type f -name 'adb_list*' -print") +local dnsFile1 = sys.exec("find '/tmp/dnsmasq.d' -maxdepth 1 -type f -name 'adb_list*' -print 2>/dev/null") +local dnsFile2 = sys.exec("find '/var/lib/unbound' -maxdepth 1 -type f -name 'adb_list*' -print 2>/dev/null") m = Map("adblock", translate("Adblock"), translate("Configuration of the adblock package to block ad/abuse domains by using DNS. ") @@ -24,17 +24,24 @@ o1 = s:option(Flag, "adb_enabled", translate("Enable adblock")) o1.rmempty = false o1.default = 0 -if data.adblock ~= nil and (dnsFile1 ~= "" or dnsFile2 ~= "") then -btn = s:option( Button, "_btn", translate("Suspend adblock")) +btn = s:option(Button, "", translate("Suspend / Resume adblock")) +if data.adblock == nil then + btn.inputtitle = "n/a" + btn.inputstyle = nil + btn.disabled = true +elseif dnsFile1 ~= "" or dnsFile2 ~= "" then + btn.inputtitle = "Suspend adblock" btn.inputstyle = "reset" + btn.disabled = false function btn.write() - luci.sys.call("/etc/init.d/adblock suspend") + luci.sys.call("/etc/init.d/adblock suspend >/dev/null 2>&1") end else - btn = s:option( Button, "_btn", translate("Resume adblock")) + btn.inputtitle = "Resume adblock" btn.inputstyle = "apply" + btn.disabled = false function btn.write() - luci.sys.call("/etc/init.d/adblock resume") + luci.sys.call("/etc/init.d/adblock resume >/dev/null 2>&1") end end @@ -53,44 +60,46 @@ o3.rmempty =false ds.template = "cbi/nullsection" dv1 = s:option(DummyValue, "adblock_version", translate("Adblock version")) + dv1.template = "adblock/runtime" if data.adblock ~= nil then - dv1.value = data.adblock.adblock.adblock_version or "?" + dv1.value = data.adblock.adblock.adblock_version or "n/a" else - dv1.value = "?" + dv1.value = "n/a" end - dv1.template = "adblock/runtime" dv2 = s:option(DummyValue, "status", translate("Status")) - if dnsFile1 ~= "" or dnsFile2 ~= "" then + dv2.template = "adblock/runtime" + if data.adblock == nil then + dv2.value = "n/a" + elseif dnsFile1 ~= "" or dnsFile2 ~= "" then dv2.value = "active" else dv2.value = "suspended" end - dv2.template = "adblock/runtime" dv3 = s:option(DummyValue, "dns_backend", translate("DNS backend")) + dv3.template = "adblock/runtime" if data.adblock ~= nil then - dv3.value = data.adblock.adblock.dns_backend or "?" + dv3.value = data.adblock.adblock.dns_backend or "n/a" else - dv3.value = "?" + dv3.value = "n/a" end - dv3.template = "adblock/runtime" dv4 = s:option(DummyValue, "blocked_domains", translate("Blocked domains (overall)")) + dv4.template = "adblock/runtime" if data.adblock ~= nil then - dv4.value = data.adblock.adblock.blocked_domains or "?" + dv4.value = data.adblock.adblock.blocked_domains or "n/a" else - dv4.value = "?" + dv4.value = "n/a" end - dv4.template = "adblock/runtime" dv5 = s:option(DummyValue, "last_rundate", translate("Last rundate")) + dv5.template = "adblock/runtime" if data.adblock ~= nil then - dv5.value = data.adblock.adblock.last_rundate or "?" + dv5.value = data.adblock.adblock.last_rundate or "n/a" else - dv5.value = "?" + dv5.value = "n/a" end - dv5.template = "adblock/runtime" -- Blocklist options |