fix: lint

This commit is contained in:
Mats Stottmeister 2025-06-11 21:40:16 +02:00
parent e6ce7e7a61
commit 7064932c16
No known key found for this signature in database
4 changed files with 65 additions and 55 deletions

View file

@ -178,7 +178,9 @@ export default {
*/
timeSinceFirstBeat() {
const firstValidBeat = this.shortBeatList.at(this.numPadding);
if (!firstValidBeat || !firstValidBeat.date) return "";
if (!firstValidBeat || !firstValidBeat.date) {
return "";
}
const days = dayjs().diff(dayjs(firstValidBeat.date), "days");
if (days > 30) {
@ -194,7 +196,9 @@ export default {
*/
timeSinceLastBeat() {
const lastValidBeat = this.shortBeatList.at(-1);
if (!lastValidBeat || !lastValidBeat.date) return "";
if (!lastValidBeat || !lastValidBeat.date) {
return "";
}
const days = dayjs().diff(dayjs(lastValidBeat.date), "days");
@ -273,15 +277,17 @@ export default {
* @returns {string} Beat title
*/
getBeatTitle(beat) {
if (!beat || beat === 0) return "";
if (!beat || beat === 0) {
return "";
}
// Handle missing data
if (beat.missing || beat.status === -1) {
const date = beat.date || beat.time.split(' ')[0];
const date = beat.date || beat.time.split(" ")[0];
return `${date}\nNo data available`;
}
const date = beat.date || beat.time.split(' ')[0];
const date = beat.date || beat.time.split(" ")[0];
const uptime = Math.round(beat.uptime * 100);
const stats = beat.dailyStats;
@ -289,8 +295,12 @@ export default {
if (stats) {
tooltip += `\nUp: ${stats.up}, Down: ${stats.down}`;
if (stats.pending > 0) tooltip += `, Pending: ${stats.pending}`;
if (stats.maintenance > 0) tooltip += `, Maintenance: ${stats.maintenance}`;
if (stats.pending > 0) {
tooltip += `, Pending: ${stats.pending}`;
}
if (stats.maintenance > 0) {
tooltip += `, Maintenance: ${stats.maintenance}`;
}
tooltip += `\nTotal checks: ${stats.total}`;
}
@ -329,22 +339,22 @@ export default {
*/
generateCompleteTimeline(actualData) {
const timeline = [];
const today = dayjs().startOf('day');
const startDate = today.subtract(90, 'day'); // 3 months back
const today = dayjs().startOf("day");
const startDate = today.subtract(90, "day"); // 3 months back
// Create a map of existing data by date for quick lookup
const dataMap = {};
actualData.forEach(beat => {
if (beat && beat.date) {
const dateKey = dayjs(beat.date).format('YYYY-MM-DD');
const dateKey = dayjs(beat.date).format("YYYY-MM-DD");
dataMap[dateKey] = beat;
}
});
// Generate complete timeline from startDate to today
for (let i = 0; i <= 90; i++) {
const currentDate = startDate.add(i, 'day');
const dateKey = currentDate.format('YYYY-MM-DD');
const currentDate = startDate.add(i, "day");
const dateKey = currentDate.format("YYYY-MM-DD");
if (dataMap[dateKey]) {
// Use actual data if available
@ -354,7 +364,7 @@ export default {
timeline.push({
status: -1, // Special status for missing data
date: dateKey,
time: dateKey + ' 00:00:00',
time: dateKey + " 00:00:00",
uptime: 0,
ping: 0,
missing: true,

View file

@ -773,7 +773,7 @@ export default {
if (! this.editMode) {
// Fetch mixed data based on per-monitor daily view settings
axios.get("/api/status-page/heartbeat-daily/" + this.slug).then((res) => {
const { heartbeatList, uptimeList, dailyViewSettings, hasMixedData } = res.data;
const { heartbeatList, uptimeList, dailyViewSettings } = res.data;
// Store both regular and daily data appropriately
this.$root.heartbeatList = {};
@ -790,7 +790,7 @@ export default {
if (heartbeatList[monitorId] && heartbeatList[monitorId].length > 0) {
const lastDailyBeat = heartbeatList[monitorId][heartbeatList[monitorId].length - 1];
// Create a minimal heartbeat list with just the last beat for color calculation
this.$root.heartbeatList[monitorId] = [lastDailyBeat];
this.$root.heartbeatList[monitorId] = [ lastDailyBeat ];
}
} else {
// This monitor uses regular view