feat: Logs - einzelne Eintraege per Button aus DB und Uebersicht loeschbar
This commit is contained in:
@@ -570,4 +570,23 @@ router.get('/logs', authenticate, requireAdmin, (req, res) => {
|
||||
res.json(combined);
|
||||
});
|
||||
|
||||
// DELETE /logs/:id – einzelnen Log-Eintrag löschen (Admin). Die ID trägt ein
|
||||
// Präfix ("push-123" / "access-45"), damit klar ist, aus welcher Tabelle
|
||||
// gelöscht werden muss.
|
||||
router.delete('/logs/:id', authenticate, requireAdmin, (req, res) => {
|
||||
const raw = req.params.id;
|
||||
const [prefix, numStr] = raw.split('-');
|
||||
const numId = parseInt(numStr, 10);
|
||||
if (!numId) return res.status(400).json({ error: 'Ungültige ID' });
|
||||
|
||||
if (prefix === 'push') {
|
||||
db.prepare('DELETE FROM push_log WHERE id=?').run(numId);
|
||||
} else if (prefix === 'access') {
|
||||
db.prepare('DELETE FROM public_access_log WHERE id=?').run(numId);
|
||||
} else {
|
||||
return res.status(400).json({ error: 'Ungültige ID' });
|
||||
}
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user