diff --git a/src/App.tsx b/src/App.tsx index 61e19fa..11739f3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,7 @@ import { } from 'recharts'; import { Activity, Cpu, Server, Database, Play, Square, - AlertTriangle, ArrowLeft, Shield, CheckSquare, Square as SquareIcon, Save, X + AlertTriangle, ArrowLeft, Shield, Save, X, Download } from 'lucide-react'; import { clsx } from 'clsx'; import { twMerge } from 'tailwind-merge'; @@ -70,7 +70,6 @@ function App() { const [view, setView] = useState<'dashboard' | 'report'>('dashboard'); const [stats, setStats] = useState(null); const [history, setHistory] = useState<{ time: string; cpu: number }[]>([]); - const [excludeSelf, setExcludeSelf] = useState(true); const [report, setReport] = useState(null); useEffect(() => { @@ -78,7 +77,7 @@ function App() { try { const isRecording = stats?.is_recording ?? false; const data = await invoke('get_system_stats', { - excludeSelf, + excludeSelf: true, minimal: isRecording || view === 'report' }); setStats(data); @@ -98,7 +97,7 @@ function App() { fetchStats(); const interval = setInterval(fetchStats, 1000); return () => clearInterval(interval); - }, [excludeSelf, view, stats?.is_recording]); + }, [view, stats?.is_recording]); const toggleRecording = async () => { if (stats?.is_recording) { @@ -110,6 +109,27 @@ function App() { } }; + const handleImport = (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (!file) return; + + const reader = new FileReader(); + reader.onload = (event) => { + try { + const data = JSON.parse(event.target?.result as string) as ProfilingReport; + if (data.aggregated_processes && data.timeline) { + setReport(data); + setView('report'); + } else { + alert('Invalid report format'); + } + } catch (err) { + alert('Failed to parse JSON'); + } + }; + reader.readAsText(file); + }; + const killProcess = async (pid: number) => { try { await invoke('run_as_admin', { command: `kill -9 ${pid}` }); @@ -127,7 +147,7 @@ function App() { ); } - if (!stats) return
Loading System Data...
; + if (!stats) return
Initializing SysPulse...
; const avgCpu = stats.cpu_usage.reduce((a, b) => a + b, 0) / stats.cpu_usage.length; const memoryPercent = (stats.used_memory / stats.total_memory) * 100; @@ -142,13 +162,12 @@ function App() { SysPulse
- + +