X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FPing.vue;h=e693af4cc210eb66ca530a1f9f2fa502bd3a0e1d;hb=fd1871508559eb44a8ef32b03b637d8565e19b6a;hp=a9114a826d70dcb1821604fe18dc53a209ae192e;hpb=ded5228972356f2161152df097421c9f46c0a6e9;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/Ping.vue b/src/components/services/Ping.vue index a9114a8..e693af4 100644 --- a/src/components/services/Ping.vue +++ b/src/components/services/Ping.vue @@ -22,8 +22,8 @@

-
- {{ api.status }} +
+ {{ status }}
@@ -42,9 +42,7 @@ export default { item: Object, }, data: () => ({ - api: { - status: "", - }, + status: null, }), created() { this.fetchStatus(); @@ -52,9 +50,20 @@ export default { methods: { fetchStatus: async function () { const url = `${this.item.url}`; - this.api.status = await fetch(url) - .then((response) => "enabled") - .catch((e) => "disabled"); + fetch(url, { + method: "HEAD", + cache: "no-cache", + credentials: "include", + }) + .then((response) => { + if (!response.ok) { + throw Error(response.statusText); + } + this.status = "online"; + }) + .catch(() => { + this.status = "offline"; + }); }, }, }; @@ -68,16 +77,16 @@ export default { font-size: 0.8rem; color: var(--text-title); - &.enabled:before { + &.online:before { background-color: #94e185; border-color: #78d965; - box-shadow: 0 0 4px 1px #94e185; + box-shadow: 0 0 5px 1px #94e185; } - &.disabled:before { + &.offline:before { background-color: #c9404d; border-color: #c42c3b; - box-shadow: 0 0 4px 1px #c9404d; + box-shadow: 0 0 5px 1px #c9404d; } &:before {