diff --git a/api_db.php b/api_db.php index e5340ff3e..ed84bc03c 100644 --- a/api_db.php +++ b/api_db.php @@ -384,7 +384,10 @@ function parseDBData($results, $interval, $from, $until) { if (isset($_GET['status'])) { - $results = $db->query('SELECT COUNT(*) FROM message;'); + $extra = ";"; + if(isset($_GET["ignore"]) && $_GET["ignore"] === 'DNSMASQ_WARN') + $extra = "WHERE type != 'DNSMASQ_WARN';"; + $results = $db->query('SELECT COUNT(*) FROM message '.$extra); if(!is_bool($results)) $result = array('message_count' => $results->fetchArray()[0]); diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 5e3866229..b88862a9d 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -102,18 +102,24 @@ function piholeChange(action, duration) { } function checkMessages() { - $.getJSON("api_db.php?status", function (data) { - if ("message_count" in data && data.message_count > 0) { - var title = - data.message_count > 1 - ? "There are " + data.message_count + " warnings. Click for further details." - : "There is one warning. Click for further details."; - - $("#pihole-diagnosis").prop("title", title); - $("#pihole-diagnosis-count").text(data.message_count); - $("#pihole-diagnosis").removeClass("hidden"); + var ignoreNonfatal = localStorage + ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") + : false; + $.getJSON( + "api_db.php?status" + (ignoreNonfatal === "true" ? "&ignore=DNSMASQ_WARN" : ""), + function (data) { + if ("message_count" in data && data.message_count > 0) { + var title = + data.message_count > 1 + ? "There are " + data.message_count + " warnings. Click for further details." + : "There is one warning. Click for further details."; + + $("#pihole-diagnosis").prop("title", title); + $("#pihole-diagnosis-count").text(data.message_count); + $("#pihole-diagnosis").removeClass("hidden"); + } } - }); + ); } function testCookies() { diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 274d6adcd..e89bf860e 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -5,7 +5,7 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ -/* global utils:false */ +/* global utils:false, checkMessages:false */ var token = $("#token").text(); $(function () { @@ -446,3 +446,26 @@ $('button[id="removedynamic"]').on("click", function () { }, }); }); + +// Non-fatal dnsmasq warnings toggle +$(function () { + var nonfatalwarnigns = $("#hideNonfatalDnsmasqWarnings"); + var chkboxData = localStorage ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") : null; + + if (chkboxData !== null) { + // Restore checkbox state + nonfatalwarnigns.prop("checked", chkboxData === "true"); + } else { + // Initialize checkbox + nonfatalwarnigns.prop("checked", false); + if (localStorage) { + localStorage.setItem("hideNonfatalDnsmasqWarnings_chkbox", false); + } + } + + nonfatalwarnigns.click(function () { + localStorage.setItem("hideNonfatalDnsmasqWarnings_chkbox", nonfatalwarnigns.prop("checked")); + // Call check messages to make new setting effective + checkMessages(); + }); +}); diff --git a/settings.php b/settings.php index e59b13523..2772372c8 100644 --- a/settings.php +++ b/settings.php @@ -1131,7 +1131,7 @@ function convertseconds($argument)