From 8511681bdeef59395166f47b18ed369cf28b3b93 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Thu, 24 Oct 2024 19:07:42 -0300 Subject: [PATCH 1/2] Do not show negative gravity count When FTL fails to count the number of domains on the lists, the value -2 is returned, but this value should not be printed (it's just an error code). Signed-off-by: RD WebDesign --- scripts/pi-hole/js/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 28910f3f..6b416450 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -414,9 +414,10 @@ function updateSummaryData(runOnce = false) { $("span#blocked_queries").text(intl.format(parseFloat(data.queries.blocked))); var formattedPercentage = utils.toPercent(data.queries.percent_blocked, 1); $("span#percent_blocked").text(formattedPercentage); - $("span#gravity_size").text(intl.format(parseInt(data.gravity.domains_being_blocked, 10))); updateQueryFrequency(intl, data.queries.frequency); + const gravityCount = parseInt(data.gravity.domains_being_blocked, 10); + $("span#gravity_size").text(intl.format(gravityCount > 0 ? gravityCount : 0)); const lastupdate = parseInt(data.gravity.last_update, 10); var updatetxt = "Lists were never updated"; if (lastupdate > 0) { From 830805772194d48253a94e08f5f186e6b957e1f7 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Sun, 27 Oct 2024 18:41:48 -0300 Subject: [PATCH 2/2] Rearrange the code and use better texts in case of error - show an error message including the error code; - change the title (tooltip) text Signed-off-by: RD WebDesign --- scripts/pi-hole/js/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 6b416450..a68648c0 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -416,8 +416,6 @@ function updateSummaryData(runOnce = false) { $("span#percent_blocked").text(formattedPercentage); updateQueryFrequency(intl, data.queries.frequency); - const gravityCount = parseInt(data.gravity.domains_being_blocked, 10); - $("span#gravity_size").text(intl.format(gravityCount > 0 ? gravityCount : 0)); const lastupdate = parseInt(data.gravity.last_update, 10); var updatetxt = "Lists were never updated"; if (lastupdate > 0) { @@ -429,6 +427,15 @@ function updateSummaryData(runOnce = false) { ")"; } + const gravityCount = parseInt(data.gravity.domains_being_blocked, 10); + if (gravityCount < 0) { + // Error. Change the title text and show the error code in parentheses + updatetxt = "Error! Update gravity to reset this value."; + $("span#gravity_size").text("Error (" + gravityCount + ")"); + } else { + $("span#gravity_size").text(intl.format(gravityCount)); + } + $(".small-box:has(#gravity_size)").attr("title", updatetxt); if (2 * previousCount < newCount && newCount > 100 && !firstSummaryUpdate) {