From c5ab81248a4552f4248ca53fb674190fb3c7aa92 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 25 Dec 2023 05:31:56 +0100 Subject: [PATCH 1/4] Query Log: Show link to groups/lists page if applicable Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 77ceb4aa..7cf27043 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -278,15 +278,22 @@ function formatInfo(data) { var regexInfo = "", cnameInfo = ""; - if (data.regex_id !== null && data.regex_id > -1) { - var regexLink = - 'entry with ID ' + - data.regex_id + + if (data.list_id !== null && data.list_id !== -1) { + // Undo the negation of the list ID if this is an anti-/gravity match + const gravityMatch = data.list_id < -1; + const listID = gravityMatch ? -2 - data.list_id : data.list_id; + + var listLink = + '' + + (gravityMatch ? "list" : "domain") + + " ID " + + listID + ""; regexInfo = - divStart + "Query was " + queryStatus.matchText + " by " + regexLink + ""; + divStart + "Query was " + queryStatus.matchText + " by " + listLink + ""; } if (queryStatus.isCNAME) { From ab42f54367191de125bd3c5883943d3d7224a5fb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Feb 2024 17:55:19 +0100 Subject: [PATCH 2/4] Show link to search page instead of to the list ID returned by the API. This is a better strategy in case a user has a certain domain on multiple lists. We intentionally don't submit on the search page to let the user decide if they want exact or partial matching Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 23 ++++++++--------------- scripts/pi-hole/js/search.js | 11 +++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 7cf27043..339b7d5b 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -276,24 +276,17 @@ function formatInfo(data) { ""; } - var regexInfo = "", + var listInfo = "", cnameInfo = ""; if (data.list_id !== null && data.list_id !== -1) { - // Undo the negation of the list ID if this is an anti-/gravity match - const gravityMatch = data.list_id < -1; - const listID = gravityMatch ? -2 - data.list_id : data.list_id; + // Some list matched - add link to search page var listLink = - '' + - (gravityMatch ? "list" : "domain") + - " ID " + - listID + - ""; - regexInfo = - divStart + "Query was " + queryStatus.matchText + " by " + listLink + ""; + 'search lists'; + listInfo = + divStart + 'Query was ' + queryStatus.matchText + ', ' + listLink + ""; } if (queryStatus.isCNAME) { @@ -356,7 +349,7 @@ function formatInfo(data) { dnssecInfo + statusInfo + cnameInfo + - regexInfo + + listInfo + ttlInfo + replyInfo + dbInfo + diff --git a/scripts/pi-hole/js/search.js b/scripts/pi-hole/js/search.js index 26875241..3e2eca7a 100644 --- a/scripts/pi-hole/js/search.js +++ b/scripts/pi-hole/js/search.js @@ -6,6 +6,17 @@ * Please see LICENSE file for your rights under this license. */ /* global utils:false, apiFailure:false */ +var GETDict = {}; + +$(function () { + GETDict = utils.parseQueryString(); + if (GETDict.domain !== undefined) { + $("input[id^='domain']").val(GETDict.domain); + } + if (GETDict.N !== undefined) { + $("#number").val(GETDict.number); + } +}); function eventsource(partial) { const ta = $("#output"); From 5f79611e96a809f50520aa8c31cc1340e38f24d0 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Feb 2024 17:56:32 +0100 Subject: [PATCH 3/4] Fix search output unintentionally broken in 7d2e83cbc42f1e63d5c5b00ebd2835b640f2895a Signed-off-by: DL6ER --- style/pi-hole.css | 5 ++++- taillog.lp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/style/pi-hole.css b/style/pi-hole.css index c60ed9bc..4be5c580 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -1075,12 +1075,15 @@ table.dataTable tbody > tr > .selected { #output { position: relative; - display: grid; margin: 5px 0; min-height: 36px; padding: 4px 8px; } +#output.pre-taillog { + display: grid; +} + .loading::before { content: " "; position: absolute; diff --git a/taillog.lp b/taillog.lp index 0514ccc6..4d0aa487 100644 --- a/taillog.lp +++ b/taillog.lp @@ -25,7 +25,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
-

+                        

                     
From a0ddfe69a2b2d8d1b613d0da05eaae445ab3ed48 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Feb 2024 18:01:03 +0100 Subject: [PATCH 4/4] Format changes Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 3 +-- scripts/pi-hole/js/search.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 339b7d5b..84da33e6 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -285,8 +285,7 @@ function formatInfo(data) { 'search lists'; - listInfo = - divStart + 'Query was ' + queryStatus.matchText + ', ' + listLink + ""; + listInfo = divStart + "Query was " + queryStatus.matchText + ", " + listLink + ""; } if (queryStatus.isCNAME) { diff --git a/scripts/pi-hole/js/search.js b/scripts/pi-hole/js/search.js index 3e2eca7a..dae432ec 100644 --- a/scripts/pi-hole/js/search.js +++ b/scripts/pi-hole/js/search.js @@ -13,6 +13,7 @@ $(function () { if (GETDict.domain !== undefined) { $("input[id^='domain']").val(GETDict.domain); } + if (GETDict.N !== undefined) { $("#number").val(GETDict.number); }