From 75fc01c95f6aa50a0bebfd5a99368f5ff47108d0 Mon Sep 17 00:00:00 2001 From: Doruk Date: Sat, 14 Jun 2025 13:38:52 +0200 Subject: [PATCH] simplifications --- package-lock.json | 4 ++-- src/components/HeartbeatBar.vue | 34 +++++++++++------------------- src/components/PublicGroupList.vue | 6 +----- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2225d11e9..ccb72dee3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "2.0.0-beta.3", + "version": "2.0.0-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "2.0.0-beta.3", + "version": "2.0.0-beta.2", "license": "MIT", "dependencies": { "@grpc/grpc-js": "~1.8.22", diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index 9be5ca3a1..1ed2f647b 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -50,11 +50,7 @@ export default { /** Heartbeat bar days */ heartbeatBarDays: { type: [ Number, String ], - default: 0, - validator(value) { - const num = Number(value); - return !isNaN(num) && num >= 0 && num <= 365; - } + default: 0 } }, data() { @@ -276,23 +272,17 @@ export default { * @returns {string} The time elapsed in minutes or hours. */ timeSinceFirstBeat() { - // For aggregated beats, calculate from the configured days + // For configured days mode, show the configured range if (this.normalizedHeartbeatBarDays > 0) { - if (this.normalizedHeartbeatBarDays < 2) { - return (this.normalizedHeartbeatBarDays * 24) + "h"; - } else { - return this.normalizedHeartbeatBarDays + "d"; - } + return this.normalizedHeartbeatBarDays < 2 ? + (this.normalizedHeartbeatBarDays * 24) + "h" : + this.normalizedHeartbeatBarDays + "d"; } - // Original logic for auto mode + // For auto mode, calculate from actual data const firstValidBeat = this.shortBeatList.at(this.numPadding); const minutes = dayjs().diff(dayjs.utc(firstValidBeat?.time), "minutes"); - if (minutes > 60) { - return (minutes / 60).toFixed(0) + "h"; - } else { - return minutes + "m"; - } + return minutes > 60 ? Math.floor(minutes / 60) + "h" : minutes + "m"; }, /** @@ -381,20 +371,20 @@ export default { * @returns {string} Beat title */ getBeatTitle(beat) { - if (beat === 0) { + if (beat === 0 || !beat) { return ""; } - // For aggregated beats (client-side aggregation), show time range and status - if (beat.beats !== undefined && this.normalizedHeartbeatBarDays > 0) { + // For aggregated beats, show time range and status + if (beat.beats !== undefined) { const start = this.$root.datetime(beat.start); const end = this.$root.datetime(beat.end); const statusText = beat.status === 1 ? "Up" : beat.status === 0 ? "Down" : beat.status === 3 ? "Maintenance" : "No Data"; return `${start} - ${end}: ${statusText} (${beat.beats.length} checks)`; } - // For published mode with configured days, show simple timestamp - return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : ""); + // For individual beats, show timestamp + return `${this.$root.datetime(beat.time)}${beat.msg ? ` - ${beat.msg}` : ""}`; }, }, diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index 4bbd04f4f..4bbeed283 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -118,11 +118,7 @@ export default { /** Heartbeat bar days */ heartbeatBarDays: { type: [ Number, String ], - default: 0, - validator(value) { - const num = Number(value); - return !isNaN(num) && num >= 0 && num <= 365; - } + default: 0 } }, data() {