Bug In the Web-UI, Timestamps for 'Warning or critical alerts' are showing incorrect month #3023

This commit is contained in:
nicolargo 2024-11-20 13:15:28 +01:00
parent 16c5c71cdc
commit fb25a6f4f4
2 changed files with 17 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<template>
<section class="plugin" id="alerts">
<span class="title" v-if="hasAlerts">
Warning or critical alerts (last {{ countAlerts }} entries)
Warning or critical alerts (last {{ countAlerts }} entries)
</span>
<span class="title" v-else>No warning or critical alert detected</span>
<table class="table table-sm table-borderless">
@ -9,9 +9,10 @@
<tr v-for="(alert, alertId) in alerts" :key="alertId">
<td scope="row">
<span>{{ formatDate(alert.begin) }}</span>
</td>
<td scope="row">
<span>({{ alert.ongoing ? 'ongoing' : alert.duration }})</span>
</td>
<td scope="row"></td>
<td scope="row">
<span v-show="!alert.ongoing"> {{ alert.state }} on </span>
<span :class="alert.state.toLowerCase()">{{ alert.type }}</span>
@ -25,8 +26,8 @@
</template>
<script>
import {padStart} from 'lodash';
import {GlancesFavico} from '../services.js';
import { padStart } from 'lodash';
import { GlancesFavico } from '../services.js';
export default {
props: {
@ -54,12 +55,12 @@ export default {
if (!alert.ongoing) {
const duration = alert.end - alert.begin;
const seconds = parseInt((duration / 1000) % 60),
minutes = parseInt((duration / (1000 * 60)) % 60),
hours = parseInt((duration / (1000 * 60 * 60)) % 24);
minutes = parseInt((duration / (1000 * 60)) % 60),
hours = parseInt((duration / (1000 * 60 * 60)) % 24);
alert.duration = padStart(hours, 2, '0') +
':' + padStart(minutes, 2, '0') +
':' + padStart(seconds, 2, '0');
':' + padStart(minutes, 2, '0') +
':' + padStart(seconds, 2, '0');
}
return alert;
@ -75,7 +76,7 @@ export default {
return this.countOngoingAlerts > 0;
},
countOngoingAlerts() {
return this.alerts.filter(({ongoing}) => ongoing).length;
return this.alerts.filter(({ ongoing }) => ongoing).length;
}
},
watch: {
@ -98,12 +99,12 @@ export default {
const date = new Date(timestamp);
return String(date.getFullYear()) +
'-' + String(date.getMonth()).padStart(2, '0') +
'-' + String(date.getDate()).padStart(2, '0') +
' ' + String(date.getHours()).padStart(2, '0') +
':' + String(date.getMinutes()).padStart(2, '0') +
':' + String(date.getSeconds()).padStart(2, '0') +
'(' + tzString + ')';
'-' + String(date.getMonth() + 1).padStart(2, '0') +
'-' + String(date.getDate()).padStart(2, '0') +
' ' + String(date.getHours()).padStart(2, '0') +
':' + String(date.getMinutes()).padStart(2, '0') +
':' + String(date.getSeconds()).padStart(2, '0') +
'(' + tzString + ')';
}
}
};

File diff suppressed because one or more lines are too long