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

+27 -1
View File
@@ -3,7 +3,7 @@ import { isIP } from "node:net";
import { and, eq, inArray } from "drizzle-orm";
import { z } from "zod";
import { db } from "../db/client.js";
import { ipamEntries, integrations, dnsRecordsCache } from "../db/schema.js";
import { ipamEntries, integrations, dnsRecordsCache, networkDevices } from "../db/schema.js";
import { requireAuth, requireRole } from "../auth/middleware.js";
import { recordAudit } from "../services/audit.js";
import { asyncHandler } from "../utils/asyncHandler.js";
@@ -290,6 +290,32 @@ ipamRouter.post("/sync-proxmox", requireRole("operator"), asyncHandler(async (re
res.json({ added, updated, skipped, skippedIps, errors });
}));
ipamRouter.post("/sync-unifi", requireRole("operator"), asyncHandler(async (req, res) => {
const controllers = await db.select({ id: integrations.id }).from(integrations).where(and(eq(integrations.type, "unifi"), eq(integrations.enabled, true)));
if (controllers.length === 0) {
return res.status(400).json({ error: "no_unifi_integration" });
}
let added = 0;
let updated = 0;
let skipped = 0;
const skippedIps: string[] = [];
// What was last read from the controllers (the page's own copy), not a new call: a device is as current as the Network devices page says.
for (const d of await db.select().from(networkDevices)) {
if (!d.ip) continue;
const kind = d.kind.replace("_", " ");
const notes = [`${kind}${d.model ? `, ${d.model}` : ""}`, d.mac ? `MAC ${d.mac}` : null].filter((v): v is string => !!v).join(" — ");
const result = await upsertSyncedEntry(d.ip, d.name, "UniFi", notes, d.siteName && d.siteName !== "Default" ? d.siteName : null, "unifi");
if (result === "added") added++;
else if (result === "updated") updated++;
else {
skipped++;
skippedIps.push(d.ip);
}
}
await recordAudit({ actor: req.currentUser!, category: "ipam", action: "sync_unifi", detail: { added, updated, skipped } });
res.json({ added, updated, skipped, skippedIps, errors: [] });
}));
ipamRouter.post("/sync-phpipam", requireRole("operator"), asyncHandler(async (req, res) => {
const phpIpamIntegrations = await db
.select()