]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Implement PiHole API token (#580) v23.02.2
authorFloren Munteanu <fmunteanu@users.noreply.github.com>
Sun, 19 Feb 2023 20:18:56 +0000 (15:18 -0500)
committerGitHub <noreply@github.com>
Sun, 19 Feb 2023 20:18:56 +0000 (12:18 -0800)
Implement PiHole API token

docs/customservices.md
src/components/services/PiHole.vue

index b28f39919582dd60231233ed887b9d2b3a276c8f..31d302ba1d34d6a88b801bf8066a5f54a7076a07 100644 (file)
@@ -58,9 +58,13 @@ The following configuration is available for the PiHole service.
   logo: "assets/tools/sample.png"
   # subtitle: "Network-wide Ad Blocking" # optional, if no subtitle is defined, PiHole statistics will be shown
   url: "http://192.168.0.151/admin"
+  apikey: "<---insert-api-key-here--->" # optional, needed if web interface is password protected
   type: "PiHole"
 ```
 
+**Remarks:**
+If PiHole web interface is password protected, obtain the `apikey` from Settings > API/Web interface > Show API token.
+
 ## OpenWeatherMap
 
 Using the OpenWeatherMap service you can display weather information about a given location.
index 9aac01670009e5c704ecfe743fe7fe32045c5fbb..237cb12973c6bcd4143356a524033a4a0995fc45 100644 (file)
@@ -49,7 +49,11 @@ export default {
   },
   methods: {
     fetchStatus: async function () {
-      const result = await this.fetch("/api.php").catch((e) => console.log(e));
+      const authQueryParams = this.item.apikey
+        ? `?summaryRaw&auth=${this.item.apikey}`
+        : "";
+      const result = await this.fetch(`/api.php${authQueryParams}`)
+        .catch((e) => console.log(e));
 
       this.status = result.status;
       this.ads_percentage_today = result.ads_percentage_today;