From 601cf44ca0df9160246dc598f1e96f1269f52be4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 15 Oct 2023 11:43:59 +0200 Subject: [PATCH 1/3] Use color and also add info if a gravity list match is of allow type (antigravity) Signed-off-by: DL6ER --- scripts/pi-hole/js/search.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/pi-hole/js/search.js b/scripts/pi-hole/js/search.js index b27110f6..a88dd030 100644 --- a/scripts/pi-hole/js/search.js +++ b/scripts/pi-hole/js/search.js @@ -48,16 +48,19 @@ function eventsource(partial) { (numDomains > 0 ? ":" : ".") + "

"; for (const domain of res.domains) { + const color = domain.type === "deny" ? "red" : "green"; result += " - " + + "' target='_blank'>" + utils.escapeHtml(domain.domain) + - "
" + + "

" + domain.kind + " " + domain.type + - " domain
added: " + + " domain

added: " + utils.renderTimestamp(domain.date_added, "display") + "
last modified: " + utils.renderTimestamp(domain.date_modified, "display") + @@ -88,7 +91,7 @@ function eventsource(partial) { result += "Found " + numAdlists + - " adlist" + + " list" + (numAdlists !== 1 ? "s" : "") + " " + verb + @@ -99,12 +102,18 @@ function eventsource(partial) { "

"; for (const address of Object.keys(grouped)) { const adlist = grouped[address][0]; + const color = adlist.type === "block" ? "red" : "green"; result += " - " + utils.escapeHtml(address) + - "
added: " + + "
" + + adlist.type + + " list" + + "
added: " + utils.renderTimestamp(adlist.date_added, "display") + "
last modified: " + utils.renderTimestamp(adlist.date_modified, "display") + @@ -122,12 +131,10 @@ function eventsource(partial) { (adlist.comment !== null && adlist.comment.length > 0 ? '
comment: "' + utils.escapeHtml(adlist.comment) + '"' : "
no comment") + - "
"; + "
matching entries:
"; for (const adlists of grouped[address]) { result += - " - " + - utils.escapeHtml(adlists.domain) + - "
"; + " - " + utils.escapeHtml(adlists.domain) + "
"; } result += "
"; From 5dcaa2198dc5e4641fb8b03df36fdcf872461afa Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 15 Oct 2023 11:55:17 +0200 Subject: [PATCH 2/3] Add number of matches and possible hint about missing results due to too small N Signed-off-by: DL6ER --- scripts/pi-hole/js/search.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/search.js b/scripts/pi-hole/js/search.js index a88dd030..cbbedd28 100644 --- a/scripts/pi-hole/js/search.js +++ b/scripts/pi-hole/js/search.js @@ -140,7 +140,41 @@ function eventsource(partial) { result += "
"; } - result += "Search took " + (1000 * data.took).toFixed(1) + " ms"; + result += "Number of results per type:
"; + result += + " - " + + data.search.results.domains.exact + + " exact domain matches
"; + result += + " - " + + data.search.results.domains.regex + + " regex domain matches
"; + result += + " - " + + data.search.results.gravity.allow + + " allowlist (antigravity) matches
"; + result += + " - " + + data.search.results.gravity.block + + " blocklist (gravity) matches
"; + + if ( + data.search.results.gravity.allow > data.search.parameters.N || + data.search.results.gravity.block > data.search.parameters.N || + data.search.results.domains.exact > data.search.parameters.N || + data.search.results.domains.regex > data.search.parameters.N + ) { + result += + "

Note: " + + "The number of results to return per type is limited to " + + data.search.parameters.N + + " entries.
There are " + + data.search.results.total + + " matching entries in total.
Consider " + + "using a more specific search term or increase N.
"; + } + + result += "
Search took " + (1000 * data.took).toFixed(1) + " ms"; ta.append(result); }) From 1802ab78dca1aadb3cdb0520347a851f6ffe30a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sun, 15 Oct 2023 14:07:51 +0200 Subject: [PATCH 3/3] Change descriptons to signal also allowed domains are searched for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/lua/sidebar.lp | 2 +- search.lp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/lua/sidebar.lp b/scripts/pi-hole/lua/sidebar.lp index 7f716635..9d09a02d 100644 --- a/scripts/pi-hole/lua/sidebar.lp +++ b/scripts/pi-hole/lua/sidebar.lp @@ -230,7 +230,7 @@
  • - Search Adlists + Search Lists
  • diff --git a/search.lp b/search.lp index 6377b373..cf89465b 100644 --- a/search.lp +++ b/search.lp @@ -11,7 +11,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r') ?>