diff --git a/backend/src/routes/admin.js b/backend/src/routes/admin.js index f9f9de8..92cf030 100644 --- a/backend/src/routes/admin.js +++ b/backend/src/routes/admin.js @@ -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; diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 5acfc1b..61bd6c9 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -3227,6 +3227,17 @@ function PushLogs({ toast }) { }; useEffect(() => { load(); }, []); + const deleteLog = async (id) => { + const prev = logs; + setLogs(l => l.filter(x => x.id !== id)); // optimistisch sofort entfernen + try { + await api(`/admin/logs/${id}`, { method:'DELETE' }); + } catch(e) { + setLogs(prev); // bei Fehler zurückrollen + toast?.(e.message||'Löschen fehlgeschlagen','error'); + } + }; + const fmtDate = iso => { if (!iso) return '—'; const d = new Date(iso.replace(' ', 'T')); @@ -3280,8 +3291,14 @@ function PushLogs({ toast }) { {PUBLIC_LINK_LABELS[l.linkType] || '🔗 Öffentlicher Link besucht'} - - {fmtDate(l.created_at)} + + + {fmtDate(l.created_at)} + +
copyPath(window.location.origin + l.path)} title={`${window.location.origin}${l.path} — antippen zum Kopieren`} @@ -3307,8 +3324,14 @@ function PushLogs({ toast }) { {l.username || `User #${l.user_id ?? '?'}`} - - {fmtDate(l.created_at)} + + + {fmtDate(l.created_at)} + +