From 081afa49240ea4b82b2e5aaf857f561c8d4d7c23 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 4 Apr 2018 14:24:59 +0200 Subject: [PATCH] Remove clients over time graph if no data is returned (privacy mode!) Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 17d80492..b942f352 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -294,6 +294,13 @@ function updateClientsOverTime() { // convert received objects to arrays data.over_time = objectToArray(data.over_time); + + // Remove graph if there are no results (e.g. privacy mode enabled) + if(jQuery.isEmptyObject(data.over_time)) + { + $("#clients").parent().remove(); + return; + } // remove last data point since it not representative data.over_time[0].splice(-1,1); var timestamps = data.over_time[0]; @@ -492,6 +499,7 @@ function updateTopClientsChart() { if(jQuery.isEmptyObject(data.top_sources)) { $("#client-frequency").parent().remove(); + return; } $("#client-frequency .overlay").hide(); @@ -535,6 +543,7 @@ function updateTopLists() { if(jQuery.isEmptyObject(data.top_queries)) { $("#domain-frequency").parent().remove(); + return; } for (domain in data.top_ads) { @@ -558,6 +567,7 @@ function updateTopLists() { if(jQuery.isEmptyObject(data.top_ads)) { $("#ad-frequency").parent().remove(); + return; } $("#domain-frequency .overlay").hide();