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

View file

@ -773,7 +773,7 @@ export default {
if (! this.editMode) { if (! this.editMode) {
// Fetch mixed data based on per-monitor daily view settings // Fetch mixed data based on per-monitor daily view settings
axios.get("/api/status-page/heartbeat-daily/" + this.slug).then((res) => { 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 // Store both regular and daily data appropriately
this.$root.heartbeatList = {}; this.$root.heartbeatList = {};