uptime-kuma/src/components/Uptime.vue

70 lines
1.4 KiB
Vue
Raw Normal View History

2021-07-01 05:11:16 +00:00
<template>
<span :class="className">{{ uptime }}</span>
</template>
<script>
export default {
props: {
2021-07-27 17:47:13 +00:00
monitor: Object,
2021-07-01 05:11:16 +00:00
type: String,
pill: {
2021-07-27 17:53:59 +00:00
type: Boolean,
2021-07-01 05:11:16 +00:00
default: false,
},
},
computed: {
uptime() {
let key = this.monitor.id + "_" + this.type;
2021-07-01 09:00:23 +00:00
if (this.$root.uptimeList[key] !== undefined) {
2021-07-01 05:11:16 +00:00
return Math.round(this.$root.uptimeList[key] * 10000) / 100 + "%";
}
2021-07-27 17:47:13 +00:00
2021-09-01 19:17:50 +00:00
return this.$t("notAvailableShort")
2021-07-01 05:11:16 +00:00
},
color() {
if (this.lastHeartBeat.status === 0) {
return "danger"
2021-07-27 18:03:53 +00:00
}
if (this.lastHeartBeat.status === 1) {
2021-07-01 05:11:16 +00:00
return "primary"
2021-07-27 18:03:53 +00:00
}
if (this.lastHeartBeat.status === 2) {
return "warning"
2021-07-01 05:11:16 +00:00
}
2021-07-27 17:47:13 +00:00
return "secondary"
2021-07-01 05:11:16 +00:00
},
lastHeartBeat() {
if (this.monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[this.monitor.id]) {
return this.$root.lastHeartbeatList[this.monitor.id]
2021-07-27 17:47:13 +00:00
}
return {
status: -1,
2021-07-01 05:11:16 +00:00
}
},
className() {
if (this.pill) {
return `badge rounded-pill bg-${this.color}`;
}
2021-07-27 17:47:13 +00:00
return "";
},
2021-07-01 05:11:16 +00:00
},
}
</script>
2021-08-03 07:14:26 +00:00
<style>
.badge {
min-width: 62px;
}
</style>