[web] Design review: last row's menu not clipped, Hostname focused after loading, popover closes on Esc and outside click, phone engine chip in the top bar, paused and needs-attention copy with Restore in the panel, change bar offers and countdown, focus after share and kept, fingerprint check when signing by hand, draft kept through sign-in
This commit is contained in:
@@ -25,6 +25,21 @@ export function when(iso: string | null | undefined, now = Date.now()): string {
|
||||
return `${d.getDate()} ${MONTHS[d.getMonth()]} ${hm}`;
|
||||
}
|
||||
|
||||
/** Inside a sentence: "today 14:02", "yesterday 21:14", "5 Nov 21:14". */
|
||||
export function whenInline(iso: string | null | undefined, now = Date.now()): string {
|
||||
return when(iso, now).replace(/^(Today|Yesterday)/, (s) => s.toLowerCase());
|
||||
}
|
||||
|
||||
/** After "at" / "on": "at 14:03", "yesterday at 21:14", "on 5 Nov at 21:14", "on 5 Nov 2025". */
|
||||
export function atTime(iso: string | null | undefined, now = Date.now()): string {
|
||||
const w = when(iso, now);
|
||||
if (!w) return "";
|
||||
if (w.startsWith("Today ")) return `at ${w.slice(6)}`;
|
||||
if (w.startsWith("Yesterday ")) return `yesterday at ${w.slice(10)}`;
|
||||
const m = /^(\d+ \w+) (\d\d:\d\d)$/.exec(w);
|
||||
return m ? `on ${m[1]} at ${m[2]}` : `on ${w}`;
|
||||
}
|
||||
|
||||
/** "14 November 2026 at 14:20". */
|
||||
export function longDate(iso: string | null | undefined, withTime = true): string {
|
||||
if (!iso) return "";
|
||||
@@ -57,12 +72,13 @@ export function ago(iso: string | null | undefined, now: number): string {
|
||||
return duration((now - Date.parse(iso)) / 1000) + " ago";
|
||||
}
|
||||
|
||||
/** "7 hosts · 5 healthy, 1 degraded, 1 down" (handoff §5.1). */
|
||||
export function countsSentence(c: { hosts: number; healthy: number; degraded: number; down: number; unknown: number }): string {
|
||||
/** "7 hosts · 5 healthy, 1 degraded, 1 down" (handoff §5.1); short (phone, §5.2): "5 healthy, 1 degraded, 1 down". */
|
||||
export function countsSentence(c: { hosts: number; healthy: number; degraded: number; down: number; unknown: number }, short = false): string {
|
||||
const parts = [`${c.healthy} healthy`];
|
||||
if (c.degraded) parts.push(`${c.degraded} degraded`);
|
||||
if (c.down) parts.push(`${c.down} down`);
|
||||
if (c.unknown) parts.push(`${c.unknown} not checked`);
|
||||
if (short) return parts.join(", ");
|
||||
return `${c.hosts} ${c.hosts === 1 ? "host" : "hosts"} · ${parts.join(", ")}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user