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