mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-23 13:45:33 +02:00
🛂 Adds auth to AdGuard widgets
This commit is contained in:
parent
b931d4e6cd
commit
f7bba8068a
@ -46,6 +46,13 @@ export default {
|
|||||||
endpoint() {
|
endpoint() {
|
||||||
return `${this.hostname}/control/filtering/status`;
|
return `${this.hostname}/control/filtering/status`;
|
||||||
},
|
},
|
||||||
|
authHeaders() {
|
||||||
|
if (this.options.username && this.options.password) {
|
||||||
|
const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
|
||||||
|
return { Authorization: `Basic ${encoded}` };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -62,7 +69,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to AdGuard endpoint */
|
/* Make GET request to AdGuard endpoint */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
this.makeRequest(this.endpoint).then(this.processData);
|
this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(data) {
|
processData(data) {
|
||||||
|
@ -19,11 +19,18 @@ export default {
|
|||||||
endpoint() {
|
endpoint() {
|
||||||
return `${this.hostname}/control/stats`;
|
return `${this.hostname}/control/stats`;
|
||||||
},
|
},
|
||||||
|
authHeaders() {
|
||||||
|
if (this.options.username && this.options.password) {
|
||||||
|
const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
|
||||||
|
return { Authorization: `Basic ${encoded}` };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to AdGuard endpoint */
|
/* Make GET request to AdGuard endpoint */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
this.makeRequest(this.endpoint).then(this.processData);
|
this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(data) {
|
processData(data) {
|
||||||
|
@ -38,6 +38,13 @@ export default {
|
|||||||
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
|
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
|
||||||
return this.options.hostname;
|
return this.options.hostname;
|
||||||
},
|
},
|
||||||
|
authHeaders() {
|
||||||
|
if (this.options.username && this.options.password) {
|
||||||
|
const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
|
||||||
|
return { Authorization: `Basic ${encoded}` };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
showOnOffStatusOnly() {
|
showOnOffStatusOnly() {
|
||||||
return this.options.showOnOffStatusOnly;
|
return this.options.showOnOffStatusOnly;
|
||||||
},
|
},
|
||||||
@ -63,7 +70,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to AdGuard endpoint */
|
/* Make GET request to AdGuard endpoint */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
this.makeRequest(this.endpoint).then(this.processData);
|
this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(data) {
|
processData(data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user