diff --git a/docs/customservices.md b/docs/customservices.md index 7ddaaaa..09809f2 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -448,8 +448,11 @@ 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 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. +### New features: +Displays the Portainer version from /api/status +Shows online/offline status depending on API reachability -See +See ```yaml - name: "Portainer" diff --git a/src/components/services/Portainer.vue b/src/components/services/Portainer.vue index f7c8634..603d1b9 100644 --- a/src/components/services/Portainer.vue +++ b/src/components/services/Portainer.vue @@ -1,5 +1,16 @@ @@ -32,6 +42,8 @@ export default { data: () => ({ endpoints: null, containers: null, + fetchOk: null, + versionstring: null, }), computed: { running: function () { @@ -61,9 +73,13 @@ export default { ); }).length; }, + status: function () { + return this.fetchOk ? "online" : "offline"; + }, }, created() { this.fetchStatus(); + this.fetchVersion(); }, methods: { fetchStatus: async function () { @@ -99,11 +115,54 @@ export default { 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); + }); + }, }, };