aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2022-07-12 13:28:07 -0700
committerGitHub <noreply@github.com>2022-07-12 13:28:07 -0700
commit0eca982f8bc89bbac3ed4fee248fc53b7c4c0527 (patch)
tree204cd561549dd6424d7e07c88b042e3bce62d608
parenta46bede230afd80b3fbf562f4d5d7491155e3835 (diff)
parentd57821b5fa8b994bc4082f7565a072090ff288a1 (diff)
downloadhomer-0eca982f8bc89bbac3ed4fee248fc53b7c4c0527.tar.gz
homer-0eca982f8bc89bbac3ed4fee248fc53b7c4c0527.tar.zst
homer-0eca982f8bc89bbac3ed4fee248fc53b7c4c0527.zip
Merge branch 'main' into vuejs-3
-rw-r--r--docs/customservices.md14
-rw-r--r--src/components/services/Healhchecks.vue115
2 files changed, 129 insertions, 0 deletions
diff --git a/docs/customservices.md b/docs/customservices.md
index 6a54400..c9ce093 100644
--- a/docs/customservices.md
+++ b/docs/customservices.md
@@ -20,6 +20,7 @@ within Homer:
20+ [Uptime Kuma](#uptime-kuma) 20+ [Uptime Kuma](#uptime-kuma)
21+ [Tautulli](#tautulli) 21+ [Tautulli](#tautulli)
22+ [Mealie](#mealie) 22+ [Mealie](#mealie)
23+ [Healthchecks](#healthchecks)
23 24
24If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page. 25If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page.
25 26
@@ -229,3 +230,16 @@ endpoint pointing to Tautulli!
229 230
230First off make sure to remove an existing `subtitle` as it will take precedence if set. 231First off make sure to remove an existing `subtitle` as it will take precedence if set.
231Setting `type: "Mealie"` will then show the number of recipes Mealie is keeping organized or the planned meal for today if one is planned. You will have to set an API key in the field `apikey` which can be created in your Mealie installation. 232Setting `type: "Mealie"` will then show the number of recipes Mealie is keeping organized or the planned meal for today if one is planned. You will have to set an API key in the field `apikey` which can be created in your Mealie installation.
233
234## Healthchecks
235
236This service displays information about the configured status checks from the Healthchecks application.
237Two lines are needed in the config.yml :
238
239```yaml
240 type: "Healthchecks"
241 apikey: "01234deb70424befb1f4ef6a23456789"
242```
243
244The url must be the root url of the Healthchecks application.
245The Healthchecks API key can be found in Settings > API Access > API key (read-only). The key is needed to access Healthchecks API.
diff --git a/src/components/services/Healhchecks.vue b/src/components/services/Healhchecks.vue
new file mode 100644
index 0000000..c60f241
--- /dev/null
+++ b/src/components/services/Healhchecks.vue
@@ -0,0 +1,115 @@
1<template>
2 <Generic :item="item">
3 <template #indicator>
4 <div class="notifs">
5 <strong v-if="up > 0" class="notif up" title="Up">
6 {{ up }}
7 </strong>
8 <strong v-if="down > 0" class="notif down" title="Down">
9 {{ down }}
10 </strong>
11 <strong v-if="grace > 0" class="notif grace" title="Grace">
12 {{ grace }}
13 </strong>
14 </div>
15 </template>
16 </Generic>
17</template>
18
19<script>
20import service from "@/mixins/service.js";
21import Generic from "./Generic.vue";
22
23export default {
24 name: "Healthchecks",
25 mixins: [service],
26 props: {
27 item: Object,
28 },
29 components: {
30 Generic,
31 },
32 data: () => ({
33 api: null,
34 }),
35 computed: {
36 up: function () {
37 if (!this.api) {
38 return "";
39 }
40 return this.api.checks?.filter((check) => {
41 return check.status.toLowerCase() === "up";
42 }).length;
43 },
44 down: function () {
45 if (!this.api) {
46 return "";
47 }
48 return this.api.checks?.filter((check) => {
49 return check.status.toLowerCase() === "down";
50 }).length;
51 },
52 grace: function () {
53 if (!this.api) {
54 return "";
55 }
56 return this.api.checks?.filter((check) => {
57 return check.status.toLowerCase() === "grace";
58 }).length;
59 },
60 },
61 created() {
62 this.fetchStatus();
63 },
64 methods: {
65 fetchStatus: async function () {
66 const apikey = this.item.apikey;
67 if (!apikey) {
68 console.error(
69 "apikey is not present in config.yml for the Healthchecks entry!"
70 );
71 return;
72 }
73
74 const headers = {
75 "X-Api-Key": this.item.apikey,
76 };
77
78 this.api = await this.fetch("/api/v1/checks/", { headers }).catch((e) => {
79 console.error(e);
80 });
81 },
82 },
83};
84</script>
85
86<style scoped lang="scss">
87.notifs {
88 position: absolute;
89 color: white;
90 font-family: sans-serif;
91 top: 0.3em;
92 right: 0.5em;
93
94 .notif {
95 display: inline-block;
96 padding: 0.2em 0.35em;
97 border-radius: 0.25em;
98 position: relative;
99 margin-left: 0.3em;
100 font-size: 0.8em;
101
102 &.up {
103 background-color: #4fd671;
104 }
105
106 &.down {
107 background-color: #e51111;
108 }
109
110 &.grace {
111 background-color: #cdd02e;
112 }
113 }
114}
115</style>