Skip to content

add service TruenasScale, view status and version #901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ within Homer:
- [Tautulli](#tautulli)
- [Tdarr](#tdarr)
- [Traefik](#traefik)
- [TrueNas Scale](#truenas-scale)
- [Uptime Kuma](#uptime-kuma)
- [Wallabag](#wallabag)
- [What's Up Docker](#whats-up-docker)
Expand Down Expand Up @@ -640,6 +641,18 @@ This service displays a version string instead of a subtitle. Example configurat
url: http://traefik.example.com
```

## Truenas Scale

This service displays a version string instead of a subtitle. Example configuration:

```yaml
- name: "Truenas"
type: "TruenasScale"
logo: "assets/tools/sample.png"
url: "http://truenas.example.com"
api_token: "your_api_token"
```

## Uptime Kuma

Using the Uptime Kuma service you can display info about your instance uptime right on your Homer dashboard.
Expand Down
97 changes: 97 additions & 0 deletions src/components/services/TruenasScale.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<template>
<Generic :item="item">
<template #content>
<p class="title is-4">{{ item.name }}</p>
<p class="subtitle is-6">
<template v-if="item.subtitle">
{{ item.subtitle }}
</template>
<template v-else-if="versionstring">
<span class="is-hidden-touch">Version {{ versionstring }}</span>
<span class="is-hidden-desktop">Version {{ versionstring.split('-').pop() }}</span>
</template>
</p>
</template>
<template #indicator>
<div v-if="status" class="status" :class="status">
{{ status }}
</div>
</template>
</Generic>
</template>

<script>
import service from "@/mixins/service.js";
import Generic from "./Generic.vue";

export default {
name: "TruenasScale",
components: {
Generic,
},
mixins: [service],
props: {
item: Object,
},
data: () => ({
fetchOk: null,
versionstring: null,
}),
computed: {
status: function () {
return this.fetchOk ? "online" : "offline";
},
},
created() {
this.fetchStatus();
},
methods: {
fetchStatus: async function () {
let headers = {};
if (this.item.api_token) {
headers["Authorization"] = `Bearer ${this.item.api_token}`;
}
this.fetch("/api/v2.0/system/version", { headers })
.then((response) => {
this.fetchOk = true;
this.versionstring = response;
})
.catch((e) => {
this.fetchOk = false;
console.log(e);
});
},
},
};
</script>

<style scoped lang="scss">
.status {
font-size: 0.8rem;
color: var(--text-title);
white-space: nowrap;
margin-left: 0.25rem;

&.online:before {
background-color: #94e185;
border-color: #78d965;
box-shadow: 0 0 5px 1px #94e185;
}

&.offline:before {
background-color: #c9404d;
border-color: #c42c3b;
box-shadow: 0 0 5px 1px #c9404d;
}

&:before {
content: " ";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 10px;
border: 1px solid #000;
border-radius: 7px;
}
}
</style>