mirror of https://github.com/bastienwirtz/homer
add status online/offline and version of the card
parent
234e063d2e
commit
b11bee7d64
|
@ -448,6 +448,9 @@ This service displays info about the total number of containers managed by your
|
||||||
In order to use it, you must be using Portainer version 1.11 or later. Generate an access token from the UI and pass
|
In order to use it, you must be using Portainer version 1.11 or later. Generate an access token from the UI and pass
|
||||||
it to the apikey field.
|
it to the apikey field.
|
||||||
By default, every connected environments will be checked. To select specific ones, add an "environments" entry which can be a simple string or an array containing all the selected environments name.
|
By default, every connected environments will be checked. To select specific ones, add an "environments" entry which can be a simple string or an array containing all the selected environments name.
|
||||||
|
### New features:
|
||||||
|
Displays the Portainer version from /api/status
|
||||||
|
Shows online/offline status depending on API reachability
|
||||||
|
|
||||||
See <https://docs.portainer.io/api/access#creating-an-access-token>
|
See <https://docs.portainer.io/api/access#creating-an-access-token>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<Generic :item="item">
|
<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">
|
||||||
|
Version {{ versionstring }}
|
||||||
|
</template>
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
<template #indicator>
|
<template #indicator>
|
||||||
<div class="notifs">
|
<div class="notifs">
|
||||||
<strong v-if="running > 0" class="notif running" title="Running">
|
<strong v-if="running > 0" class="notif running" title="Running">
|
||||||
|
@ -8,14 +19,13 @@
|
||||||
<strong v-if="dead > 0" class="notif dead" title="Dead">
|
<strong v-if="dead > 0" class="notif dead" title="Dead">
|
||||||
{{ dead }}
|
{{ dead }}
|
||||||
</strong>
|
</strong>
|
||||||
<strong
|
<strong v-if="misc > 0" class="notif misc" title="Other (creating, paused, exited, etc.)">
|
||||||
v-if="misc > 0"
|
|
||||||
class="notif misc"
|
|
||||||
title="Other (creating, paused, exited, etc.)"
|
|
||||||
>
|
|
||||||
{{ misc }}
|
{{ misc }}
|
||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="status" class="status" :class="status">
|
||||||
|
{{ status }}
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Generic>
|
</Generic>
|
||||||
</template>
|
</template>
|
||||||
|
@ -32,6 +42,8 @@ export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
endpoints: null,
|
endpoints: null,
|
||||||
containers: null,
|
containers: null,
|
||||||
|
fetchOk: null,
|
||||||
|
versionstring: null,
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
running: function () {
|
running: function () {
|
||||||
|
@ -61,9 +73,13 @@ export default {
|
||||||
);
|
);
|
||||||
}).length;
|
}).length;
|
||||||
},
|
},
|
||||||
|
status: function () {
|
||||||
|
return this.fetchOk ? "online" : "offline";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.fetchStatus();
|
this.fetchStatus();
|
||||||
|
this.fetchVersion();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
|
@ -99,11 +115,54 @@ export default {
|
||||||
|
|
||||||
this.containers = containers;
|
this.containers = containers;
|
||||||
},
|
},
|
||||||
|
fetchVersion: async function () {
|
||||||
|
const headers = {
|
||||||
|
"X-Api-Key": this.item.apikey,
|
||||||
|
};
|
||||||
|
this.fetch("/api/status", { headers })
|
||||||
|
.then((response) => {
|
||||||
|
this.fetchOk = true;
|
||||||
|
this.versionstring = response.Version;
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
this.fetchOk = false;
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.notifs {
|
.notifs {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
Loading…
Reference in New Issue