Add saved filter views, a customisable dashboard, server comparison, row keyboard navigation and share links
- Table search, status, tag and sort live in the address; Save view pins one as a favourite. - Dashboard cards can be moved and hidden per user (users.dashboard_layout, migration 0022). - Compare two to four servers' load, memory or disk on one chart. - j/k move through table rows that open a detail panel. - Share links open a read-only wall without signing in, numbers only or with names (share_links, migration 0023); the wall is split into a shared view over two data sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
906220040e
commit
44e393f172
50 files changed
+6114
-258
No files matched your search
@@ -0,0 +1,109 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { api, type PublicWall } from "../api/client";
|
||||
import WallView, { REFRESH_MS, wallHeadline, type WallData } from "../components/WallView";
|
||||
import { setDateTimeSettings } from "../utils/date";
|
||||
|
||||
/**
|
||||
* The wall display behind a share link: the same board, read-only and without signing in. The address carries the secret, and the
|
||||
* server decides how much it may show — this only draws what comes back. A link that doesn't work (never made, ended, taken back)
|
||||
* says so and stops asking.
|
||||
*/
|
||||
export default function SharedWall() {
|
||||
const { token = "" } = useParams();
|
||||
const [wall, setWall] = useState<PublicWall | null>(null);
|
||||
const [state, setState] = useState<"loading" | "ok" | "dead" | "unreachable">("loading");
|
||||
const [updatedAt, setUpdatedAt] = useState<Date | null>(null);
|
||||
const [idle, setIdle] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
let timer: ReturnType<typeof setInterval> | undefined;
|
||||
const load = () =>
|
||||
api.publicWall
|
||||
.get(token)
|
||||
.then((w) => {
|
||||
if (!alive) return;
|
||||
setDateTimeSettings({ dateFormat: w.display.dateFormat as "ymd" | "dmy" | "mdy", timeFormat: w.display.timeFormat as "24h" | "12h" });
|
||||
setWall(w);
|
||||
setUpdatedAt(new Date());
|
||||
setState("ok");
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
if (!alive) return;
|
||||
const status = (err as { status?: number }).status;
|
||||
if (status === 404 || status === 429) {
|
||||
// 404: this link doesn't work (any more). Asking again would only repeat that.
|
||||
if (status === 404) {
|
||||
setState("dead");
|
||||
if (timer) clearInterval(timer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setState((s) => (s === "ok" ? "ok" : "unreachable"));
|
||||
});
|
||||
void load();
|
||||
timer = setInterval(load, REFRESH_MS);
|
||||
return () => {
|
||||
alive = false;
|
||||
if (timer) clearInterval(timer);
|
||||
};
|
||||
}, [token]);
|
||||
|
||||
// The pointer hides itself when nobody is using it.
|
||||
useEffect(() => {
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
const onMove = () => {
|
||||
setIdle(false);
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => setIdle(true), 5000);
|
||||
};
|
||||
onMove();
|
||||
window.addEventListener("mousemove", onMove);
|
||||
return () => {
|
||||
window.removeEventListener("mousemove", onMove);
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (state === "dead") {
|
||||
return (
|
||||
<div className="wall" data-bs-theme="dark">
|
||||
<section className="wall-status wall-status-unsure" role="alert">
|
||||
<span className="wall-status-symbol" aria-hidden="true">
|
||||
?
|
||||
</span>
|
||||
<span>This link doesn't work any more</span>
|
||||
</section>
|
||||
<div className="wall-empty">It may have ended or been taken back. Ask whoever gave it to you for a new one.</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const count = wall ? wall.alerts.critical + wall.alerts.warning : 0;
|
||||
const data: WallData = {
|
||||
level: wall?.level ?? "unsure",
|
||||
headline: wallHeadline(wall?.level ?? "unsure", count, { loaded: !!wall, failed: state === "unreachable" }),
|
||||
servers: wall ? { online: wall.servers.online, total: wall.servers.online + wall.servers.offline } : null,
|
||||
alerts: wall ? wall.alerts : null,
|
||||
maintenance: wall?.maintenance ?? 0,
|
||||
integrationsFailing: wall ? wall.integrationsFailing : null,
|
||||
problems: wall?.problems ?? null,
|
||||
windows: wall?.maintenanceWindows ?? null,
|
||||
integrations: (wall?.integrations as WallData["integrations"]) ?? null,
|
||||
environmentName: wall?.environment ?? null,
|
||||
updatedAt,
|
||||
};
|
||||
|
||||
return (
|
||||
<WallView
|
||||
data={data}
|
||||
idle={idle}
|
||||
footerActions={
|
||||
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
|
||||
Full screen
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user