Add a since-you-last-looked summary, 30-day uptime ribbons, a maintenance timeline and hover timestamps
- Dashboard card on what changed since the user pressed Got it (users.last_looked_at, migration 0021), folding each problem and its recovery into one line. - Uptime ribbons on servers and integrations, built from the audit log; integrations' failing/working-again moments are now recorded. - Timeline of running and scheduled maintenance windows on the Maintenance page. - TimeAgo component: relative times with the exact time in the chosen format on hover. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3945c60681
commit
906220040e
32 files changed
+3380
-15
No files matched your search
@@ -10,6 +10,44 @@ export interface CurrentUser {
|
||||
favorites?: string[];
|
||||
}
|
||||
|
||||
/** One thing worth a line in "Since you last looked". */
|
||||
export interface ChangeEvent {
|
||||
at: string;
|
||||
tone: "good" | "bad" | "info" | "neutral";
|
||||
kind: "server" | "integration" | "maintenance";
|
||||
title: string;
|
||||
detail: string | null;
|
||||
link: string | null;
|
||||
}
|
||||
|
||||
export interface ChangesSummary {
|
||||
since: string;
|
||||
/** True the first time: the summary then covers the last day. */
|
||||
firstTime: boolean;
|
||||
events: ChangeEvent[];
|
||||
moreEvents: number;
|
||||
/** Entries other people wrote in the audit log in that time; null if this person can't see the audit log. */
|
||||
changesByOthers: number | null;
|
||||
}
|
||||
|
||||
/** Minutes known / minutes down in one 24-hour stretch. */
|
||||
export interface UptimeBucket {
|
||||
k: number;
|
||||
d: number;
|
||||
}
|
||||
|
||||
export interface UptimeSeries {
|
||||
buckets: UptimeBucket[];
|
||||
percent: number;
|
||||
}
|
||||
|
||||
export interface UptimeReport {
|
||||
days: number;
|
||||
endsAt: string;
|
||||
servers: Record<number, UptimeSeries>;
|
||||
integrations: Record<number, UptimeSeries>;
|
||||
}
|
||||
|
||||
export interface UserRecord {
|
||||
id: number;
|
||||
oidcSub: string;
|
||||
@@ -1110,7 +1148,12 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
export const api = {
|
||||
me: Object.assign(() => request<{ user: CurrentUser }>("/api/me"), {
|
||||
setFavorites: (paths: string[]) => request<{ favorites: string[] }>("/api/me/favorites", { method: "PUT", body: JSON.stringify({ paths }) }),
|
||||
changes: () => request<ChangesSummary>("/api/me/changes"),
|
||||
markChangesSeen: () => request<{ lastLookedAt: string }>("/api/me/changes/seen", { method: "POST" }),
|
||||
}),
|
||||
uptime: {
|
||||
get: () => request<UptimeReport>("/api/uptime"),
|
||||
},
|
||||
search: {
|
||||
query: (q: string) => request<SearchResponse>(`/api/search?q=${encodeURIComponent(q)}`),
|
||||
},
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import type { MaintenanceWindow } from "../api/client";
|
||||
import { formatDate, formatDateTime, formatTime } from "../utils/date";
|
||||
|
||||
const HOUR = 3600_000;
|
||||
const DAY = 24 * HOUR;
|
||||
|
||||
const RANGES = [
|
||||
{ key: "24h", label: "Next 24 hours", span: DAY, tickEvery: 3 * HOUR },
|
||||
{ key: "7d", label: "Next 7 days", span: 7 * DAY, tickEvery: DAY },
|
||||
{ key: "30d", label: "Next 30 days", span: 30 * DAY, tickEvery: 5 * DAY },
|
||||
] as const;
|
||||
|
||||
interface Span {
|
||||
from: number;
|
||||
to: number;
|
||||
}
|
||||
|
||||
/** Overlapping or touching spans folded into the stretches during which at least one is running. */
|
||||
function union(spans: Span[]): Span[] {
|
||||
const sorted = [...spans].sort((a, b) => a.from - b.from);
|
||||
const out: Span[] = [];
|
||||
for (const s of sorted) {
|
||||
const last = out[out.length - 1];
|
||||
if (last && s.from <= last.to) last.to = Math.max(last.to, s.to);
|
||||
else out.push({ ...s });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* The running and scheduled windows laid out along a time axis, one row per server, integration or DNS provider, plus a top row for
|
||||
* "anything at all in maintenance". It shows what a list can't: which windows overlap, and where there are gaps. The tables further
|
||||
* down the page hold the same windows for reading and for ending them, so this is a picture only.
|
||||
*/
|
||||
export default function MaintenanceTimeline({ windows, now }: { windows: MaintenanceWindow[]; now: number }) {
|
||||
const [rangeKey, setRangeKey] = useState<(typeof RANGES)[number]["key"]>("7d");
|
||||
const range = RANGES.find((r) => r.key === rangeKey)!;
|
||||
const start = now;
|
||||
const end = now + range.span;
|
||||
|
||||
const { rows, everything, further } = useMemo(() => {
|
||||
const inRange = windows.filter((w) => Date.parse(w.endsAt) > start && Date.parse(w.startedAt) < end);
|
||||
const byTarget = new Map<string, { name: string; kind: string; windows: MaintenanceWindow[] }>();
|
||||
for (const w of inRange) {
|
||||
const key = `${w.targetType}:${w.targetId}`;
|
||||
const row = byTarget.get(key) ?? { name: w.targetName, kind: w.targetKind, windows: [] };
|
||||
row.windows.push(w);
|
||||
byTarget.set(key, row);
|
||||
}
|
||||
return {
|
||||
rows: [...byTarget.values()].sort((a, b) => a.name.localeCompare(b.name)),
|
||||
everything: union(inRange.map((w) => ({ from: Math.max(Date.parse(w.startedAt), start), to: Math.min(Date.parse(w.endsAt), end) }))),
|
||||
further: windows.length - inRange.length,
|
||||
};
|
||||
}, [windows, start, end]);
|
||||
|
||||
const pct = (t: number) => ((Math.min(Math.max(t, start), end) - start) / range.span) * 100;
|
||||
const bar = (from: number, to: number) => ({ left: `${pct(from)}%`, width: `${Math.max(pct(to) - pct(from), 0.6)}%` });
|
||||
|
||||
const ticks: number[] = [];
|
||||
// First tick at the next whole step after now (the next midnight for day steps), so labels land on round times.
|
||||
const stepStart = new Date(now);
|
||||
if (range.tickEvery >= DAY) stepStart.setHours(24, 0, 0, 0);
|
||||
else {
|
||||
stepStart.setMinutes(0, 0, 0);
|
||||
const hours = range.tickEvery / HOUR;
|
||||
stepStart.setHours(Math.floor(stepStart.getHours() / hours) * hours);
|
||||
}
|
||||
for (let t = stepStart.getTime(); t < end; t += range.tickEvery) if (t > start) ticks.push(t);
|
||||
|
||||
const tickLabel = (t: number) => (range.tickEvery >= DAY ? formatDate(new Date(t)).replace(/^\d{4}-|\/\d{4}$/, "") : formatTime(new Date(t), false));
|
||||
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Timeline</h3>
|
||||
<div className="card-actions">
|
||||
<div className="btn-group btn-group-sm" role="group" aria-label="Time range">
|
||||
{RANGES.map((r) => (
|
||||
<button key={r.key} type="button" className={`btn btn-sm ${r.key === rangeKey ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={r.key === rangeKey} onClick={() => setRangeKey(r.key)}>
|
||||
{r.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{rows.length === 0 ? (
|
||||
<div className="text-secondary">Nothing running or scheduled in this time.{further > 0 ? ` ${further} further ahead.` : ""}</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="timeline-scroll" aria-hidden="true">
|
||||
<div className="timeline">
|
||||
<div className="timeline-row timeline-axis">
|
||||
<div className="timeline-label text-secondary">From now</div>
|
||||
<div className="timeline-track">
|
||||
{ticks.map((t) => (
|
||||
<span key={t} className="timeline-tick" style={{ left: `${pct(t)}%` }}>
|
||||
{tickLabel(t)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="timeline-row timeline-union">
|
||||
<div className="timeline-label fw-bold">Anything</div>
|
||||
<div className="timeline-track">
|
||||
{ticks.map((t) => (
|
||||
<span key={t} className="timeline-grid" style={{ left: `${pct(t)}%` }} />
|
||||
))}
|
||||
{everything.map((s, i) => (
|
||||
<span key={i} className="timeline-bar timeline-bar-union" style={bar(s.from, s.to)} title={`${formatDateTime(new Date(s.from))} – ${formatDateTime(new Date(s.to))}`} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{rows.map((row) => (
|
||||
<div key={row.name + row.kind} className="timeline-row">
|
||||
<div className="timeline-label" title={`${row.name} · ${row.kind}`}>
|
||||
{row.name}
|
||||
</div>
|
||||
<div className="timeline-track">
|
||||
{ticks.map((t) => (
|
||||
<span key={t} className="timeline-grid" style={{ left: `${pct(t)}%` }} />
|
||||
))}
|
||||
{row.windows.map((w) => {
|
||||
const from = Date.parse(w.startedAt);
|
||||
const to = Date.parse(w.endsAt);
|
||||
const running = from <= now;
|
||||
return (
|
||||
<span
|
||||
key={w.id}
|
||||
className={`timeline-bar ${running ? "timeline-bar-running" : "timeline-bar-scheduled"} ${w.source ? "timeline-bar-mirrored" : ""}`}
|
||||
style={bar(from, to)}
|
||||
title={`${row.name}: ${formatDateTime(new Date(from))} – ${formatDateTime(new Date(to))}${w.reason ? ` · ${w.reason}` : ""}`}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-secondary small mt-2 d-flex flex-wrap gap-3 align-items-center">
|
||||
<span>
|
||||
<span className="timeline-key timeline-bar-running" /> Running
|
||||
</span>
|
||||
<span>
|
||||
<span className="timeline-key timeline-bar-scheduled" /> Scheduled
|
||||
</span>
|
||||
<span>
|
||||
<span className="timeline-key timeline-bar-mirrored" /> From Uptime Kuma
|
||||
</span>
|
||||
<span>The same windows are listed in the tables below.</span>
|
||||
{further > 0 && <span>{further} further ahead than this range.</span>}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { formatDateTime, parseDbTimestamp } from "../utils/date";
|
||||
import { formatAgo, formatRemaining } from "../utils/duration";
|
||||
|
||||
// One shared clock for every TimeAgo on screen: "5 min ago" moves on by itself without each one running its own timer.
|
||||
const listeners = new Set<() => void>();
|
||||
let tick = 0;
|
||||
let timer: ReturnType<typeof setInterval> | undefined;
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
if (!timer) {
|
||||
timer = setInterval(() => {
|
||||
tick++;
|
||||
listeners.forEach((l) => l());
|
||||
}, 30_000);
|
||||
}
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
if (listeners.size === 0 && timer) {
|
||||
clearInterval(timer);
|
||||
timer = undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const getTick = () => tick;
|
||||
|
||||
/**
|
||||
* A time as people say it ("5 min ago", "in 2 h"), with the exact date and time — in the format chosen under Settings → Display —
|
||||
* as the hover text. `fromDb` is for the plain "2026-10-02 20:27:55" timestamps SQLite writes, which are UTC without saying so.
|
||||
*/
|
||||
export default function TimeAgo({ value, fromDb, empty = "—" }: { value: string | Date | null | undefined; fromDb?: boolean; empty?: string }) {
|
||||
useSyncExternalStore(subscribe, getTick);
|
||||
if (value === null || value === undefined || value === "") return <>{empty}</>;
|
||||
const date = value instanceof Date ? value : fromDb ? parseDbTimestamp(value) : new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return <>{empty}</>;
|
||||
const iso = date.toISOString();
|
||||
const future = date.getTime() > Date.now() + 60_000;
|
||||
return (
|
||||
<time dateTime={iso} title={formatDateTime(date)}>
|
||||
{future ? `in ${formatRemaining(iso)}` : formatAgo(iso)}
|
||||
</time>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useUptime } from "../hooks/useUptime";
|
||||
import { formatDate } from "../utils/date";
|
||||
|
||||
const DAY_MS = 24 * 3600_000;
|
||||
|
||||
function minutesLabel(minutes: number): string {
|
||||
if (minutes < 60) return `${minutes} min`;
|
||||
const h = Math.floor(minutes / 60);
|
||||
return minutes % 60 && h < 10 ? `${h} h ${minutes % 60} min` : `${h} h`;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thin strip of one bar per day for the last 30 days — green for a day with nothing wrong, amber for some time down, red for
|
||||
* half the day or more, grey where nothing is known (before it was added, or before the app began keeping this) — with the share of
|
||||
* time up beside it. The bars are for the eye; the percentage and the hover text carry the same information in words.
|
||||
*/
|
||||
export default function UptimeRibbon({ kind, id, name, showPercent = true }: { kind: "servers" | "integrations"; id: number; name: string; showPercent?: boolean }) {
|
||||
const report = useUptime();
|
||||
const series = report?.[kind][id];
|
||||
if (!report || !series) return null;
|
||||
|
||||
const end = Date.parse(report.endsAt);
|
||||
const summary = `${name}: ${series.percent}% up over the last ${report.days} days`;
|
||||
return (
|
||||
<span className="uptime" title={summary}>
|
||||
<span className="uptime-ribbon" aria-hidden="true">
|
||||
{series.buckets.map((b, i) => {
|
||||
const start = new Date(end - (report.days - i) * DAY_MS);
|
||||
const state = b.k === 0 ? "none" : b.d === 0 ? "up" : b.d / b.k >= 0.5 ? "down" : "some";
|
||||
const text = b.k === 0 ? "no record" : b.d === 0 ? "up all day" : `down ${minutesLabel(b.d)}`;
|
||||
return <i key={i} className={`uptime-${state}`} title={`${formatDate(start)}: ${text}`} />;
|
||||
})}
|
||||
</span>
|
||||
{showPercent ? (
|
||||
<span className="uptime-percent">
|
||||
{series.percent}% <span className="visually-hidden">up over the last {report.days} days</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="visually-hidden">{summary}</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { IconAlertTriangle, IconCircleCheck, IconPlugConnected, IconServer, IconTool } from "@tabler/icons-react";
|
||||
import { api, type ChangeEvent, type ChangesSummary, type UserRole } from "../api/client";
|
||||
import TimeAgo from "./TimeAgo";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const TONE_CLASS: Record<ChangeEvent["tone"], string> = { good: "text-green", bad: "text-red", info: "text-blue", neutral: "text-secondary" };
|
||||
|
||||
function EventIcon({ event }: { event: ChangeEvent }) {
|
||||
const cls = TONE_CLASS[event.tone];
|
||||
if (event.kind === "maintenance") return <IconTool size={18} className={cls} aria-hidden="true" />;
|
||||
if (event.tone === "bad") return <IconAlertTriangle size={18} className={cls} aria-hidden="true" />;
|
||||
if (event.tone === "good") return <IconCircleCheck size={18} className={cls} aria-hidden="true" />;
|
||||
return event.kind === "integration" ? <IconPlugConnected size={18} className={cls} aria-hidden="true" /> : <IconServer size={18} className={cls} aria-hidden="true" />;
|
||||
}
|
||||
|
||||
/**
|
||||
* What happened since this person last pressed "Got it": servers that stopped reporting, services that stopped answering, maintenance
|
||||
* that began or ended. Nothing to say means nothing shown. The mark is theirs alone and follows them to any browser.
|
||||
*/
|
||||
export default function WhatChanged({ role }: { role: UserRole }) {
|
||||
const [summary, setSummary] = useState<ChangesSummary | null>(null);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
api.me
|
||||
.changes()
|
||||
.then((s) => alive && setSummary(s))
|
||||
.catch(() => {
|
||||
// Only a nicety on the dashboard: if it can't load, the dashboard simply doesn't have it.
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!summary || dismissed) return null;
|
||||
const others = role !== "viewer" ? (summary.changesByOthers ?? 0) : 0;
|
||||
if (summary.events.length === 0 && others === 0) return null;
|
||||
|
||||
async function gotIt() {
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.me.markChangesSeen();
|
||||
setDismissed(true);
|
||||
} catch {
|
||||
toast.error("Couldn't save that. Try again.");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="card mb-3" aria-label="Since you last looked">
|
||||
<div className="card-header">
|
||||
<div>
|
||||
<h3 className="card-title">Since you last looked</h3>
|
||||
<div className="text-secondary small">{summary.firstTime ? "In the last day" : <>Since <TimeAgo value={summary.since} /></>}</div>
|
||||
</div>
|
||||
<div className="card-actions">
|
||||
<button type="button" className="btn btn-sm btn-primary" onClick={gotIt} disabled={busy}>
|
||||
Got it
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{summary.events.length > 0 ? (
|
||||
<ol className="activity-list">
|
||||
{summary.events.map((e, i) => (
|
||||
<li key={`${e.at}-${i}`}>
|
||||
<EventIcon event={e} />
|
||||
<div className="flex-fill" style={{ minWidth: 0 }}>
|
||||
<div>{e.link ? <Link to={e.link}>{e.title}</Link> : e.title}</div>
|
||||
{e.detail && <div className="text-secondary small">{e.detail}</div>}
|
||||
</div>
|
||||
<span className="text-secondary small text-nowrap">
|
||||
<TimeAgo value={e.at} />
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
) : (
|
||||
<div className="text-secondary">Nothing went wrong or came back.</div>
|
||||
)}
|
||||
{(summary.moreEvents > 0 || others > 0) && (
|
||||
<div className="text-secondary small mt-2">
|
||||
{summary.moreEvents > 0 && <>and {summary.moreEvents} more. </>}
|
||||
{others > 0 && (
|
||||
<>
|
||||
{others} change{others === 1 ? "" : "s"} made by other people — <Link to="/audit-log">see the audit log</Link>.
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
import { api, type UptimeReport } from "../api/client";
|
||||
|
||||
// One report for every ribbon on a page: the first to appear fetches it, the rest share it, and it is fetched again after a few minutes.
|
||||
const STALE_MS = 5 * 60_000;
|
||||
let report: UptimeReport | null = null;
|
||||
let fetchedAt = 0;
|
||||
let loading = false;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function load(): void {
|
||||
if (loading || (report && Date.now() - fetchedAt < STALE_MS)) return;
|
||||
loading = true;
|
||||
api.uptime
|
||||
.get()
|
||||
.then((r) => {
|
||||
report = r;
|
||||
fetchedAt = Date.now();
|
||||
listeners.forEach((l) => l());
|
||||
})
|
||||
.catch(() => {
|
||||
// No ribbons rather than an error on every row: this is a nicety on top of the lists.
|
||||
})
|
||||
.finally(() => {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
/** How each server and integration has done over the last 30 days; null until it has loaded (or if it couldn't). */
|
||||
export function useUptime(): UptimeReport | null {
|
||||
useEffect(load, []);
|
||||
return useSyncExternalStore(subscribe, () => report);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type ConsistencyFinding, type ConsistencyKind, type ConsistencyReport, type ConsistencySeverity, type CurrentUser } from "../api/client";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
@@ -182,7 +183,7 @@ export default function Consistency({ user }: { user: CurrentUser }) {
|
||||
<>
|
||||
{" "}
|
||||
from {dns.syncedZones} of {dns.zones} synced zone{dns.zones === 1 ? "" : "s"}
|
||||
{dns.oldestSyncedAt && <> (oldest sync {formatAgo(dns.oldestSyncedAt)})</>}
|
||||
{dns.oldestSyncedAt && <> (oldest sync <TimeAgo value={dns.oldestSyncedAt} />)</>}
|
||||
</>
|
||||
)}
|
||||
.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import WhatChanged from "../components/WhatChanged";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -594,6 +596,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
Welcome back, {user.name ?? user.email ?? user.sub}.
|
||||
</p>
|
||||
<StatusStrip />
|
||||
<WhatChanged role={user.role} />
|
||||
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
|
||||
<SetupGuide steps={setupSteps} />
|
||||
)}
|
||||
@@ -752,7 +755,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
{i > 0 && ", "}
|
||||
<Link to={`/servers/${s.id}`}>{s.name}</Link>{" "}
|
||||
<span className="text-secondary">
|
||||
({formatAgo(s.lastSeenAt)}
|
||||
(<TimeAgo value={s.lastSeenAt} empty="never seen" />
|
||||
{s.inMaintenance ? ", in maintenance" : ""})
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState, type CSSProperties } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -440,7 +441,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
||||
<td>{z.name}</td>
|
||||
<td>{z.recordCount}</td>
|
||||
<td className="text-secondary">
|
||||
{z.syncedAt ? formatDateTime(new Date(z.syncedAt)) : "never"}
|
||||
{z.syncedAt ? <TimeAgo value={z.syncedAt} /> : "never"}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import UptimeRibbon from "../components/UptimeRibbon";
|
||||
|
||||
const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
tailscale: "Tailscale",
|
||||
@@ -223,6 +224,11 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{i.enabled && (
|
||||
<div className="mb-3">
|
||||
<UptimeRibbon kind="integrations" id={i.id} name={i.name} />
|
||||
</div>
|
||||
)}
|
||||
{result && !result.ok && testingId !== i.id && <div className="text-red small mb-3">{result.error}</div>}
|
||||
<div className="btn-list mt-auto">
|
||||
{i.enabled && (
|
||||
|
||||
@@ -17,6 +17,7 @@ import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import MaintenanceTimeline from "../components/MaintenanceTimeline";
|
||||
|
||||
const DURATIONS: { minutes: number; label: string }[] = [
|
||||
{ minutes: 30, label: "30 minutes" },
|
||||
@@ -323,6 +324,8 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{((windows?.length ?? 0) > 0 || upcoming.length > 0) && <MaintenanceTimeline windows={[...(windows ?? []), ...upcoming]} now={now} />}
|
||||
|
||||
{canEdit && kumaIntegrations && kumaIntegrations.length > 0 && (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState, type FormEvent } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -225,7 +226,7 @@ export default function Ports({ user }: { user: CurrentUser }) {
|
||||
{p.localOnly && <span className="badge bg-secondary-lt text-secondary ms-2">local only</span>}
|
||||
</td>
|
||||
<td className="text-secondary">{p.process ?? "—"}</td>
|
||||
<td className="text-secondary">{p.lastSeenAt ? formatAgo(p.lastSeenAt) : "—"}</td>
|
||||
<td className="text-secondary"><TimeAgo value={p.lastSeenAt} /></td>
|
||||
</tr>
|
||||
))}
|
||||
{agentPorts !== null && agentPorts.length === 0 && (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type PrivacyOverview } from "../api/client";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
@@ -114,7 +115,7 @@ export default function Privacy() {
|
||||
{s.ip ?? "—"} {s.current && <span className="badge bg-green-lt text-green ms-1">this browser</span>}
|
||||
</td>
|
||||
<td className="text-secondary text-break">{s.userAgent ?? "—"}</td>
|
||||
<td className="text-secondary">{formatAgo(s.lastAccess)}</td>
|
||||
<td className="text-secondary"><TimeAgo value={s.lastAccess} /></td>
|
||||
<td className="text-secondary">{s.expiresAt ? formatDateTime(new Date(s.expiresAt)) : "—"}</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -461,7 +462,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
<td className="text-secondary">{t.node}</td>
|
||||
<td>{t.guestId ?? "—"}</td>
|
||||
<td>{backupStatusBadge(t)}</td>
|
||||
<td className="text-secondary">{formatDateTime(new Date(t.startTime))}</td>
|
||||
<td className="text-secondary"><TimeAgo value={t.startTime} /></td>
|
||||
<td className="text-secondary">{formatDuration(t.startTime, t.endTime)}</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -208,9 +209,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
||||
<td>{t.name}</td>
|
||||
<td className="text-secondary">{t.projectName}</td>
|
||||
<td className="text-secondary">
|
||||
{t.lastTask
|
||||
? formatDateTime(new Date(t.lastTask.end ?? t.lastTask.start ?? t.lastTask.created ?? ""))
|
||||
: "—"}
|
||||
{t.lastTask ? <TimeAgo value={t.lastTask.end ?? t.lastTask.start ?? t.lastTask.created} /> : "—"}
|
||||
</td>
|
||||
<td>{semaphoreStatusBadge(t)}</td>
|
||||
{canEdit && (
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
import ServerPorts from "../components/ServerPorts";
|
||||
import ServerTrends from "../components/ServerTrends";
|
||||
import ServerActivity from "../components/ServerActivity";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import UptimeRibbon from "../components/UptimeRibbon";
|
||||
import ServerTags from "../components/ServerTags";
|
||||
import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskTable";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
@@ -748,7 +750,11 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
<dt className="col-5">Created</dt>
|
||||
<dd className="col-7">{formatDateTime(new Date(server.createdAt))}</dd>
|
||||
<dt className="col-5">Last seen</dt>
|
||||
<dd className="col-7">{server.lastSeenAt ? formatDateTime(new Date(server.lastSeenAt)) : "never"}</dd>
|
||||
<dd className="col-7">{server.lastSeenAt ? <TimeAgo value={server.lastSeenAt} /> : "never"}</dd>
|
||||
<dt className="col-5">Last 30 days</dt>
|
||||
<dd className="col-7">
|
||||
<UptimeRibbon kind="servers" id={server.id} name={server.name} />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,8 @@ import { Link, useSearchParams } from "react-router-dom";
|
||||
import { api, type CurrentUser, type ServerRecord } from "../api/client";
|
||||
import CopyButton from "../components/CopyButton";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import UptimeRibbon from "../components/UptimeRibbon";
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { usePagination } from "../hooks/usePagination";
|
||||
@@ -291,6 +293,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
direction={sortDir}
|
||||
onSort={requestSort}
|
||||
/>
|
||||
<th>Last 30 days</th>
|
||||
<th className="w-1">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -307,7 +310,10 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</td>
|
||||
<td className="text-secondary">{s.apiTokenPrefix}…</td>
|
||||
<td>{s.lastSeenAt ? formatDateTime(new Date(s.lastSeenAt)) : "never"}</td>
|
||||
<td>{s.lastSeenAt ? <TimeAgo value={s.lastSeenAt} /> : "never"}</td>
|
||||
<td>
|
||||
<UptimeRibbon kind="servers" id={s.id} name={s.name} />
|
||||
</td>
|
||||
<td>
|
||||
<div className="btn-list flex-nowrap">
|
||||
<button className="btn btn-sm" onClick={() => rotateToken(s.id)}>
|
||||
@@ -325,7 +331,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
))}
|
||||
{sortedServers?.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={6} className="text-secondary text-center">
|
||||
<td colSpan={7} className="text-secondary text-center">
|
||||
No servers registered yet.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -410,7 +416,10 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
)}
|
||||
<div className="text-secondary small mt-2">
|
||||
{s.lastSeenAt ? `Last seen ${formatDateTime(new Date(s.lastSeenAt))}` : "Never reported"}
|
||||
{s.lastSeenAt ? <>Last seen <TimeAgo value={s.lastSeenAt} /></> : "Never reported"}
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<UptimeRibbon kind="servers" id={s.id} name={s.name} />
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { api, type SessionSummary } from "../api/client";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
@@ -148,7 +149,7 @@ export default function Sessions() {
|
||||
<td>{s.role ?? <span className="text-secondary">unknown user</span>}</td>
|
||||
<td>{s.ip ?? "—"}</td>
|
||||
<td className="text-secondary">{friendlyUserAgent(s.userAgent)}</td>
|
||||
<td>{formatDateTime(new Date(s.lastAccess))}</td>
|
||||
<td><TimeAgo value={s.lastAccess} /></td>
|
||||
<td>{s.expiresAt ? formatDateTime(new Date(s.expiresAt)) : "—"}</td>
|
||||
<td>
|
||||
<button
|
||||
|
||||
@@ -492,6 +492,159 @@ main:focus {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
/* ── Uptime ribbon: one bar per day for the last 30 days. ── */
|
||||
.uptime {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
max-width: 260px;
|
||||
}
|
||||
|
||||
/* The bars share whatever width there is, so the strip fits a narrow card as well as a table cell. */
|
||||
.uptime-ribbon {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
min-width: 60px;
|
||||
gap: 1px;
|
||||
height: 18px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.uptime-ribbon > i {
|
||||
display: block;
|
||||
flex: 1 1 0;
|
||||
min-width: 1px;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.table .uptime {
|
||||
min-width: 190px;
|
||||
}
|
||||
|
||||
.uptime-up {
|
||||
background: var(--tblr-green);
|
||||
}
|
||||
|
||||
.uptime-some {
|
||||
background: var(--tblr-yellow);
|
||||
}
|
||||
|
||||
.uptime-down {
|
||||
background: var(--tblr-red);
|
||||
}
|
||||
|
||||
.uptime-none {
|
||||
background: var(--tblr-border-color);
|
||||
}
|
||||
|
||||
.uptime-percent {
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
color: var(--tblr-secondary);
|
||||
}
|
||||
|
||||
/* ── Maintenance timeline: windows along a time axis, one row per target. ── */
|
||||
.timeline-scroll {
|
||||
overflow: auto;
|
||||
max-height: 420px;
|
||||
}
|
||||
|
||||
.timeline {
|
||||
min-width: 640px;
|
||||
}
|
||||
|
||||
.timeline-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 28px;
|
||||
border-bottom: 1px solid var(--tblr-border-color);
|
||||
}
|
||||
|
||||
.timeline-label {
|
||||
flex: 0 0 160px;
|
||||
padding-right: 0.75rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.8125rem;
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
background: var(--tblr-card-bg, var(--tblr-bg-surface));
|
||||
}
|
||||
|
||||
.timeline-track {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.timeline-axis {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
background: var(--tblr-card-bg, var(--tblr-bg-surface));
|
||||
}
|
||||
|
||||
.timeline-axis .timeline-track {
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.timeline-tick {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
padding-left: 3px;
|
||||
font-size: 0.7rem;
|
||||
color: var(--tblr-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.timeline-grid {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
background: var(--tblr-border-color);
|
||||
}
|
||||
|
||||
.timeline-bar,
|
||||
.timeline-key {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.timeline-bar {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
bottom: 6px;
|
||||
min-width: 3px;
|
||||
}
|
||||
|
||||
.timeline-key {
|
||||
display: inline-block;
|
||||
width: 1.25rem;
|
||||
height: 0.7rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.timeline-bar-running {
|
||||
background-color: var(--tblr-blue);
|
||||
}
|
||||
|
||||
.timeline-bar-scheduled {
|
||||
background-color: color-mix(in srgb, var(--tblr-blue) 25%, transparent);
|
||||
border: 1px solid var(--tblr-blue);
|
||||
}
|
||||
|
||||
.timeline-bar-union {
|
||||
background-color: var(--tblr-orange);
|
||||
}
|
||||
|
||||
/* Windows mirrored from Uptime Kuma's own schedule get diagonal stripes on top of their colour. */
|
||||
.timeline-bar-mirrored {
|
||||
background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 3px, transparent 3px 6px);
|
||||
}
|
||||
|
||||
/* ── The wall display: a full-screen status board, big enough to read across a room. ── */
|
||||
.wall {
|
||||
display: flex;
|
||||
|
||||
Reference in new issue
Block a user