Sortieren und Filtern wie in Excel in jeder Tabelle, Ansichten je Benutzer (0.13.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
@@ -36,4 +36,18 @@ export function registriereIch(app: FastifyInstance, pool: Pool, einstellungen:
|
||||
.map(({ start: _s, dauer: _d, ...v }) => v);
|
||||
return { heute, bis, arbeitstage: woche.tage, einsaetze };
|
||||
});
|
||||
|
||||
// Ansichten der Tabellen (Sortierung, Filter, ausgeblendete Zeilen, gespeicherte Ansichten), je Benutzer
|
||||
app.get("/api/ich/ansichten", async (req) => {
|
||||
const r = await pool.query("select tabelle, daten from ansicht where anmeldename = $1", [req.wer!.anmeldename]);
|
||||
return Object.fromEntries(r.rows.map((z) => [z.tabelle, z.daten]));
|
||||
});
|
||||
app.put("/api/ich/ansichten/:tabelle", async (req, reply) => {
|
||||
const { tabelle } = z.object({ tabelle: z.string().regex(/^[a-z0-9-]{1,40}$/) }).parse(req.params);
|
||||
const daten = z.record(z.string(), z.unknown()).parse(req.body);
|
||||
if (JSON.stringify(daten).length > 100_000) return reply.status(413).send({ fehler: "Die Ansicht ist zu groß." });
|
||||
await pool.query(`insert into ansicht (anmeldename, tabelle, daten) values ($1, $2, $3)
|
||||
on conflict (anmeldename, tabelle) do update set daten = excluded.daten, geaendert_am = now()`, [req.wer!.anmeldename, tabelle, daten]);
|
||||
return reply.status(204).send();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user