diff --git a/src/pages/AdminMonitor.tsx b/src/pages/AdminMonitor.tsx index da020e9..5c5eddc 100644 --- a/src/pages/AdminMonitor.tsx +++ b/src/pages/AdminMonitor.tsx @@ -7,12 +7,24 @@ interface AppStatus { repo: string host: string currentCommit: string + currentCommitAt: string | null latestCommit: string + latestCommitAt: string | null updateAvailable: boolean deployed: boolean checkedAt: string } +function relativeTime(iso: string | null | undefined): string | null { + if (!iso) return null + const diff = Date.now() - new Date(iso).getTime() + if (diff < 60_000) return 'just now' + if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago` + if (diff < 86_400_000) return `${Math.floor(diff / 3_600_000)}h ago` + if (diff < 7 * 86_400_000) return `${Math.floor(diff / 86_400_000)}d ago` + return new Date(iso).toLocaleDateString(undefined, { day: 'numeric', month: 'short' }) +} + interface HealthStatus { name: string up: boolean @@ -172,8 +184,20 @@ export function AdminMonitor({ user }: { user: User }) {
{s.deployed ? `deployed: ${s.currentCommit}` : s.currentCommit} + {s.deployed && relativeTime(s.currentCommitAt) && ( + + · {relativeTime(s.currentCommitAt)} + + )} {s.latestCommit !== 'unknown' && ( - latest: {s.latestCommit} + + latest: {s.latestCommit} + {relativeTime(s.latestCommitAt) && ( + + · {relativeTime(s.latestCommitAt)} + + )} + )}