2
0
mirror of https://github.com/hibiken/asynqmon.git synced 2025-10-26 16:26:12 +08:00

(ui): Update UI to use the user selected duration

This commit is contained in:
Ken Hibino
2021-12-01 17:14:26 -08:00
parent ce28af6a69
commit 3a90416b52
5 changed files with 23 additions and 14 deletions

View File

@@ -74,8 +74,8 @@ export function timeAgo(timestamp: string): string {
}
export function timeAgoUnix(unixtime: number): string {
if (unixtime === 0) {
return ""
if (unixtime === 0) {
return "";
}
const duration = durationBetween(Date.now(), unixtime * 1000);
return stringifyDuration(duration) + " ago";
@@ -103,14 +103,12 @@ export function percentage(numerator: number, denominator: number): string {
return `${perc} %`;
}
export function isJsonPayload(p: string) {
try {
JSON.parse(p);
} catch (error) {
return false;
}
return true;
}
@@ -118,6 +116,10 @@ export function prettifyPayload(p: string) {
if (isJsonPayload(p)) {
return JSON.stringify(JSON.parse(p), null, 2);
}
return p;
}
// Returns the number of seconds elapsed since January 1, 1970 00:00:00 UTC.
export function currentUnixtime(): number {
return Math.floor(Date.now() / 1000);
}