chore(ui): Move prettifyTimeDifference to helper as generatePrettyTimeDifference

This commit is contained in:
TwiN 2022-06-12 17:57:05 -04:00
parent c31cb7540d
commit 9f343bacf7
2 changed files with 5 additions and 5 deletions

View File

@ -17,6 +17,10 @@ export const helper = {
let seconds = (differenceInMs / 1000).toFixed(0);
return seconds + " second" + (seconds !== "1" ? "s" : "") + " ago";
},
generatePrettyTimeDifference(start, end) {
let minutes = Math.ceil((new Date(start) - new Date(end)) / 1000 / 60);
return minutes + (minutes === 1 ? ' minute' : ' minutes');
},
prettifyTimestamp(timestamp) {
let date = new Date(timestamp);
let YYYY = date.getFullYear();

View File

@ -128,7 +128,7 @@ export default {
event.fancyText = 'Endpoint became healthy';
} else if (event.type === 'UNHEALTHY') {
if (nextEvent) {
event.fancyText = 'Endpoint was unhealthy for ' + this.prettifyTimeDifference(nextEvent.timestamp, event.timestamp);
event.fancyText = 'Endpoint was unhealthy for ' + this.generatePrettyTimeDifference(nextEvent.timestamp, event.timestamp);
} else {
event.fancyText = 'Endpoint became unhealthy';
}
@ -158,10 +158,6 @@ export default {
generateResponseTimeChartImageURL() {
return `${this.serverUrl}/api/v1/endpoints/${this.endpointStatus.key}/response-times/24h/chart.svg`;
},
prettifyTimeDifference(start, end) {
let minutes = Math.ceil((new Date(start) - new Date(end)) / 1000 / 60);
return minutes + (minutes === 1 ? ' minute' : ' minutes');
},
changePage(page) {
this.currentPage = page;
this.fetchData();