-
-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement PiHole API token #580
Conversation
✅ Deploy Preview for homer-demo-content ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
src/components/services/PiHole.vue
Outdated
@@ -49,7 +52,8 @@ export default { | |||
}, | |||
methods: { | |||
fetchStatus: async function () { | |||
const result = await this.fetch("/api.php").catch((e) => console.log(e)); | |||
const result = await this.fetch("/api.php${this.apiQuery}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might require backticks for ${this.apiQuery}
, since is a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should be:
const result = await this.fetch(`/api.php${this.apiQuery()}`)
src/components/services/PiHole.vue
Outdated
@@ -37,6 +37,9 @@ export default { | |||
ads_percentage_today: 0, | |||
}), | |||
computed: { | |||
apiQuery() { | |||
return this.item.apikey ? "?summaryRaw&auth=${this.item.apikey}" : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this needs to be:
return this.item.apikey ? `?summaryRaw&auth=${this.item.apikey}` : "";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tibbe I was looking at other files and @bastienwirtz is usually adding backticks to the function call, something like:
const result = await this.fetch(`/api.php${this.apiQuery()}`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you need the backticks every time you do variable interpolation (i.e. every time you mention ${..}
). which happens on this line. Perhaps it's possible to delay the interpolation but that seems error prone (e.g. the interpolated expression might not be in scope at the later point).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tibbe thank you for the info, not experienced with the language, Python head here. :) Basically, I should add the backticks in both locations, right? If yes, I'll push the changes now, let me know please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I believe they need to be in both places and contain the entire string (like I did I my examples).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tibbe, I pushed the change. Feel free to resolve the conversation. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw your open issue and this PR. Thanks @fmunteanu !
Looks good, a few little thing and we should be good to go.
Thanks for the adjustment @fmunteanu I will test it asap. |
Thanks again @fmunteanu 👍 |
Description
When PiHole web interface is password protected, a query string containing an API token is required for validation.
Fixes #579
Type of change
Checklist:
config.yml
file