Add controller node selector and accordion wizards

This commit is contained in:
mmckeen
2026-04-28 15:40:25 +00:00
parent 38b651d460
commit 225b3c32bf
7 changed files with 429 additions and 23 deletions
+36
View File
@@ -0,0 +1,36 @@
import { NextResponse } from "next/server"
import { listControllerNodes, renameControllerNode, upsertControllerNode } from "@/app/lib/controllerNodeRegistry"
export async function GET() {
try {
return NextResponse.json({ nodes: await listControllerNodes() })
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to load controller nodes"
return NextResponse.json({ error: message }, { status: 500 })
}
}
export async function POST(request: Request) {
try {
const body = await request.json().catch(() => ({}))
const action = typeof body?.action === "string" ? body.action : "upsert"
if (action === "rename") {
const node = await renameControllerNode(String(body?.nodeId || ""), String(body?.name || ""))
return NextResponse.json({ node, nodes: await listControllerNodes() })
}
const node = await upsertControllerNode({
id: body?.id,
name: body?.name,
host: body?.host,
url: body?.url,
role: body?.role,
})
return NextResponse.json({ node, nodes: await listControllerNodes() })
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to update controller nodes"
return NextResponse.json({ error: message }, { status: 400 })
}
}