From ac7f3805d47cf9d5b4d1b28495226034b50b1e8b Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 28 Dec 2024 14:17:48 +0000 Subject: [PATCH] Add custom unmarshalling for pihole queries stats + hide-graph and hide-top-domains options for DNS stats widget --- docs/configuration.md | 8 ++++ internal/glance/templates/dns-stats.html | 7 +++- internal/glance/widget-dns-stats.go | 53 ++++++++++++++++++------ 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 1224ba7..c818e52 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1358,6 +1358,8 @@ Preview: | username | string | when service is `adguard` | | | password | string | when service is `adguard` | | | token | string | when service is `pihole` | | +| hide-graph | bool | no | false | +| hide-top-domains | bool | no | false | | hour-format | string | no | 12h | ##### `service` @@ -1378,6 +1380,12 @@ Only required when using AdGuard Home. The password used to log into the admin d ##### `token` Only required when using Pi-hole. The API token which can be found in `Settings -> API -> Show API token`. Can be specified from an environment variable using the syntax `${VARIABLE_NAME}`. +##### `hide-graph` +Whether to hide the graph showing the number of queries over time. + +##### `hide-top-domains` +Whether to hide the list of top blocked domains. + ##### `hour-format` Whether to display the relative time in the graph in `12h` or `24h` format. diff --git a/internal/glance/templates/dns-stats.html b/internal/glance/templates/dns-stats.html index 8447ce1..7938038 100644 --- a/internal/glance/templates/dns-stats.html +++ b/internal/glance/templates/dns-stats.html @@ -24,6 +24,8 @@ {{ end }} + {{ $showGraph := not (or .HideGraph (eq (len .Stats.Series) 0)) }} + {{ if $showGraph }}
@@ -67,9 +69,10 @@ {{ end }}
+ {{ end }} - {{ if .Stats.TopBlockedDomains }} -
+ {{ if and (not .HideTopDomains) .Stats.TopBlockedDomains }} +
Top blocked domains