mirror of
https://github.com/bastienwirtz/homer.git
synced 2025-06-21 10:18:13 +02:00
Merge pull request #169 from bramceulemans/extended-pihole-component
Added extended PiHole statistics
This commit is contained in:
commit
16a86df3e4
@ -109,7 +109,7 @@ services:
|
|||||||
items:
|
items:
|
||||||
- name: "Pi-hole"
|
- name: "Pi-hole"
|
||||||
logo: "assets/tools/sample.png"
|
logo: "assets/tools/sample.png"
|
||||||
subtitle: "Network-wide Ad Blocking"
|
# subtitle: "Network-wide Ad Blocking" # optional, if no subtitle is defined, PiHole statistics will be shown
|
||||||
tag: "other"
|
tag: "other"
|
||||||
url: "http://192.168.0.151/admin"
|
url: "http://192.168.0.151/admin"
|
||||||
type: "PiHole" # optional, loads a specific component that provides extra features. MUST MATCH a file name (without file extension) available in `src/components/services`
|
type: "PiHole" # optional, loads a specific component that provides extra features. MUST MATCH a file name (without file extension) available in `src/components/services`
|
||||||
|
@ -11,15 +11,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="item.icon" class="media-left">
|
<div v-if="item.icon" class="media-left">
|
||||||
<figure class="image is-48x48">
|
<figure class="image is-48x48">
|
||||||
<i style="font-size: 35px;" :class="['fa-fw', item.icon]"></i>
|
<i style="font-size: 35px" :class="['fa-fw', item.icon]"></i>
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
<p class="title is-4">{{ item.name }}</p>
|
<p class="title is-4">{{ item.name }}</p>
|
||||||
<p class="subtitle is-6">{{ item.subtitle }}</p>
|
<p class="subtitle is-6">
|
||||||
|
<template v-if="item.subtitle">
|
||||||
|
{{ item.subtitle }}
|
||||||
|
</template>
|
||||||
|
<template v-else-if="api">
|
||||||
|
{{ percentage }}% blocked
|
||||||
|
</template>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="status" class="status" :class="status.status">
|
<div v-if="api" class="status" :class="api.status">
|
||||||
{{ status.status }}
|
{{ api.status }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag" :class="item.tagstyle" v-if="item.tag">
|
<div class="tag" :class="item.tagstyle" v-if="item.tag">
|
||||||
@ -37,19 +44,29 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
item: Object,
|
item: Object,
|
||||||
},
|
},
|
||||||
data: () => {
|
data: () => ({
|
||||||
return {
|
api: {
|
||||||
status: null,
|
status: "",
|
||||||
};
|
ads_percentage_today: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
percentage: function () {
|
||||||
|
if (this.api) {
|
||||||
|
return this.api.ads_percentage_today.toFixed(1);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created: function () {
|
created() {
|
||||||
this.fetchStatus();
|
this.fetchStatus();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
this.status = await fetch(`${this.item.url}/api.php`).then((response) =>
|
const url = `${this.item.url}/api.php`;
|
||||||
response.json()
|
this.api = await fetch(url)
|
||||||
);
|
.then((response) => response.json())
|
||||||
|
.catch((e) => console.log(e));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -66,13 +83,13 @@ export default {
|
|||||||
&.enabled:before {
|
&.enabled:before {
|
||||||
background-color: #94e185;
|
background-color: #94e185;
|
||||||
border-color: #78d965;
|
border-color: #78d965;
|
||||||
box-shadow: 0px 0px 4px 1px #94e185;
|
box-shadow: 0 0 4px 1px #94e185;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.disabled:before {
|
&.disabled:before {
|
||||||
background-color: #c9404d;
|
background-color: #c9404d;
|
||||||
border-color: #c42c3b;
|
border-color: #c42c3b;
|
||||||
box-shadow: 0px 0px 4px 1px #c9404d;
|
box-shadow: 0 0 4px 1px #c9404d;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user