diff --git a/src/lib/components/MonitorPanel.svelte b/src/lib/components/MonitorPanel.svelte index 8d20cc9..a4da24a 100644 --- a/src/lib/components/MonitorPanel.svelte +++ b/src/lib/components/MonitorPanel.svelte @@ -68,6 +68,42 @@ { value: 'error', label: '🔴 Fehler' }, { value: 'debug', label: '⚪ Debug' }, ]; + + // Export-Funktionen + function exportAsJson() { + const data = { + exportedAt: new Date().toISOString(), + filter: $monitorFilter, + stats: $monitorStats, + events: $filteredMonitorEvents.map(e => ({ + ...e, + timestamp: e.timestamp.toISOString() + })) + }; + downloadFile(JSON.stringify(data, null, 2), 'monitor-log.json', 'application/json'); + } + + function exportAsText() { + const lines = $filteredMonitorEvents.map(e => { + const time = formatTime(e.timestamp); + const type = typeLabels[e.type].padEnd(6); + const duration = e.durationMs ? `[${e.durationMs}ms]` : ''; + return `${time} ${monitorEventColors[e.type]} ${type} ${e.summary} ${duration}`.trim(); + }); + + const header = `Claude Desktop Monitor Log\nExportiert: ${new Date().toLocaleString('de-DE')}\nEvents: ${lines.length}\n${'─'.repeat(60)}\n\n`; + downloadFile(header + lines.join('\n'), 'monitor-log.txt', 'text/plain'); + } + + function downloadFile(content: string, filename: string, mimeType: string) { + const blob = new Blob([content], { type: mimeType }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); + }