79 lines
1.7 KiB
Vue
Raw Normal View History

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