mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
Hide top tables if no data is available
Signed-off-by: yubiuser <github@yubiuser.dev>
This commit is contained in:
@@ -277,18 +277,21 @@ function updateForwardDestinationsPie() {
|
||||
function updateTopClientsTable(blocked) {
|
||||
let api;
|
||||
let style;
|
||||
let table;
|
||||
let tablecontent;
|
||||
let overlay;
|
||||
let clienttable;
|
||||
if (blocked) {
|
||||
api = document.body.dataset.apiurl + "/stats/top_clients?blocked=true";
|
||||
style = "queries-blocked";
|
||||
table = $("#client-frequency-blocked");
|
||||
tablecontent = $("#client-frequency-blocked td").parent();
|
||||
overlay = $("#client-frequency-blocked .overlay");
|
||||
clienttable = $("#client-frequency-blocked").find("tbody:last");
|
||||
} else {
|
||||
api = document.body.dataset.apiurl + "/stats/top_clients";
|
||||
style = "queries-permitted";
|
||||
table = $("#client-frequency");
|
||||
tablecontent = $("#client-frequency td").parent();
|
||||
overlay = $("#client-frequency .overlay");
|
||||
clienttable = $("#client-frequency").find("tbody:last");
|
||||
@@ -301,10 +304,10 @@ function updateTopClientsTable(blocked) {
|
||||
let percentage;
|
||||
const sum = blocked ? data.blocked_queries : data.total_queries;
|
||||
|
||||
// Add note if there are no results (e.g. privacy mode enabled)
|
||||
// Remove table if there are no results (e.g. new
|
||||
// installation or privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.clients)) {
|
||||
clienttable.append('<tr><td colspan="3"><center>- No data -</center></td></tr>');
|
||||
overlay.hide();
|
||||
table.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -342,18 +345,21 @@ function updateTopClientsTable(blocked) {
|
||||
function updateTopDomainsTable(blocked) {
|
||||
let api;
|
||||
let style;
|
||||
let table
|
||||
let tablecontent;
|
||||
let overlay;
|
||||
let domaintable;
|
||||
if (blocked) {
|
||||
api = document.body.dataset.apiurl + "/stats/top_domains?blocked=true";
|
||||
style = "queries-blocked";
|
||||
table = $("#ad-frequency");
|
||||
tablecontent = $("#ad-frequency td").parent();
|
||||
overlay = $("#ad-frequency .overlay");
|
||||
domaintable = $("#ad-frequency").find("tbody:last");
|
||||
} else {
|
||||
api = document.body.dataset.apiurl + "/stats/top_domains";
|
||||
style = "queries-permitted";
|
||||
table = $("#domain-frequency");
|
||||
tablecontent = $("#domain-frequency td").parent();
|
||||
overlay = $("#domain-frequency .overlay");
|
||||
domaintable = $("#domain-frequency").find("tbody:last");
|
||||
@@ -368,10 +374,10 @@ function updateTopDomainsTable(blocked) {
|
||||
let urlText;
|
||||
const sum = blocked ? data.blocked_queries : data.total_queries;
|
||||
|
||||
// Add note if there are no results (e.g. privacy mode enabled)
|
||||
// Remove table if there are no results (e.g. new
|
||||
// installation or privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.domains)) {
|
||||
domaintable.append('<tr><td colspan="3"><center>- No data -</center></td></tr>');
|
||||
overlay.hide();
|
||||
table.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user