mirror of https://github.com/bastienwirtz/homer
improved status texts
parent
65f79d8e5c
commit
9a30f52a27
|
@ -6,13 +6,15 @@
|
||||||
<template v-if="item.subtitle">
|
<template v-if="item.subtitle">
|
||||||
{{ item.subtitle }}
|
{{ item.subtitle }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="status">
|
<template v-else-if="statusMessage.up !== false">
|
||||||
{{ statusMessage }}
|
<i class="fa-solid fa-signal mr-1"></i> {{ statusMessage.up }}
|
||||||
|
<span class="separator mx-1"> | </span>
|
||||||
|
<i class="fa-solid fa-stopwatch mr-1"></i> {{ statusMessage.avgRes }}
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
<template #indicator>
|
<template #indicator>
|
||||||
<div v-if="status" class="status" :class="status">
|
<div v-if="status !== false" class="status" :class="status">
|
||||||
{{ percentageGood }}%
|
{{ percentageGood }}%
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -32,6 +34,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
up: 0,
|
up: 0,
|
||||||
down: 0,
|
down: 0,
|
||||||
|
avgRespTime: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -39,24 +42,21 @@ export default {
|
||||||
return this.up + this.down;
|
return this.up + this.down;
|
||||||
},
|
},
|
||||||
percentageGood: function () {
|
percentageGood: function () {
|
||||||
if (this.up == 0) {
|
if (this.up == 0) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return Math.round((this.up / this.total) * 100);
|
return Math.round((this.up / this.total) * 100);
|
||||||
},
|
},
|
||||||
status: function () {
|
status: function () {
|
||||||
if (this.up == 0 && this.down == 0) {
|
if (this.up == 0 && this.down == 0) return false;
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (this.down == this.total) return "bad";
|
if (this.down == this.total) return "bad";
|
||||||
if (this.up == this.total) return "good";
|
if (this.up == this.total) return "good";
|
||||||
return "warn";
|
return "warn";
|
||||||
},
|
},
|
||||||
statusMessage: function () {
|
statusMessage: function () {
|
||||||
if (this.up == 0 && this.down == 0) {
|
if (this.up == 0 && this.down == 0) return false;
|
||||||
return "";
|
return {
|
||||||
}
|
up: `${this.up}/${this.total} up`,
|
||||||
return `${this.up}/${this.total} endpoints are up`;
|
avgRes: `${Math.round(this.avgRespTime * 100) / 100} ms avg.`,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -74,6 +74,9 @@ export default {
|
||||||
endpoints[i].results[endpoints[i].results.length - 1];
|
endpoints[i].results[endpoints[i].results.length - 1];
|
||||||
if (latestResult.success) {
|
if (latestResult.success) {
|
||||||
this.up++;
|
this.up++;
|
||||||
|
const duration = latestResult.duration / 1000000; // convert to ms
|
||||||
|
console.log(`${endpoints[i].name}: ${duration}ms`);
|
||||||
|
this.avgRespTime = (this.avgRespTime + duration) / this.up;
|
||||||
} else {
|
} else {
|
||||||
this.down++;
|
this.down++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue