Skip to content

Commit

Permalink
Implement PiHole API token (#580)
Browse files Browse the repository at this point in the history
Implement PiHole API token
  • Loading branch information
fmunteanu authored Feb 19, 2023
1 parent dfde8ea commit d362add
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/components/services/PiHole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d362add

Please sign in to comment.