Skip to content

Commit 6916c2f

Browse files
thibaut1304bastienwirtz
authored andcommitted
add service TruenasScale, view status and version
1 parent e5bd328 commit 6916c2f

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

docs/customservices.md

+13
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ within Homer:
4949
- [Tautulli](#tautulli)
5050
- [Tdarr](#tdarr)
5151
- [Traefik](#traefik)
52+
- [TrueNas Scale](#truenas-scale)
5253
- [Uptime Kuma](#uptime-kuma)
5354
- [Vaultwarden](#vaultwarden)
5455
- [Wallabag](#wallabag)
@@ -657,6 +658,18 @@ This service displays a version string instead of a subtitle. Example configurat
657658
url: http://traefik.example.com
658659
```
659660

661+
## Truenas Scale
662+
663+
This service displays a version string instead of a subtitle. Example configuration:
664+
665+
```yaml
666+
- name: "Truenas"
667+
type: "TruenasScale"
668+
logo: "assets/tools/sample.png"
669+
url: "http://truenas.example.com"
670+
api_token: "your_api_token"
671+
```
672+
660673
## Uptime Kuma
661674

662675
Using the Uptime Kuma service you can display info about your instance uptime right on your Homer dashboard.
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<template>
2+
<Generic :item="item">
3+
<template #content>
4+
<p class="title is-4">{{ item.name }}</p>
5+
<p class="subtitle is-6">
6+
<template v-if="item.subtitle">
7+
{{ item.subtitle }}
8+
</template>
9+
<template v-else-if="versionstring">
10+
<span class="is-hidden-touch">Version {{ versionstring }}</span>
11+
<span class="is-hidden-desktop">Version {{ versionstring.split('-').pop() }}</span>
12+
</template>
13+
</p>
14+
</template>
15+
<template #indicator>
16+
<div v-if="status" class="status" :class="status">
17+
{{ status }}
18+
</div>
19+
</template>
20+
</Generic>
21+
</template>
22+
23+
<script>
24+
import service from "@/mixins/service.js";
25+
import Generic from "./Generic.vue";
26+
27+
export default {
28+
name: "TruenasScale",
29+
components: {
30+
Generic,
31+
},
32+
mixins: [service],
33+
props: {
34+
item: Object,
35+
},
36+
data: () => ({
37+
fetchOk: null,
38+
versionstring: null,
39+
}),
40+
computed: {
41+
status: function () {
42+
return this.fetchOk ? "online" : "offline";
43+
},
44+
},
45+
created() {
46+
this.fetchStatus();
47+
},
48+
methods: {
49+
fetchStatus: async function () {
50+
let headers = {};
51+
if (this.item.api_token) {
52+
headers["Authorization"] = `Bearer ${this.item.api_token}`;
53+
}
54+
this.fetch("/api/v2.0/system/version", { headers })
55+
.then((response) => {
56+
this.fetchOk = true;
57+
this.versionstring = response;
58+
})
59+
.catch((e) => {
60+
this.fetchOk = false;
61+
console.log(e);
62+
});
63+
},
64+
},
65+
};
66+
</script>
67+
68+
<style scoped lang="scss">
69+
.status {
70+
font-size: 0.8rem;
71+
color: var(--text-title);
72+
white-space: nowrap;
73+
margin-left: 0.25rem;
74+
75+
&.online:before {
76+
background-color: #94e185;
77+
border-color: #78d965;
78+
box-shadow: 0 0 5px 1px #94e185;
79+
}
80+
81+
&.offline:before {
82+
background-color: #c9404d;
83+
border-color: #c42c3b;
84+
box-shadow: 0 0 5px 1px #c9404d;
85+
}
86+
87+
&:before {
88+
content: " ";
89+
display: inline-block;
90+
width: 7px;
91+
height: 7px;
92+
margin-right: 10px;
93+
border: 1px solid #000;
94+
border-radius: 7px;
95+
}
96+
}
97+
</style>

0 commit comments

Comments
 (0)