2021-07-01 05:11:16 +00:00
|
|
|
<template>
|
2022-10-17 17:20:51 +00:00
|
|
|
<span :class="className" :title="title">{{ uptime }}</span>
|
2021-07-01 05:11:16 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-01-17 09:34:47 +00:00
|
|
|
import { DOWN, MAINTENANCE, PENDING, UP } from "../util.ts";
|
|
|
|
|
2021-07-01 05:11:16 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Monitor this represents */
|
2022-04-30 01:51:14 +00:00
|
|
|
monitor: {
|
|
|
|
type: Object,
|
|
|
|
default: null,
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Type of monitor */
|
2022-04-30 01:51:14 +00:00
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
2022-06-02 14:15:21 +00:00
|
|
|
/** Is this a pill? */
|
2021-07-01 05:11:16 +00:00
|
|
|
pill: {
|
2021-07-27 17:53:59 +00:00
|
|
|
type: Boolean,
|
2021-07-01 05:11:16 +00:00
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
uptime() {
|
2022-01-23 14:22:00 +00:00
|
|
|
if (this.type === "maintenance") {
|
2022-09-27 12:44:44 +00:00
|
|
|
return this.$t("statusMaintenance");
|
2022-01-23 14:22:00 +00:00
|
|
|
}
|
2021-07-01 05:11:16 +00:00
|
|
|
|
|
|
|
let key = this.monitor.id + "_" + this.type;
|
|
|
|
|
2021-07-01 09:00:23 +00:00
|
|
|
if (this.$root.uptimeList[key] !== undefined) {
|
2023-01-18 16:38:55 +00:00
|
|
|
let result = Math.round(this.$root.uptimeList[key] * 10000) / 100;
|
|
|
|
// Only perform sanity check on status page. See louislam/uptime-kuma#2628
|
2023-01-23 18:10:45 +00:00
|
|
|
if (this.$route.path.startsWith("/status") && result > 100) {
|
|
|
|
return "100%";
|
2023-01-18 16:38:55 +00:00
|
|
|
} else {
|
|
|
|
return result + "%";
|
|
|
|
}
|
2021-07-01 05:11:16 +00:00
|
|
|
}
|
2021-07-27 17:47:13 +00:00
|
|
|
|
2022-04-13 16:30:32 +00:00
|
|
|
return this.$t("notAvailableShort");
|
2021-07-01 05:11:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
color() {
|
2023-01-17 09:34:47 +00:00
|
|
|
if (this.lastHeartBeat.status === MAINTENANCE) {
|
2022-04-30 12:57:08 +00:00
|
|
|
return "maintenance";
|
2022-01-23 14:22:00 +00:00
|
|
|
}
|
2022-04-30 12:57:08 +00:00
|
|
|
|
2023-01-17 09:34:47 +00:00
|
|
|
if (this.lastHeartBeat.status === DOWN) {
|
2022-04-13 16:30:32 +00:00
|
|
|
return "danger";
|
2021-07-27 18:03:53 +00:00
|
|
|
}
|
|
|
|
|
2023-01-17 09:34:47 +00:00
|
|
|
if (this.lastHeartBeat.status === UP) {
|
2022-04-13 16:30:32 +00:00
|
|
|
return "primary";
|
2021-07-27 18:03:53 +00:00
|
|
|
}
|
|
|
|
|
2023-01-17 09:34:47 +00:00
|
|
|
if (this.lastHeartBeat.status === PENDING) {
|
2022-04-13 16:30:32 +00:00
|
|
|
return "warning";
|
2021-07-01 05:11:16 +00:00
|
|
|
}
|
2021-07-27 17:47:13 +00:00
|
|
|
|
2022-04-13 16:30:32 +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]) {
|
2022-04-13 16:30:32 +00:00
|
|
|
return this.$root.lastHeartbeatList[this.monitor.id];
|
2021-07-27 17:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
status: -1,
|
2022-04-13 16:30:32 +00:00
|
|
|
};
|
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 "";
|
|
|
|
},
|
2022-10-17 17:20:51 +00:00
|
|
|
|
|
|
|
title() {
|
2023-08-31 21:19:21 +00:00
|
|
|
if (this.type === "1y") {
|
|
|
|
return `1${this.$t("-year")}`;
|
|
|
|
}
|
2022-10-17 17:20:51 +00:00
|
|
|
if (this.type === "720") {
|
2022-10-17 17:36:52 +00:00
|
|
|
return `30${this.$t("-day")}`;
|
2022-10-17 17:20:51 +00:00
|
|
|
}
|
2022-10-17 17:36:52 +00:00
|
|
|
return `24${this.$t("-hour")}`;
|
2022-10-17 17:20:51 +00:00
|
|
|
}
|
2021-07-01 05:11:16 +00:00
|
|
|
},
|
2022-04-13 16:30:32 +00:00
|
|
|
};
|
2021-07-01 05:11:16 +00:00
|
|
|
</script>
|
2021-08-03 07:14:26 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.badge {
|
|
|
|
min-width: 62px;
|
|
|
|
}
|
|
|
|
</style>
|