mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-10-03 00:26:18 +00:00
Update system-overview.tsx
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState, useEffect } from "react"
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
|
||||||
import { Progress } from "./ui/progress"
|
import { Progress } from "./ui/progress"
|
||||||
import { Badge } from "./ui/badge"
|
import { Badge } from "./ui/badge"
|
||||||
import { XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, AreaChart, Area } from "recharts"
|
import { XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, AreaChart, Area, Legend } from "recharts"
|
||||||
import { Cpu, MemoryStick, Thermometer, Activity, Server, Zap, AlertCircle } from "lucide-react"
|
import { Cpu, MemoryStick, Thermometer, Activity, Server, Zap, AlertCircle } from "lucide-react"
|
||||||
|
|
||||||
interface SystemData {
|
interface SystemData {
|
||||||
@@ -18,6 +18,7 @@ interface SystemData {
|
|||||||
hostname: string
|
hostname: string
|
||||||
node_id: string
|
node_id: string
|
||||||
timestamp: string
|
timestamp: string
|
||||||
|
cpu_cores?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VMData {
|
interface VMData {
|
||||||
@@ -41,7 +42,7 @@ interface HistoricalData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const historicalDataStore: HistoricalData[] = []
|
const historicalDataStore: HistoricalData[] = []
|
||||||
const MAX_HISTORICAL_POINTS = 24 // Store 24 data points for 24h view
|
const MAX_HISTORICAL_POINTS = 144 // Store 144 data points for 24h view
|
||||||
|
|
||||||
const fetchSystemData = async (): Promise<SystemData | null> => {
|
const fetchSystemData = async (): Promise<SystemData | null> => {
|
||||||
try {
|
try {
|
||||||
@@ -353,16 +354,16 @@ export function SystemOverview() {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-foreground flex items-center">
|
<CardTitle className="text-foreground flex items-center">
|
||||||
<Activity className="h-5 w-5 mr-2" />
|
<Activity className="h-5 w-5 mr-2" />
|
||||||
CPU Usage (Last {historicalDataStore.length} readings)
|
CPU Usage (Last 24h)
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{chartData.cpuData.length > 0 ? (
|
{chartData.cpuData.length > 0 ? (
|
||||||
<ResponsiveContainer width="100%" height={300}>
|
<ResponsiveContainer width="100%" height={300}>
|
||||||
<AreaChart data={chartData.cpuData}>
|
<AreaChart data={chartData.cpuData}>
|
||||||
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" />
|
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" opacity={0.3} />
|
||||||
<XAxis dataKey="time" stroke="hsl(var(--muted-foreground))" fontSize={12} />
|
<XAxis dataKey="time" stroke="hsl(var(--foreground))" fontSize={12} opacity={0.7} />
|
||||||
<YAxis stroke="hsl(var(--muted-foreground))" fontSize={12} />
|
<YAxis stroke="hsl(var(--foreground))" fontSize={12} opacity={0.7} />
|
||||||
<Tooltip
|
<Tooltip
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
backgroundColor: "hsl(var(--card))",
|
backgroundColor: "hsl(var(--card))",
|
||||||
@@ -370,8 +371,16 @@ export function SystemOverview() {
|
|||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
color: "hsl(var(--foreground))",
|
color: "hsl(var(--foreground))",
|
||||||
}}
|
}}
|
||||||
|
labelStyle={{ color: "hsl(var(--foreground))" }}
|
||||||
|
/>
|
||||||
|
<Area
|
||||||
|
type="monotone"
|
||||||
|
dataKey="value"
|
||||||
|
stroke="#60a5fa"
|
||||||
|
fill="#60a5fa"
|
||||||
|
fillOpacity={0.3}
|
||||||
|
name="CPU %"
|
||||||
/>
|
/>
|
||||||
<Area type="monotone" dataKey="value" stroke="#3b82f6" fill="#3b82f6" fillOpacity={0.2} />
|
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
) : (
|
) : (
|
||||||
@@ -386,16 +395,16 @@ export function SystemOverview() {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-foreground flex items-center">
|
<CardTitle className="text-foreground flex items-center">
|
||||||
<MemoryStick className="h-5 w-5 mr-2" />
|
<MemoryStick className="h-5 w-5 mr-2" />
|
||||||
Memory Usage (Last {historicalDataStore.length} readings)
|
Memory Usage (Last 24h)
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{chartData.memoryData.length > 0 ? (
|
{chartData.memoryData.length > 0 ? (
|
||||||
<ResponsiveContainer width="100%" height={300}>
|
<ResponsiveContainer width="100%" height={300}>
|
||||||
<AreaChart data={chartData.memoryData}>
|
<AreaChart data={chartData.memoryData}>
|
||||||
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" />
|
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" opacity={0.3} />
|
||||||
<XAxis dataKey="time" stroke="hsl(var(--muted-foreground))" fontSize={12} />
|
<XAxis dataKey="time" stroke="hsl(var(--foreground))" fontSize={12} opacity={0.7} />
|
||||||
<YAxis stroke="hsl(var(--muted-foreground))" fontSize={12} />
|
<YAxis stroke="hsl(var(--foreground))" fontSize={12} opacity={0.7} />
|
||||||
<Tooltip
|
<Tooltip
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
backgroundColor: "hsl(var(--card))",
|
backgroundColor: "hsl(var(--card))",
|
||||||
@@ -403,15 +412,26 @@ export function SystemOverview() {
|
|||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
color: "hsl(var(--foreground))",
|
color: "hsl(var(--foreground))",
|
||||||
}}
|
}}
|
||||||
|
labelStyle={{ color: "hsl(var(--foreground))" }}
|
||||||
|
/>
|
||||||
|
<Legend wrapperStyle={{ color: "hsl(var(--foreground))" }} iconType="square" />
|
||||||
|
<Area
|
||||||
|
type="monotone"
|
||||||
|
dataKey="used"
|
||||||
|
stackId="1"
|
||||||
|
stroke="#60a5fa"
|
||||||
|
fill="#60a5fa"
|
||||||
|
fillOpacity={0.6}
|
||||||
|
name="Used Memory (GB)"
|
||||||
/>
|
/>
|
||||||
<Area type="monotone" dataKey="used" stackId="1" stroke="#3b82f6" fill="#3b82f6" fillOpacity={0.6} />
|
|
||||||
<Area
|
<Area
|
||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey="available"
|
dataKey="available"
|
||||||
stackId="1"
|
stackId="1"
|
||||||
stroke="#10b981"
|
stroke="#34d399"
|
||||||
fill="#10b981"
|
fill="#34d399"
|
||||||
fillOpacity={0.6}
|
fillOpacity={0.6}
|
||||||
|
name="Available Memory (GB)"
|
||||||
/>
|
/>
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
@@ -434,22 +454,22 @@ export function SystemOverview() {
|
|||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3">
|
<CardContent className="space-y-3">
|
||||||
<div className="flex justify-between">
|
|
||||||
<span className="text-muted-foreground">Hostname:</span>
|
|
||||||
<span className="text-foreground font-mono">{systemData.hostname}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-muted-foreground">Uptime:</span>
|
<span className="text-muted-foreground">Uptime:</span>
|
||||||
<span className="text-foreground">{systemData.uptime}</span>
|
<span className="text-foreground">{systemData.uptime}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
|
||||||
<span className="text-muted-foreground">Node ID:</span>
|
|
||||||
<span className="text-foreground font-mono">{systemData.node_id}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-muted-foreground">Last Update:</span>
|
<span className="text-muted-foreground">Last Update:</span>
|
||||||
<span className="text-foreground">{new Date(systemData.timestamp).toLocaleTimeString()}</span>
|
<span className="text-foreground">{new Date(systemData.timestamp).toLocaleTimeString()}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-between">
|
||||||
|
<span className="text-muted-foreground">Proxmox Version:</span>
|
||||||
|
<span className="text-foreground">8.x</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-between">
|
||||||
|
<span className="text-muted-foreground">Kernel:</span>
|
||||||
|
<span className="text-foreground font-mono text-sm">Linux</span>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -461,8 +481,11 @@ export function SystemOverview() {
|
|||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3">
|
<CardContent className="space-y-3">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between items-start">
|
||||||
|
<div className="flex flex-col">
|
||||||
<span className="text-muted-foreground">Load Average:</span>
|
<span className="text-muted-foreground">Load Average:</span>
|
||||||
|
<span className="text-xs text-muted-foreground">(1m, 5m, 15m)</span>
|
||||||
|
</div>
|
||||||
<span className="text-foreground font-mono">
|
<span className="text-foreground font-mono">
|
||||||
{systemData.load_average.map((avg) => avg.toFixed(2)).join(", ")}
|
{systemData.load_average.map((avg) => avg.toFixed(2)).join(", ")}
|
||||||
</span>
|
</span>
|
||||||
@@ -479,7 +502,7 @@ export function SystemOverview() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-muted-foreground">CPU Cores:</span>
|
<span className="text-muted-foreground">CPU Cores:</span>
|
||||||
<span className="text-foreground">{navigator.hardwareConcurrency || "N/A"}</span>
|
<span className="text-foreground">{systemData.cpu_cores || "N/A"}</span>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
Reference in New Issue
Block a user