dashboard frontend: consume rfc3339 timestamps from the api

This commit is contained in:
damocles 2026-07-02 21:35:03 +02:00 committed by mara
commit cafef519a9
5 changed files with 46 additions and 33 deletions

View file

@ -15,6 +15,7 @@
import {
$, el, fmtAgeSecs, openStream, initServerWarnings,
} from './common.js';
import { epochSec } from './util.js';
import { createTabStrip } from '@hive/shared/tabs.js';
(() => {
@ -170,10 +171,11 @@ import { createTabStrip } from '@hive/shared/tabs.js';
let auditTotal = 0;
let auditFetching = false;
// ts_unix is unix seconds — fmtAgeSecs wants an age in seconds.
function auditFmtWhen(tsUnix) {
if (!tsUnix) return '';
const age = Math.floor(Date.now() / 1000) - tsUnix;
// ts_unix arrives as an RFC 3339 string — fmtAgeSecs wants an age
// in seconds, so normalize via epochSec first.
function auditFmtWhen(ts) {
if (!ts) return '';
const age = Math.floor(Date.now() / 1000) - epochSec(ts);
return fmtAgeSecs(Math.max(0, age)) + ' ago';
}
@ -234,7 +236,7 @@ import { createTabStrip } from '@hive/shared/tabs.js';
tbody.append(el('tr', {},
el('td', {
class: 'audit-when meta',
title: e.ts_unix ? new Date(e.ts_unix * 1000).toISOString() : '',
title: e.ts_unix ? new Date(e.ts_unix).toISOString() : '',
}, auditFmtWhen(e.ts_unix)),
el('td', { class: 'audit-agent' }, e.agent || ''),
el('td', { class: 'audit-action' }, e.action || ''),