X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FPiHole.vue;h=a9fd369c2a87ba30bc048f352aeab276f4dac187;hb=cc7ff885527283d97f32347210b0370e8477c4ff;hp=c08e1fab44788b44ce8e35c18e8798d05992029f;hpb=9a14de007e7c8d04ce708f8df1300ac8070d85df;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue index c08e1fa..a9fd369 100644 --- a/src/components/services/PiHole.vue +++ b/src/components/services/PiHole.vue @@ -11,15 +11,22 @@
- +

{{ item.name }}

-

{{ item.subtitle }}

+

+ + +

-
- {{ status.status }} +
+ {{ api.status }}
@@ -37,19 +44,29 @@ export default { props: { item: Object, }, - data: () => { - return { - status: null, - }; + data: () => ({ + api: { + 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(); }, methods: { fetchStatus: async function () { - this.status = await fetch(`${this.item.url}/api.php`).then((response) => - response.json() - ); + const url = `${this.item.url}/api.php`; + this.api = await fetch(url) + .then((response) => response.json()) + .catch((e) => console.log(e)); }, }, }; @@ -66,13 +83,13 @@ export default { &.enabled:before { background-color: #94e185; border-color: #78d965; - box-shadow: 0px 0px 4px 1px #94e185; + box-shadow: 0 0 4px 1px #94e185; } &.disabled:before { background-color: #c9404d; border-color: #c42c3b; - box-shadow: 0px 0px 4px 1px #c9404d; + box-shadow: 0 0 4px 1px #c9404d; } &:before {