diff options
Diffstat (limited to 'applications/luci-app-adblock-fast/htdocs/luci-static/resources')
3 files changed, 142 insertions, 9 deletions
diff --git a/applications/luci-app-adblock-fast/htdocs/luci-static/resources/adblock-fast/status.js b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/adblock-fast/status.js index 89dcb8846e..9b845e3ff8 100644 --- a/applications/luci-app-adblock-fast/htdocs/luci-static/resources/adblock-fast/status.js +++ b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/adblock-fast/status.js @@ -328,7 +328,7 @@ var status = baseclass.extend({ _("Start") ); - var btn_action = E( + var btn_action_dl = E( "button", { class: "btn cbi-button cbi-button-apply", @@ -338,13 +338,28 @@ var status = baseclass.extend({ E( "p", { class: "spinning" }, - _("Force re-downloading %s block lists").format(pkg.Name) + _("Force redownloading %s block lists").format(pkg.Name) ), ]); return RPC.setInitAction(pkg.Name, "dl"); }, }, - _("Force Re-Download") + _("Redownload") + ); + + var btn_action_pause = E( + "button", + { + class: "btn cbi-button cbi-button-apply", + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E("p", { class: "spinning" }, _("Pausing %s").format(pkg.Name)), + ]); + return RPC.setInitAction(pkg.Name, "pause"); + }, + }, + _("Pause") ); var btn_stop = E( @@ -410,17 +425,20 @@ var status = baseclass.extend({ switch (reply.status.status) { case "statusSuccess": btn_start.disabled = true; - btn_action.disabled = false; + btn_action_dl.disabled = false; + btn_action_pause.disabled = false; btn_stop.disabled = false; break; case "statusStopped": btn_start.disabled = false; - btn_action.disabled = true; + btn_action_dl.disabled = true; + btn_action_pause.disabled = true; btn_stop.disabled = true; break; default: btn_start.disabled = false; - btn_action.disabled = true; + btn_action_dl.disabled = true; + btn_action_pause.disabled = true; btn_stop.disabled = false; btn_enable.disabled = true; btn_disable.disabled = true; @@ -428,7 +446,8 @@ var status = baseclass.extend({ } } else { btn_start.disabled = true; - btn_action.disabled = true; + btn_action_dl.disabled = true; + btn_action_pause.disabled = true; btn_stop.disabled = true; btn_enable.disabled = false; btn_disable.disabled = true; @@ -442,8 +461,10 @@ var status = baseclass.extend({ ); var buttonsText = E("div", {}, [ btn_start, + // btn_gap, + // btn_action_pause, btn_gap, - btn_action, + btn_action_dl, btn_gap, btn_stop, btn_gap_long, 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 ce9041e8f8..ab36223983 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 @@ -378,7 +378,7 @@ return view.extend({ s3.anonymous = true; s3.addremove = true; - o = s3.option(form.DummyValue, "_size", "Size"); + o = s3.option(form.DummyValue, "_size", _("Size")); o.modalonly = false; o.cfgvalue = function (section_id) { let url = uci.get(pkg.Name, section_id, "url"); @@ -399,6 +399,10 @@ return view.extend({ o.value("allow", _("Allow")); o.value("block", _("Block")); o.default = "block"; + o.textvalue = function (section_id) { + var val = this.cfgvalue(section_id); + return val == "allow" ? _("Allow") : _("Block"); + }; o = s3.option(form.Value, "url", _("URL")); o.optional = false; diff --git a/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/status/include/70_adblock-fast.js b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/status/include/70_adblock-fast.js new file mode 100644 index 0000000000..5dd3d9079c --- /dev/null +++ b/applications/luci-app-adblock-fast/htdocs/luci-static/resources/view/status/include/70_adblock-fast.js @@ -0,0 +1,108 @@ +"require ui"; +"require rpc"; +"require form"; +"require baseclass"; + +var pkg = { + get Name() { + return "adblock-fast"; + }, + get URL() { + return "https://docs.openwrt.melmac.net/" + pkg.Name + "/"; + }, +}; + +var getInitStatus = rpc.declare({ + object: "luci." + pkg.Name, + method: "getInitStatus", + params: ["name"], +}); + +return baseclass.extend({ + title: _("AdBlock-Fast"), + + load: function () { + return Promise.all([getInitStatus(pkg.Name)]); + }, + + render: function (data) { + var reply = { + status: (data[0] && data[0][pkg.Name]) || { + enabled: false, + status: null, + running: null, + version: null, + errors: [], + warnings: [], + force_dns_active: null, + force_dns_ports: [], + entries: null, + dns: null, + outputFile: null, + outputCache: null, + outputGzip: null, + outputFileExists: null, + outputCacheExists: null, + outputGzipExists: null, + leds: [], + }, + }; + var statusTable = { + statusNoInstall: _("%s is not installed or not found").format(pkg.Name), + statusStopped: _("Stopped"), + statusStarting: _("Starting"), + statusProcessing: _("Processing lists"), + statusRestarting: _("Restarting"), + statusForceReloading: _("Force Reloading"), + statusDownloading: _("Downloading lists"), + statusError: _("Error"), + statusWarning: _("Warning"), + statusFail: _("Fail"), + statusSuccess: _("Active"), + }; + + var cacheText; + if (reply.status.outputCacheExists) { + cacheText = _("Cache file"); + } else if (reply.status.outputGzipExists) { + cacheText = _("Compressed cache"); + } + var forceDnsText = ""; + if (reply.status.force_dns_active) { + reply.status.force_dns_ports.forEach((element) => { + forceDnsText += element + " "; + }); + } else { + forceDnsText = "-"; + } + + var table = E( + "table", + { class: "table", id: "adblock-fast_status_table" }, + [ + E("tr", { class: "tr table-titles" }, [ + E("th", { class: "th" }, _("Status")), + E("th", { class: "th" }, _("Version")), + E("th", { class: "th" }, _("DNS Service")), + E("th", { class: "th" }, _("Blocked Domains")), + E("th", { class: "th" }, _("Cache")), + E("th", { class: "th" }, _("Force DNS Ports")), + ]), + E("tr", { class: "tr" }, [ + E( + "td", + { class: "td" }, + statusTable[reply.status.status] || _("Unknown") + ), + E("td", { class: "td" }, reply.status.version || _("-")), + E("td", { class: "td" }, reply.status.dns || _("-")), + E("td", { class: "td" }, reply.status.entries || _("-")), + E("td", { class: "td" }, cacheText || _("-")), + E("td", { class: "td" }, forceDnsText || _("-")), + ]), + ] + ); + + return table; + }, +}); |