diff --git a/server/src/plugins/service-admin-http/routes-admin.ts b/server/src/plugins/service-admin-http/routes-admin.ts index 6ae7295..f2f7cfa 100644 --- a/server/src/plugins/service-admin-http/routes-admin.ts +++ b/server/src/plugins/service-admin-http/routes-admin.ts @@ -1434,6 +1434,38 @@ export function registerAdminRoutes(app: H3, deps: AdminDeps): void { return new Response(null, { status: 302, headers: { location: "/admin/cameras" } }); }); + // ---- Camera live event feed (htmx fragment, polled every 5s) --------------- + const formatTimeShort = (iso: string) => { + try { return new Date(iso).toLocaleString("en-GB", { hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit", day: "2-digit", month: "short" }); } + catch { return iso; } + }; + const escapeHtml = (s: string) => s.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """); + app.get("/admin/cameras/:id/events", (event) => { + const id = Number(getRouterParam(event, "id")); + const { events } = deps.repo.queryEvents({ + camera_id: id, + limit: 20, + }); + if (events.length === 0) { + return htmlFragment( + `
${escapeHtml(e.topic)}${escapeHtml(payload)}| Time | Topic | Source | Payload |
|---|
+ ONVIF events from kiosks subscribed to this camera. Auto-refreshes + every 5s. All topics shown — motion, ANPR, line crossing, I/O, analytics, unknown. +
+