You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/src/components/Uptime.vue

79 lines
1.7 KiB

3 years ago
<template>
<span :class="className" :title="24 + $t('-hour')">{{ uptime }}</span>
3 years ago
</template>
<script>
export default {
props: {
/** Monitor this represents */
monitor: {
type: Object,
default: null,
},
/** Type of monitor */
type: {
type: String,
default: null,
},
/** Is this a pill? */
3 years ago
pill: {
3 years ago
type: Boolean,
3 years ago
default: false,
},
},
computed: {
uptime() {
let key = this.monitor.id + "_" + this.type;
if (this.$root.uptimeList[key] !== undefined) {
3 years ago
return Math.round(this.$root.uptimeList[key] * 10000) / 100 + "%";
}
3 years ago
return this.$t("notAvailableShort");
3 years ago
},
color() {
if (this.lastHeartBeat.status === 0) {
return "danger";
}
if (this.lastHeartBeat.status === 1) {
return "primary";
}
if (this.lastHeartBeat.status === 2) {
return "warning";
3 years ago
}
3 years ago
return "secondary";
3 years ago
},
lastHeartBeat() {
if (this.monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[this.monitor.id]) {
return this.$root.lastHeartbeatList[this.monitor.id];
3 years ago
}
return {
status: -1,
};
3 years ago
},
className() {
if (this.pill) {
return `badge rounded-pill bg-${this.color}`;
}
3 years ago
return "";
},
3 years ago
},
};
3 years ago
</script>
3 years ago
<style>
.badge {
min-width: 62px;
}
</style>