Phone card layout, status symbols, breadcrumbs, integration cards and server trends
Tables stack into labelled cards on a phone. Green, red and amber badges carry a check, cross or triangle as well as their colour. Pages inside a menu group show a breadcrumb, with the thing's name on a server's page. Integrations are cards with an Open button and a live status (working, failing, not checked yet, disabled). Agent-reported servers keep a short history of load, memory and disk use (migration 0019, one sample per ten minutes for 35 days) and show it as a Trends card with a days-until-full forecast for a filling disk. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
617dc1ea2f
commit
9965d94036
22 files changed
+3000
-84
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
const SORT_GLYPHS = /[↕↑↓▲▼⇅⇵]/g;
|
||||
|
||||
/** Writes each column's heading onto its cells (data-label), so the phone layout can show "Status: running" beside each value. */
|
||||
function labelTable(table: HTMLTableElement): void {
|
||||
const headRow = table.tHead?.rows[table.tHead.rows.length - 1];
|
||||
if (!headRow) return;
|
||||
const labels: string[] = [];
|
||||
for (const th of Array.from(headRow.cells)) {
|
||||
const text = (th.textContent ?? "").replace(SORT_GLYPHS, "").replace(/\s+/g, " ").trim();
|
||||
for (let i = 0; i < Math.max(1, th.colSpan); i++) labels.push(text);
|
||||
}
|
||||
for (const body of Array.from(table.tBodies)) {
|
||||
for (const row of Array.from(body.rows)) {
|
||||
let col = 0;
|
||||
for (const cell of Array.from(row.cells)) {
|
||||
const label = cell.colSpan > 1 ? "" : (labels[col] ?? "");
|
||||
if (label) {
|
||||
if (cell.getAttribute("data-label") !== label) cell.setAttribute("data-label", label);
|
||||
} else if (cell.hasAttribute("data-label")) {
|
||||
cell.removeAttribute("data-label");
|
||||
}
|
||||
col += Math.max(1, cell.colSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On a phone the wide tables are drawn as a stack of cards (see styles.css), which needs every cell to know its column's
|
||||
* heading. This keeps that up to date as pages load, sort, filter and page — without each table having to do it.
|
||||
*/
|
||||
export function useStackedTables(): void {
|
||||
useEffect(() => {
|
||||
const root = document.querySelector(".page-body");
|
||||
if (!root) return;
|
||||
// A short timer rather than an animation frame: frames stop while the tab is in the background, and the labels should not.
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
const run = () => {
|
||||
timer = null;
|
||||
root.querySelectorAll<HTMLTableElement>("table.card-table").forEach(labelTable);
|
||||
};
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!timer) timer = setTimeout(run, 30);
|
||||
});
|
||||
observer.observe(root, { childList: true, subtree: true });
|
||||
run();
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
if (timer) clearTimeout(timer);
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
Reference in new issue
Block a user