-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
87 lines (76 loc) · 2.6 KB
/
App.tsx
File metadata and controls
87 lines (76 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { useState } from 'react';
import { Header } from './components/Header';
import { CpuGraph } from './components/CpuGraph';
import { MemoryGraph } from './components/MemoryGraph';
import { ProcessTable } from './components/ProcessTable';
import { StatusBar } from './components/StatusBar';
import { AlertBar } from './components/AlertBar';
import { EnvironmentPanel } from './components/EnvironmentPanel';
import { useSystemMetrics } from './hooks/useSystemMetrics';
import './App.css';
function App() {
const [filter, setFilter] = useState('');
const [refreshRate, setRefreshRate] = useState(1000);
const { metrics, error, loading } = useSystemMetrics(refreshRate);
if (loading && !metrics) {
return (
<div className="app loading">
<div className="loading-container">
<div className="loading-spinner"></div>
<span className="loading-text">Connecting to btop server...</span>
<span className="loading-hint">Make sure the server is running: bun run server</span>
</div>
</div>
);
}
if (error && !metrics) {
return (
<div className="app error">
<div className="error-container">
<span className="error-icon">⚠</span>
<span className="error-text">Connection Error: {error}</span>
<span className="error-hint">
Start the server with: <code>bun run server</code>
</span>
</div>
</div>
);
}
if (!metrics) return null;
return (
<div className="app">
<Header
hostname={metrics.hostname}
platform={metrics.platform}
arch={metrics.arch}
uptime={metrics.uptime}
loadAvg={metrics.loadAvg}
processCount={metrics.processCount}
/>
<div className="metrics-panel">
<CpuGraph cpuUsage={metrics.cpuUsage} />
<MemoryGraph
used={metrics.usedMem}
total={metrics.totalMem}
percent={metrics.memPercent}
/>
</div>
<div className="process-section compact">
<div className="section-header">
<span className="section-title">Processes</span>
{error && <span className="connection-warning">(reconnecting...)</span>}
</div>
<ProcessTable processes={metrics.processes} filter={filter} />
</div>
<EnvironmentPanel filter={filter} />
<AlertBar cpuUsage={metrics.cpuUsage} memPercent={metrics.memPercent} />
<StatusBar
filter={filter}
onFilterChange={setFilter}
refreshRate={refreshRate}
onRefreshRateChange={setRefreshRate}
/>
</div>
);
}
export default App;