uptime-kuma/src/components/Uptime.vue

79 lines
1.7 KiB
Vue
Raw Normal View History

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