diff options
author | Daniel Baumann <daniel@debian.org> | 2024-11-26 09:28:28 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-11-26 12:25:58 +0100 |
commit | a1882b67c41fe9901a0cd8059b5cc78a5beadec0 (patch) | |
tree | 2a24507c67aa99a15416707b2f7e645142230ed8 /src/components/Uptime.vue | |
parent | Initial commit. (diff) | |
download | uptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.tar.xz uptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.zip |
Adding upstream version 2.0.0~beta.0+dfsg.upstream/2.0.0_beta.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'src/components/Uptime.vue')
-rw-r--r-- | src/components/Uptime.vue | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/components/Uptime.vue b/src/components/Uptime.vue new file mode 100644 index 0000000..64bbd4e --- /dev/null +++ b/src/components/Uptime.vue @@ -0,0 +1,103 @@ +<template> + <span :class="className" :title="title">{{ uptime }}</span> +</template> + +<script> +import { DOWN, MAINTENANCE, PENDING, UP } from "../util.ts"; + +export default { + props: { + /** Monitor this represents */ + monitor: { + type: Object, + default: null, + }, + /** Type of monitor */ + type: { + type: String, + default: null, + }, + /** Is this a pill? */ + pill: { + type: Boolean, + default: false, + }, + }, + + computed: { + uptime() { + if (this.type === "maintenance") { + return this.$t("statusMaintenance"); + } + + let key = this.monitor.id + "_" + this.type; + + if (this.$root.uptimeList[key] !== undefined) { + let result = Math.round(this.$root.uptimeList[key] * 10000) / 100; + // Only perform sanity check on status page. See louislam/uptime-kuma#2628 + if (this.$route.path.startsWith("/status") && result > 100) { + return "100%"; + } else { + return result + "%"; + } + } + + return this.$t("notAvailableShort"); + }, + + color() { + if (this.lastHeartBeat.status === MAINTENANCE) { + return "maintenance"; + } + + if (this.lastHeartBeat.status === DOWN) { + return "danger"; + } + + if (this.lastHeartBeat.status === UP) { + return "primary"; + } + + if (this.lastHeartBeat.status === PENDING) { + return "warning"; + } + + return "secondary"; + }, + + lastHeartBeat() { + if (this.monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[this.monitor.id]) { + return this.$root.lastHeartbeatList[this.monitor.id]; + } + + return { + status: -1, + }; + }, + + className() { + if (this.pill) { + return `badge rounded-pill bg-${this.color}`; + } + + return ""; + }, + + title() { + if (this.type === "1y") { + return `1${this.$t("-year")}`; + } + if (this.type === "720") { + return `30${this.$t("-day")}`; + } + return `24${this.$t("-hour")}`; + } + }, +}; +</script> + +<style> +.badge { + min-width: 62px; +} +</style> |