diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js
index 390c19b7..0fd513c4 100644
--- a/scripts/pi-hole/js/index.js
+++ b/scripts/pi-hole/js/index.js
@@ -360,7 +360,6 @@ function updateForwardedOverTime() {
});
}
-
function updateClientsOverTime() {
$.getJSON("api.php?overTimeDataClients&getClientNames", function(data) {
@@ -527,7 +526,7 @@ function escapeHtml(text) {
}
function updateTopClientsChart() {
- $.getJSON("api.php?summaryRaw&getQuerySources", function(data) {
+ $.getJSON("api.php?summaryRaw&getQuerySources&topClientsBlocked", function(data) {
if("FTLnotrunning" in data)
{
@@ -566,17 +565,56 @@ function updateTopClientsChart() {
"
" + data.top_sources[client] + " | | ");
}
+ }
+ // Clear tables before filling them with data
+ $("#client-frequency-blocked td").parent().remove();
+ var clientblockedtable = $("#client-frequency-blocked").find("tbody:last");
+ var client, percentage, clientname, clientip;
+ for (client in data.top_sources_blocked) {
+
+ if ({}.hasOwnProperty.call(data.top_sources_blocked, client)){
+ // Sanitize client
+ if(escapeHtml(client) !== client)
+ {
+ // Make a copy with the escaped index if necessary
+ data.top_sources_blocked[escapeHtml(client)] = data.top_sources_blocked[client];
+ }
+ client = escapeHtml(client);
+ if(client.indexOf("|") > -1)
+ {
+ var idx = client.indexOf("|");
+ clientname = client.substr(0, idx);
+ clientip = client.substr(idx+1, client.length-idx);
+ }
+ else
+ {
+ clientname = client;
+ clientip = client;
+ }
+
+ var url = "
"+clientname+"";
+ percentage = data.top_sources_blocked[client] / data.dns_queries_today * 100;
+ clientblockedtable.append("
| " + url +
+ " | " + data.top_sources_blocked[client] + " | |
");
+ }
}
// Remove table if there are no results (e.g. privacy mode enabled)
if(jQuery.isEmptyObject(data.top_sources))
{
$("#client-frequency").parent().remove();
- return;
+ }
+
+ // Remove table if there are no results (e.g. privacy mode enabled)
+ if(jQuery.isEmptyObject(data.top_sources_blocked))
+ {
+ $("#client-frequency-blocked").parent().remove();
}
$("#client-frequency .overlay").hide();
+ $("#client-frequency-blocked .overlay").hide();
// Update top clients list data every ten seconds
setTimeout(updateTopClientsChart, 10000);
});