implement uptime

This commit is contained in:
LouisLam
2021-07-01 13:11:16 +08:00
parent 82afddcfd6
commit 84c21b71c0
7 changed files with 145 additions and 49 deletions

View File

@@ -18,9 +18,6 @@ export default {
computed: {
displayText() {
console.log(dayjs.tz.guess())
return this.value
},
}

61
src/components/Uptime.vue Normal file
View File

@@ -0,0 +1,61 @@
<template>
<span :class="className">{{ uptime }}</span>
</template>
<script>
export default {
props: {
monitor : Object,
type: String,
pill: {
Boolean,
default: false,
},
},
computed: {
uptime() {
let key = this.monitor.id + "_" + this.type;
if (this.$root.uptimeList[key]) {
return Math.round(this.$root.uptimeList[key] * 10000) / 100 + "%";
} else {
return "N/A"
}
},
color() {
if (this.lastHeartBeat.status === 0) {
return "danger"
} else if (this.lastHeartBeat.status === 1) {
return "primary"
} else {
return "secondary"
}
},
lastHeartBeat() {
if (this.monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[this.monitor.id]) {
return this.$root.lastHeartbeatList[this.monitor.id]
} else {
return { status: -1 }
}
},
className() {
if (this.pill) {
return `badge rounded-pill bg-${this.color}`;
} else {
return "";
}
},
},
}
</script>
<style scoped>
</style>