UniFi: servers plugged into switches; server page in sections; My work; settings search and undo

UniFi: the controller's client list is matched to servers by IP address, so a
server is connected through a switch or access point (and port). That is a
dependency made by itself, shown on the server page, the Network devices page
and the Connections map. IP Addresses can sync the devices' addresses.

A server's page is split into Overview, Health, Network, History, Tasks and
Settings, by ?view=; alerts link to the section they are about.

My work lists what has your name on it: alerts you have, maintenance you
started (extend, end with undo) and update runs you started, with a badge.

Settings has a search box (and the command palette lists every setting).
Removing a dependency, admin link, runbook, hand-made IP address, port opening
or restore test is undone from the message instead of asked about first.

Two backup tests used a fixed date and failed as days passed; they follow the
real clock now.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 19:35:45 +02:00
1 parent 396e074108
commit 5e26e77340
45 files changed
+6224 -194

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
import { useEffect, useSyncExternalStore } from "react";
import { api, type MyWork } from "../api/client";
/**
* What the signed-in person has taken on, shared by everything that shows it (the menu badge, the dashboard strip, the My work page), so one request every
* couple of minutes serves them all. Asked again at once when something that changes it is done (an acknowledgement, a maintenance window).
*/
let current: MyWork | null = null;
const listeners = new Set<() => void>();
let timer: ReturnType<typeof setInterval> | null = null;
let inFlight = false;
const POLL_MS = 120_000;
async function refresh(): Promise<void> {
if (inFlight) return;
inFlight = true;
try {
current = await api.myWork.get();
for (const l of listeners) l();
} catch {
// keep what there was: a failed look is not "nothing to do"
} finally {
inFlight = false;
}
}
/** Looks again now — after something was acknowledged, handed over, extended or ended. */
export function refreshMyWork(): void {
if (listeners.size > 0) void refresh();
}
if (typeof window !== "undefined") {
window.addEventListener("maintenance-changed", refreshMyWork);
}
function subscribe(listener: () => void): () => void {
listeners.add(listener);
if (listeners.size === 1) {
void refresh();
timer = setInterval(() => void refresh(), POLL_MS);
}
return () => {
listeners.delete(listener);
if (listeners.size === 0 && timer) {
clearInterval(timer);
timer = null;
}
};
}
/** The current "My work", or null until it has been read (and always null when `enabled` is false: viewers have no work to follow). */
export function useMyWork(enabled = true): { work: MyWork | null; reload: () => void } {
const work = useSyncExternalStore(
(listener) => (enabled ? subscribe(listener) : () => {}),
() => (enabled ? current : null),
);
useEffect(() => {
if (enabled) refreshMyWork();
}, [enabled]);
return { work, reload: refreshMyWork };
}