A To do card on server pages and in a device's drawer

- The open jobs about a server (or device) are listed on its page, with a line to add another already about it and a box to tick one off with Undo
- GET /api/todos takes ?targetType=&targetId= to list only those about one thing
- README and ROLES updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 22:46:12 +02:00
1 parent 18ceed62e8
commit 788b3e073c
10 files changed
+164 -9

No files matched your search

+5 -2
View File
@@ -22,8 +22,11 @@ const fields = {
targetId: z.number().int().positive().nullable().optional(),
};
todosRouter.get("/", asyncHandler(async (_req, res) => {
res.json({ todos: await listTodos(), people: await assignableUsers() });
// `?targetType=server&targetId=3` lists only the jobs about that one (a server's page shows its own).
todosRouter.get("/", asyncHandler(async (req, res) => {
const type = TARGET_TYPES.find((t) => t === req.query.targetType);
const id = /^\d+$/.test(String(req.query.targetId ?? "")) ? Number(req.query.targetId) : NaN;
res.json({ todos: await listTodos(type && Number.isInteger(id) ? { type, id } : undefined), people: await assignableUsers() });
}));
todosRouter.post("/", requireRole("operator"), asyncHandler(async (req, res) => {