summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-adblock/luasrc/view/adblock/runtime.htm')
-rw-r--r--applications/luci-app-adblock/luasrc/view/adblock/runtime.htm188
1 files changed, 185 insertions, 3 deletions
diff --git a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
index c01d9a5c08..bdcd0a1821 100644
--- a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
+++ b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
@@ -1,10 +1,192 @@
<%#
Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
+local sys = require("luci.sys")
+
-%>
+<style type="text/css">
+.runtime
+{
+ color:#0069d6;
+ font-weight:bold;
+ display:inline-block;
+ width:100%;
+ padding-top: 0.5rem;
+}
+</style>
+
+<script type="text/javascript">
+//<![CDATA[
+ function status_update(json)
+ {
+ var view = document.getElementById("value_1");
+ var btn1 = document.getElementById("btn1");
+ var btn2 = document.getElementById("btn2");
+ var input = json.data.adblock_status;
+
+ view.innerHTML = input || "-";
+ if (input === "enabled")
+ {
+ btn1.value = "Suspend";
+ btn2.value = "Refresh";
+ btn1.disabled = false;
+ running(btn1_running, 0);
+ btn2.disabled = false;
+ running(btn2_running, 0);
+ }
+ else if (input === "paused")
+ {
+ btn1.value = "Resume";
+ btn2.value = "Refresh";
+ btn1.disabled = false;
+ running(btn1_running, 0);
+ btn2.disabled = false;
+ running(btn2_running, 0);
+ }
+ else
+ {
+ btn1.value = "Suspend";
+ btn2.value = "Refresh";
+ btn1.disabled = true;
+ btn2.disabled = true;
+ }
+ view = document.getElementById("value_2");
+ input = json.data.adblock_version;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_3");
+ input = json.data.fetch_utility;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_4");
+ input = json.data.dns_backend;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_5");
+ input = json.data.overall_domains;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_6");
+ input = json.data.last_rundate;
+ view.innerHTML = input || "-";
+ }
+
+ function btn_action(action)
+ {
+ var btn1 = document.getElementById("btn1");
+ var btn1_running = document.getElementById("btn1_running");
+ var btn2 = document.getElementById("btn2");
+ var btn2_running = document.getElementById("btn2_running");
+
+ btn1.disabled = true;
+ btn2.disabled = true;
+
+ if (action.value === "Refresh")
+ {
+ running(btn2_running, 1);
+ }
+ else
+ {
+ running(btn1_running, 1);
+ }
+
+ new XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock")%>/action/' + action.value, null,
+ function(x)
+ {
+ if (!x)
+ {
+ return;
+ }
+ });
+ }
+
+ function running(element, state)
+ {
+ if (state === 1)
+ {
+ var running_html = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
+ element.innerHTML = running_html;
+ }
+ else
+ {
+ element.innerHTML = '';
+ }
+ }
-<%+cbi/valueheader%>
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ var btn1 = document.getElementById("btn1");
+ var btn2 = document.getElementById("btn2");
+ btn1.value = "Suspend";
+ btn2.value = "Refresh";
+ btn1.disabled = true;
+ btn2.disabled = false;
+ return;
+ }
+ status_update(json_info)
+ });
-<input name="runtime" id="runtime" type="text" class="cbi-input-text" style="outline:none;border:none;box-shadow:none;background:transparent;color:#0069d6;font-weight:bold;line-height:30px;height:30px;width:20em;" value="<%=self:cfgvalue(section)%>" disabled="disabled" />
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "adblock", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ return;
+ }
+ status_update(json_info)
+ });
+//]]>
+</script>
-<%+cbi/valuefooter%>
+<h3>Runtime Information</h3>
+<div class="cbi-value" id="status_1">
+ <label class="cbi-value-title" for="status_1">Adblock Status</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_1">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_2">
+ <label class="cbi-value-title" for="status_2">Adblock Version</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_2">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_3">
+ <label class="cbi-value-title" for="status_3">Download Utility (SSL Library)</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_3">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_4">
+ <label class="cbi-value-title" for="status_4">DNS Backend (DNS Directory)</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_4">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_5">
+ <label class="cbi-value-title" for="status_5">Overall Domains</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_5">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_6">
+ <label class="cbi-value-title" for="status_6">Last Run</label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_6">-</span>
+ </div>
+</div>
+<hr />
+<div class="cbi-value" id="button_1">
+ <label class="cbi-value-title" for="button_1">Suspend / Resume Adblock</label>
+ <div class="cbi-value-field">
+ <input class="cbi-button cbi-button-reset" id="btn1" type="button" value="" onclick="btn_action(this)" />
+ <span id="btn1_running" style="display:inline-block; width:16px; height:16px; margin:0 5px"></span>
+ </div>
+</div>
+<p />
+<div class="cbi-value" id="button_2">
+ <label class="cbi-value-title" for="button_2">Refresh Blocklist Sources</label>
+ <div class="cbi-value-field">
+ <input class="cbi-button cbi-button-apply" id="btn2" type="button" value="" onclick="btn_action(this)" />
+ <span id="btn2_running" style="display:inline-block; width:16px; height:16px; margin:0 5px"></span>
+ </div>
+</div>