simplifications

This commit is contained in:
Doruk 2025-06-14 13:38:52 +02:00
parent 992bcdb18e
commit 75fc01c95f
3 changed files with 15 additions and 29 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "2.0.0-beta.3", "version": "2.0.0-beta.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "2.0.0-beta.3", "version": "2.0.0-beta.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "~1.8.22", "@grpc/grpc-js": "~1.8.22",

View file

@ -50,11 +50,7 @@ export default {
/** Heartbeat bar days */ /** Heartbeat bar days */
heartbeatBarDays: { heartbeatBarDays: {
type: [ Number, String ], type: [ Number, String ],
default: 0, default: 0
validator(value) {
const num = Number(value);
return !isNaN(num) && num >= 0 && num <= 365;
}
} }
}, },
data() { data() {
@ -276,23 +272,17 @@ export default {
* @returns {string} The time elapsed in minutes or hours. * @returns {string} The time elapsed in minutes or hours.
*/ */
timeSinceFirstBeat() { timeSinceFirstBeat() {
// For aggregated beats, calculate from the configured days // For configured days mode, show the configured range
if (this.normalizedHeartbeatBarDays > 0) { if (this.normalizedHeartbeatBarDays > 0) {
if (this.normalizedHeartbeatBarDays < 2) { return this.normalizedHeartbeatBarDays < 2 ?
return (this.normalizedHeartbeatBarDays * 24) + "h"; (this.normalizedHeartbeatBarDays * 24) + "h" :
} else { this.normalizedHeartbeatBarDays + "d";
return this.normalizedHeartbeatBarDays + "d";
}
} }
// Original logic for auto mode // For auto mode, calculate from actual data
const firstValidBeat = this.shortBeatList.at(this.numPadding); const firstValidBeat = this.shortBeatList.at(this.numPadding);
const minutes = dayjs().diff(dayjs.utc(firstValidBeat?.time), "minutes"); const minutes = dayjs().diff(dayjs.utc(firstValidBeat?.time), "minutes");
if (minutes > 60) { return minutes > 60 ? Math.floor(minutes / 60) + "h" : minutes + "m";
return (minutes / 60).toFixed(0) + "h";
} else {
return minutes + "m";
}
}, },
/** /**
@ -381,20 +371,20 @@ export default {
* @returns {string} Beat title * @returns {string} Beat title
*/ */
getBeatTitle(beat) { getBeatTitle(beat) {
if (beat === 0) { if (beat === 0 || !beat) {
return ""; return "";
} }
// For aggregated beats (client-side aggregation), show time range and status // For aggregated beats, show time range and status
if (beat.beats !== undefined && this.normalizedHeartbeatBarDays > 0) { if (beat.beats !== undefined) {
const start = this.$root.datetime(beat.start); const start = this.$root.datetime(beat.start);
const end = this.$root.datetime(beat.end); const end = this.$root.datetime(beat.end);
const statusText = beat.status === 1 ? "Up" : beat.status === 0 ? "Down" : beat.status === 3 ? "Maintenance" : "No Data"; const statusText = beat.status === 1 ? "Up" : beat.status === 0 ? "Down" : beat.status === 3 ? "Maintenance" : "No Data";
return `${start} - ${end}: ${statusText} (${beat.beats.length} checks)`; return `${start} - ${end}: ${statusText} (${beat.beats.length} checks)`;
} }
// For published mode with configured days, show simple timestamp // For individual beats, show timestamp
return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : ""); return `${this.$root.datetime(beat.time)}${beat.msg ? ` - ${beat.msg}` : ""}`;
}, },
}, },

View file

@ -118,11 +118,7 @@ export default {
/** Heartbeat bar days */ /** Heartbeat bar days */
heartbeatBarDays: { heartbeatBarDays: {
type: [ Number, String ], type: [ Number, String ],
default: 0, default: 0
validator(value) {
const num = Number(value);
return !isNaN(num) && num >= 0 && num <= 365;
}
} }
}, },
data() { data() {