feat: Server-Konsolen-Mitschnitt (24h, wie docker logs) als Download im Logs-Bereich

This commit is contained in:
2026-07-18 17:04:13 +02:00
parent 6209c38a83
commit 8419a02e00
4 changed files with 91 additions and 0 deletions

View File

@@ -3238,6 +3238,21 @@ function PushLogs({ toast }) {
}
};
const downloadConsoleLog = async () => {
try {
const tokenVal = localStorage.getItem('sk_token');
const res = await fetch('/api/admin/console-log/download', { headers: { Authorization: `Bearer ${tokenVal}` } });
if (!res.ok) { const d = await res.json().catch(()=>({})); throw new Error(d.error || 'Fehler'); }
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `dickendock-console-${new Date().toISOString().slice(0,10)}.log`;
document.body.appendChild(a); a.click(); document.body.removeChild(a);
URL.revokeObjectURL(url);
} catch(e) { toast?.(e.message||'Fehler','error'); }
};
const fmtDate = iso => {
if (!iso) return '—';
const d = new Date(iso.replace(' ', 'T'));
@@ -3263,11 +3278,18 @@ function PushLogs({ toast }) {
return (
<div>
<Sec title={`LOGS (${filtered.length})`}>
<div style={{ ...S.sub, marginBottom:10 }}>
Live-Mitschnitt der Server-Konsole (wie <code>docker logs -f dickendock</code>), letzte 24 Stunden danach
werden ältere Zeilen automatisch überschrieben.
</div>
<div style={{ display:'flex', gap:8, marginBottom:8, flexWrap:'wrap' }}>
<select value={typeFilter} onChange={e=>setTypeFilter(e.target.value)}
style={{ ...S.inp, flex:'1 1 200px' }}>
{LOG_TYPE_OPTIONS.map(([id,label]) => <option key={id} value={id}>{label}</option>)}
</select>
<button onClick={downloadConsoleLog} style={{ ...S.btn('#4ecdc4'), flexShrink:0, whiteSpace:'nowrap' }}>
Server-Konsole (24h)
</button>
</div>
<div style={{ display:'flex', gap:8, marginBottom:12 }}>
<input value={filter} onChange={e=>setFilter(e.target.value)}