summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-adblock/luasrc/view
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-adblock/luasrc/view')
-rw-r--r--applications/luci-app-adblock/luasrc/view/adblock/adblock_css.htm10
-rw-r--r--applications/luci-app-adblock/luasrc/view/adblock/report.htm244
-rw-r--r--applications/luci-app-adblock/luasrc/view/adblock/runtime.htm4
3 files changed, 251 insertions, 7 deletions
diff --git a/applications/luci-app-adblock/luasrc/view/adblock/adblock_css.htm b/applications/luci-app-adblock/luasrc/view/adblock/adblock_css.htm
index e6460122e2..5467c87632 100644
--- a/applications/luci-app-adblock/luasrc/view/adblock/adblock_css.htm
+++ b/applications/luci-app-adblock/luasrc/view/adblock/adblock_css.htm
@@ -1,8 +1,8 @@
<style type="text/css">
textarea
{
- width: 100%;
- height: 450px;
+ width: 100% !important;
+ height: 450px !important;
border: 1px solid #cccccc;
padding: 5px;
font-size: 12px;
@@ -16,8 +16,8 @@
select[readonly],
textarea[readonly]
{
- width: 100%;
- height: 450px;
+ width: 100% !important;
+ height: 450px !important;
border: 1px solid #cccccc;
padding: 5px;
font-size: 12px;
@@ -33,7 +33,7 @@
.cbi-section-table-row,
.tr[data-title]::before
{
- text-align: left;
+ text-align: left !important;
vertical-align: top;
margin-left: 0px;
padding-left: 2px;
diff --git a/applications/luci-app-adblock/luasrc/view/adblock/report.htm b/applications/luci-app-adblock/luasrc/view/adblock/report.htm
new file mode 100644
index 0000000000..a28ca171b6
--- /dev/null
+++ b/applications/luci-app-adblock/luasrc/view/adblock/report.htm
@@ -0,0 +1,244 @@
+<%#
+Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
+This is free software, licensed under the Apache License, Version 2.0
+-%>
+
+<%+header%>
+<%+adblock/adblock_css%>
+
+<script type="text/javascript">
+//<![CDATA[
+ function report_json(json)
+ {
+ document.getElementById("value_1").innerHTML = json.data.start_date + ", " + json.data.start_time || "-";
+ document.getElementById("value_2").innerHTML = json.data.end_date + ", " + json.data.end_time || "-";
+ document.getElementById("value_3").innerHTML = json.data.total || "-";
+ document.getElementById("value_4").innerHTML = json.data.blocked + " (" + json.data.percent + ")" || "-";
+
+ var a_cnt;
+ var b_cnt;
+ var c_cnt;
+ var a_val;
+ var b_val;
+ var c_val;
+ var s = '<div class="tr table-titles">';
+ s += '<div class="th left"><%:Count%></div>';
+ s += '<div class="th left"><%:Name / IP-Address%></div>';
+ s += '<div class="th left"><%:Count%></div>';
+ s += '<div class="th left"><%:Domain%></div>';
+ s += '<div class="th left"><%:Count%></div>';
+ s += '<div class="th left"><%:Blocked Domain%></div></div>';
+
+ for(var i=0;i<10;i++)
+ {
+ if (i < json.top_clients.length)
+ {
+ a_cnt = json.top_clients[i].count;
+ a_val = json.top_clients[i].address;
+ }
+ else
+ {
+ a_cnt = "-";
+ a_val = "";
+ }
+
+ if (i < json.top_domains.length)
+ {
+ b_cnt = json.top_domains[i].count;
+ b_val = json.top_domains[i].address;
+ }
+ else
+ {
+ b_cnt = "-";
+ b_val = "";
+ }
+
+ if (i < json.top_blocked.length)
+ {
+ c_cnt = json.top_blocked[i].count;
+ c_val = json.top_blocked[i].address;
+ }
+ else
+ {
+ c_cnt = "-";
+ c_val = "";
+ }
+
+ s += '<div class="tr left">';
+ s += '<div class="td left" data-title="<%:Count%>">' + a_cnt + '</div>';
+ s += '<div class="td left" data-title="<%:Name / IP-Address%>">' + a_val + '</div>';
+ s += '<div class="td left" data-title="<%:Count%>">' + b_cnt + '</div>';
+ s += '<div class="td left" data-title="<%:Domain%>">' + b_val + '</div>';
+ s += '<div class="td left" data-title="<%:Count%>">' + c_cnt + '</div>';
+ s += '<div class="td left" data-title="<%:Blocked Domain%>">' + c_val + '</div></div>';
+ }
+ document.getElementById("value_5").innerHTML = s;
+ }
+
+ function report_text(text)
+ {
+ var s = '<div class="tr table-titles">';
+ s += '<div class="th left"><%:Date%></div>';
+ s += '<div class="th left"><%:Time%></div>';
+ s += '<div class="th left"><%:Client%></div>';
+ s += '<div class="th left"><%:Domain%></div>';
+ s += '<div class="th left"><%:Answer%></div>';
+ s += '<div class="th left"><%:Action%></div></div>';
+ var btn;
+ var record;
+ var title_arr = ["<%:Date%>", "<%:Time%>", "<%:Client%>", "<%:Domain%>", "<%:Answer%>", "<%:Action%>"];
+ var array = text.split("\n", 50);
+ for (var i=0;i<array.length;i++)
+ {
+ record = array[i].split("\t");
+ if (record[0] && record[0] != "undefined")
+ {
+ s += '<div class="tr left">';
+ for (var j=0;j<5;j++)
+ {
+ s += '<div class="td left" data-title="' + title_arr[j] + '">' + record[j] + '</div>';
+ if (record[4] === "NX")
+ {
+ btn = '<div class="td left" data-title="' + title_arr[5] + '"><input type="button" class="cbi-button cbi-button-edit" name="add_whitelist,' + record[3] + '" value="<%:Whitelist%>" onclick="btn_action(this)" /></div>';
+ }
+ else
+ {
+ btn = '<div class="td left" data-title="' + title_arr[5] + '"><input type="button" class="cbi-button cbi-button-remove" name="add_blacklist,' + record[3] + '" value="<%:Blacklist%>" onclick="btn_action(this)" /></div>';
+ }
+ }
+ s += btn + '</div>'
+ }
+ }
+ document.getElementById("value_6").innerHTML = s;
+ }
+
+ function btn_action(value)
+ {
+ var action = value.name.split(",");
+
+ if (action[0] === "do_report")
+ {
+ var btn = document.getElementById("btn");
+ var btn_running = document.getElementById("btn_running");
+
+ btn.disabled = true;
+ running(btn_running, 1);
+ action[1] = "-"
+ }
+
+ new XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock")%>/action/' + action[0] + "/" + action[1], null,
+ function(x)
+ {
+ if (!x)
+ {
+ return;
+ }
+ if (action[0] === "do_report")
+ {
+ running(btn_running, 0);
+ btn.disabled = false;
+ }
+ });
+ }
+
+ 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 = '';
+ }
+ }
+
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock", "report_json")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info || !json_info.data)
+ {
+ running(btn_running, 0);
+ btn.disabled = false;
+ return;
+ }
+ report_json(json_info);
+ });
+
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "adblock", "report_json")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info || !json_info.data)
+ {
+ running(btn_running, 0);
+ btn.disabled = false;
+ return;
+ }
+ report_json(json_info);
+ });
+
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock", "report_text")%>', null,
+ function(x)
+ {
+ if (!x || !x.responseText)
+ {
+ return;
+ }
+ report_text(x.responseText);
+ });
+
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "adblock", "report_text")%>', null,
+ function(x)
+ {
+ if (!x || !x.responseText)
+ {
+ return;
+ }
+ report_text(x.responseText);
+ });
+//]]>
+</script>
+
+<div class="cbi-section">
+ <div class="cbi-value" id="status_1">
+ <label class="cbi-value-title" for="status_1"><%:Start Date%></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"><%:End Date%></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"><%:Total DNS Queries%></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"><%:Blocked DNS Queries%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_4">-</span>
+ </div>
+ </div>
+ <br />
+ <div id="button">
+ <input type="button" class="cbi-button cbi-button-action important" id="btn" name="do_report" value="<%:Refresh Report%>" onclick="btn_action(this)" />
+ <span id="btn_running" class="btn_running"></span>
+ </div>
+</div>
+<br />
+<div class="cbi-section">
+ <h3><%:Top 10 Reporting%></h3>
+ <div class="table" id="value_5"></div>
+</div>
+<br />
+<div class="cbi-section">
+ <h3><%:Latest DNS Queries%></h3>
+ <div class="table" id="value_6"></div>
+</div>
+<%+footer%>
diff --git a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
index ee20133d5a..0b5c748571 100644
--- a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
+++ b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm
@@ -112,7 +112,7 @@ This is free software, licensed under the Apache License, Version 2.0
document.getElementById("value_6").innerHTML = "-";
}
- XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock", "status")%>', null,
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "adblock", "status_update")%>', null,
function(x, json_info)
{
if (!x || !json_info || !json_info.data)
@@ -123,7 +123,7 @@ This is free software, licensed under the Apache License, Version 2.0
status_update(json_info);
});
- XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "adblock", "status")%>', null,
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "adblock", "status_update")%>', null,
function(x, json_info)
{
if (!x || !json_info || !json_info.data)