Update AppImage

This commit is contained in:
MacRimi
2025-10-21 17:20:16 +02:00
parent b79f22f4fe
commit f20e46dee0
2 changed files with 169 additions and 210 deletions

View File

@@ -10,7 +10,6 @@ interface MetricsViewProps {
vmid: number vmid: number
vmName: string vmName: string
vmType: "qemu" | "lxc" vmType: "qemu" | "lxc"
metricType: "cpu" | "memory" | "network" | "disk"
onBack: () => void onBack: () => void
} }
@@ -22,14 +21,7 @@ const TIMEFRAME_OPTIONS = [
{ value: "year", label: "1 Year" }, { value: "year", label: "1 Year" },
] ]
const METRIC_TITLES = { export function MetricsView({ vmid, vmName, vmType, onBack }: MetricsViewProps) {
cpu: "CPU Usage",
memory: "Memory Usage",
network: "Network Traffic",
disk: "Disk I/O",
}
export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: MetricsViewProps) {
const [timeframe, setTimeframe] = useState("week") const [timeframe, setTimeframe] = useState("week")
const [data, setData] = useState<any[]>([]) const [data, setData] = useState<any[]>([])
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
@@ -61,23 +53,19 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
const date = new Date(item.time * 1000) const date = new Date(item.time * 1000)
let timeLabel = "" let timeLabel = ""
// Format time based on timeframe
if (timeframe === "hour") { if (timeframe === "hour") {
// For 1 hour: show HH:mm
timeLabel = date.toLocaleString("en-US", { timeLabel = date.toLocaleString("en-US", {
hour: "2-digit", hour: "2-digit",
minute: "2-digit", minute: "2-digit",
hour12: false, hour12: false,
}) })
} else if (timeframe === "day") { } else if (timeframe === "day") {
// For 24 hours: show HH:mm
timeLabel = date.toLocaleString("en-US", { timeLabel = date.toLocaleString("en-US", {
hour: "2-digit", hour: "2-digit",
minute: "2-digit", minute: "2-digit",
hour12: false, hour12: false,
}) })
} else if (timeframe === "week") { } else if (timeframe === "week") {
// For 7 days: show Mon DD HH:mm
timeLabel = date.toLocaleString("en-US", { timeLabel = date.toLocaleString("en-US", {
month: "short", month: "short",
day: "numeric", day: "numeric",
@@ -86,13 +74,11 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
hour12: false, hour12: false,
}) })
} else if (timeframe === "month") { } else if (timeframe === "month") {
// For 30 days: show Mon DD
timeLabel = date.toLocaleString("en-US", { timeLabel = date.toLocaleString("en-US", {
month: "short", month: "short",
day: "numeric", day: "numeric",
}) })
} else { } else {
// For 1 year: show Mon YYYY
timeLabel = date.toLocaleString("en-US", { timeLabel = date.toLocaleString("en-US", {
month: "short", month: "short",
year: "numeric", year: "numeric",
@@ -125,7 +111,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
return tick return tick
} }
const renderChart = () => { const renderAllCharts = () => {
if (loading) { if (loading) {
return ( return (
<div className="flex items-center justify-center h-[400px]"> <div className="flex items-center justify-center h-[400px]">
@@ -150,17 +136,15 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
) )
} }
// Calculate tick interval based on data length
const tickInterval = Math.ceil(data.length / 8) const tickInterval = Math.ceil(data.length / 8)
switch (metricType) { return (
case "cpu": <div className="space-y-8">
const maxCpuValue = Math.max(...data.map((d) => d.cpu || 0)) {/* CPU Chart */}
const cpuDomainMax = Math.ceil(maxCpuValue * 1.15) // 15% margin <div>
<h3 className="text-lg font-semibold mb-4">CPU Usage</h3>
return ( <ResponsiveContainer width="100%" height={300}>
<ResponsiveContainer width="100%" height={400}> <AreaChart data={data} margin={{ bottom: 80 }}>
<AreaChart data={data} margin={{ bottom: 100 }}>
<CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" /> <CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" />
<XAxis <XAxis
dataKey="time" dataKey="time"
@@ -169,7 +153,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
angle={-45} angle={-45}
textAnchor="end" textAnchor="end"
height={80} height={60}
interval={tickInterval} interval={tickInterval}
tickFormatter={formatXAxisTick} tickFormatter={formatXAxisTick}
/> />
@@ -178,8 +162,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
className="text-foreground" className="text-foreground"
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
label={{ value: "%", angle: -90, position: "insideLeft", fill: "currentColor" }} label={{ value: "%", angle: -90, position: "insideLeft", fill: "currentColor" }}
domain={[0, cpuDomainMax]} domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.15)]}
allowDataOverflow={false}
/> />
<Tooltip <Tooltip
contentStyle={{ contentStyle={{
@@ -188,7 +171,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
borderRadius: "6px", borderRadius: "6px",
}} }}
/> />
<Legend wrapperStyle={{ paddingTop: "20px" }} /> <Legend wrapperStyle={{ paddingTop: "10px" }} />
<Area <Area
type="monotone" type="monotone"
dataKey="cpu" dataKey="cpu"
@@ -200,15 +183,13 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
/> />
</AreaChart> </AreaChart>
</ResponsiveContainer> </ResponsiveContainer>
) </div>
case "memory": {/* Memory Chart */}
const maxMemoryValue = Math.max(...data.map((d) => d.memory || 0)) <div>
const memoryDomainMax = Math.ceil(maxMemoryValue * 1.15) // 15% margin <h3 className="text-lg font-semibold mb-4">Memory Usage</h3>
<ResponsiveContainer width="100%" height={300}>
return ( <AreaChart data={data} margin={{ bottom: 80 }}>
<ResponsiveContainer width="100%" height={400}>
<AreaChart data={data} margin={{ bottom: 100 }}>
<CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" /> <CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" />
<XAxis <XAxis
dataKey="time" dataKey="time"
@@ -217,7 +198,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
angle={-45} angle={-45}
textAnchor="end" textAnchor="end"
height={80} height={60}
interval={tickInterval} interval={tickInterval}
tickFormatter={formatXAxisTick} tickFormatter={formatXAxisTick}
/> />
@@ -226,8 +207,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
className="text-foreground" className="text-foreground"
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
label={{ value: "%", angle: -90, position: "insideLeft", fill: "currentColor" }} label={{ value: "%", angle: -90, position: "insideLeft", fill: "currentColor" }}
domain={[0, memoryDomainMax]} domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.15)]}
allowDataOverflow={false}
/> />
<Tooltip <Tooltip
contentStyle={{ contentStyle={{
@@ -236,7 +216,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
borderRadius: "6px", borderRadius: "6px",
}} }}
/> />
<Legend wrapperStyle={{ paddingTop: "20px" }} /> <Legend wrapperStyle={{ paddingTop: "10px" }} />
<Area <Area
type="monotone" type="monotone"
dataKey="memory" dataKey="memory"
@@ -248,15 +228,13 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
/> />
</AreaChart> </AreaChart>
</ResponsiveContainer> </ResponsiveContainer>
) </div>
case "network": {/* Disk I/O Chart */}
const maxNetworkValue = Math.max(...data.map((d) => Math.max(d.netin || 0, d.netout || 0))) <div>
const networkDomainMax = Math.ceil(maxNetworkValue * 1.15) // 15% margin <h3 className="text-lg font-semibold mb-4">Disk I/O</h3>
<ResponsiveContainer width="100%" height={300}>
return ( <AreaChart data={data} margin={{ bottom: 80 }}>
<ResponsiveContainer width="100%" height={400}>
<AreaChart data={data} margin={{ bottom: 100 }}>
<CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" /> <CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" />
<XAxis <XAxis
dataKey="time" dataKey="time"
@@ -265,7 +243,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
angle={-45} angle={-45}
textAnchor="end" textAnchor="end"
height={80} height={60}
interval={tickInterval} interval={tickInterval}
tickFormatter={formatXAxisTick} tickFormatter={formatXAxisTick}
/> />
@@ -274,8 +252,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
className="text-foreground" className="text-foreground"
tick={{ fill: "currentColor" }} tick={{ fill: "currentColor" }}
label={{ value: "MB", angle: -90, position: "insideLeft", fill: "currentColor" }} label={{ value: "MB", angle: -90, position: "insideLeft", fill: "currentColor" }}
domain={[0, networkDomainMax]} domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.15)]}
allowDataOverflow={false}
/> />
<Tooltip <Tooltip
contentStyle={{ contentStyle={{
@@ -284,64 +261,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
borderRadius: "6px", borderRadius: "6px",
}} }}
/> />
<Legend wrapperStyle={{ paddingTop: "20px" }} /> <Legend wrapperStyle={{ paddingTop: "10px" }} />
<Area
type="monotone"
dataKey="netin"
stroke="#10b981"
fill="#10b981"
fillOpacity={0.3}
strokeWidth={2}
name="Download (MB)"
/>
<Area
type="monotone"
dataKey="netout"
stroke="#3b82f6"
fill="#3b82f6"
fillOpacity={0.3}
strokeWidth={2}
name="Upload (MB)"
/>
</AreaChart>
</ResponsiveContainer>
)
case "disk":
const maxDiskValue = Math.max(...data.map((d) => Math.max(d.diskread || 0, d.diskwrite || 0)))
const diskDomainMax = Math.ceil(maxDiskValue * 1.15) // 15% margin
return (
<ResponsiveContainer width="100%" height={400}>
<AreaChart data={data} margin={{ bottom: 100 }}>
<CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" />
<XAxis
dataKey="time"
stroke="currentColor"
className="text-foreground"
tick={{ fill: "currentColor" }}
angle={-45}
textAnchor="end"
height={80}
interval={tickInterval}
tickFormatter={formatXAxisTick}
/>
<YAxis
stroke="currentColor"
className="text-foreground"
tick={{ fill: "currentColor" }}
label={{ value: "MB", angle: -90, position: "insideLeft", fill: "currentColor" }}
domain={[0, diskDomainMax]}
allowDataOverflow={false}
/>
<Tooltip
contentStyle={{
backgroundColor: "hsl(var(--background))",
border: "1px solid hsl(var(--border))",
borderRadius: "6px",
}}
/>
<Legend wrapperStyle={{ paddingTop: "20px" }} />
<Area <Area
type="monotone" type="monotone"
dataKey="diskread" dataKey="diskread"
@@ -362,11 +282,63 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
/> />
</AreaChart> </AreaChart>
</ResponsiveContainer> </ResponsiveContainer>
) </div>
default: {/* Network I/O Chart */}
return null <div>
} <h3 className="text-lg font-semibold mb-4">Network I/O</h3>
<ResponsiveContainer width="100%" height={300}>
<AreaChart data={data} margin={{ bottom: 80 }}>
<CartesianGrid strokeDasharray="3 3" stroke="currentColor" className="text-border" />
<XAxis
dataKey="time"
stroke="currentColor"
className="text-foreground"
tick={{ fill: "currentColor" }}
angle={-45}
textAnchor="end"
height={60}
interval={tickInterval}
tickFormatter={formatXAxisTick}
/>
<YAxis
stroke="currentColor"
className="text-foreground"
tick={{ fill: "currentColor" }}
label={{ value: "MB", angle: -90, position: "insideLeft", fill: "currentColor" }}
domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.15)]}
/>
<Tooltip
contentStyle={{
backgroundColor: "hsl(var(--background))",
border: "1px solid hsl(var(--border))",
borderRadius: "6px",
}}
/>
<Legend wrapperStyle={{ paddingTop: "10px" }} />
<Area
type="monotone"
dataKey="netin"
stroke="#10b981"
fill="#10b981"
fillOpacity={0.3}
strokeWidth={2}
name="Download (MB)"
/>
<Area
type="monotone"
dataKey="netout"
stroke="#3b82f6"
fill="#3b82f6"
fillOpacity={0.3}
strokeWidth={2}
name="Upload (MB)"
/>
</AreaChart>
</ResponsiveContainer>
</div>
</div>
)
} }
return ( return (
@@ -379,9 +351,7 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
<ArrowLeft className="h-5 w-5" /> <ArrowLeft className="h-5 w-5" />
</Button> </Button>
<div> <div>
<h2 className="text-xl font-semibold"> <h2 className="text-xl font-semibold">Metrics - {vmName}</h2>
{METRIC_TITLES[metricType]} - {vmName}
</h2>
<p className="text-sm text-muted-foreground mt-1"> <p className="text-sm text-muted-foreground mt-1">
VMID: {vmid} Type: {vmType.toUpperCase()} VMID: {vmid} Type: {vmType.toUpperCase()}
</p> </p>
@@ -402,8 +372,8 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric
</div> </div>
</div> </div>
{/* Scrollable Content */} {/* Scrollable Content with all charts */}
<div className="flex-1 overflow-y-auto p-6">{renderChart()}</div> <div className="flex-1 overflow-y-auto p-6">{renderAllCharts()}</div>
</div> </div>
) )
} }

View File

@@ -1,5 +1,7 @@
"use client" "use client"
import type React from "react"
import { useState, useMemo, useEffect } from "react" import { useState, useMemo, useEffect } from "react"
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card" import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
import { Badge } from "./ui/badge" import { Badge } from "./ui/badge"
@@ -170,6 +172,30 @@ const getModalProgressColor = (percent: number): string => {
return "[&>div]:bg-blue-500" return "[&>div]:bg-blue-500"
} }
// Placeholder for the undeclared getOSIcon function
const getOSIcon = (ostype: string | undefined, vmType: string): React.ReactNode => {
if (vmType === "lxc") {
return <Container className="h-16 w-16 text-cyan-500" />
}
switch (ostype) {
case "debian":
return <img src="/icons/debian.svg" alt="Debian" className="h-16 w-16" />
case "ubuntu":
return <img src="/icons/ubuntu.svg" alt="Ubuntu" className="h-16 w-16" />
case "centos":
return <img src="/icons/centos.svg" alt="CentOS" className="h-16 w-16" />
case "fedora":
return <img src="/icons/fedora.svg" alt="Fedora" className="h-16 w-16" />
case "windows":
return <img src="/icons/windows.svg" alt="Windows" className="h-16 w-16" />
case "alpine":
return <img src="/icons/alpine.svg" alt="Alpine" className="h-16 w-16" />
default:
return <Server className="h-16 w-16 text-purple-500" />
}
}
export function VirtualMachines() { export function VirtualMachines() {
const { const {
data: vmData, data: vmData,
@@ -188,8 +214,8 @@ export function VirtualMachines() {
const [detailsLoading, setDetailsLoading] = useState(false) const [detailsLoading, setDetailsLoading] = useState(false)
const [vmConfigs, setVmConfigs] = useState<Record<number, string>>({}) const [vmConfigs, setVmConfigs] = useState<Record<number, string>>({})
const [currentView, setCurrentView] = useState<"main" | "metrics">("main") const [currentView, setCurrentView] = useState<"main" | "metrics">("main")
const [selectedMetric, setSelectedMetric] = useState<"cpu" | "memory" | "disk" | "network" | null>(null)
const [showAdditionalInfo, setShowAdditionalInfo] = useState(false) const [showAdditionalInfo, setShowAdditionalInfo] = useState(false)
const [selectedMetric, setSelectedMetric] = useState<string | null>(null) // undeclared variable fix
useEffect(() => { useEffect(() => {
const fetchLXCIPs = async () => { const fetchLXCIPs = async () => {
@@ -223,7 +249,6 @@ export function VirtualMachines() {
const handleVMClick = async (vm: VMData) => { const handleVMClick = async (vm: VMData) => {
setSelectedVM(vm) setSelectedVM(vm)
setCurrentView("main") setCurrentView("main")
setSelectedMetric(null)
setShowAdditionalInfo(false) setShowAdditionalInfo(false)
setDetailsLoading(true) setDetailsLoading(true)
try { try {
@@ -239,14 +264,12 @@ export function VirtualMachines() {
} }
} }
const handleMetricClick = (metric: "cpu" | "memory" | "disk" | "network") => { const handleMetricsClick = () => {
setSelectedMetric(metric)
setCurrentView("metrics") setCurrentView("metrics")
} }
const handleBackToMain = () => { const handleBackToMain = () => {
setCurrentView("main") setCurrentView("main")
setSelectedMetric(null)
} }
const handleVMControl = async (vmid: number, action: string) => { const handleVMControl = async (vmid: number, action: string) => {
@@ -562,7 +585,7 @@ export function VirtualMachines() {
<div <div
className="cursor-pointer hover:opacity-80 transition-opacity" className="cursor-pointer hover:opacity-80 transition-opacity"
onClick={() => { onClick={() => {
setSelectedMetric("cpu") setSelectedMetric("cpu") // undeclared variable fix
}} }}
> >
<div <div
@@ -789,112 +812,79 @@ export function VirtualMachines() {
<h3 className="text-sm font-semibold text-muted-foreground mb-3 uppercase tracking-wide"> <h3 className="text-sm font-semibold text-muted-foreground mb-3 uppercase tracking-wide">
Basic Information Basic Information
</h3> </h3>
<div className="grid grid-cols-2 lg:grid-cols-3 gap-3"> <Card
{/* CPU Usage Card */} className="border border-border bg-card/50 cursor-pointer hover:bg-card/70 transition-colors"
<Card className="border border-border bg-card/50"> onClick={handleMetricsClick}
<CardContent className="p-3"> >
<div className="text-xs text-muted-foreground mb-2">CPU Usage</div> <CardContent className="p-4">
<div <div className="grid grid-cols-2 lg:grid-cols-3 gap-4">
className="cursor-pointer hover:opacity-80 transition-opacity" {/* CPU Usage */}
onClick={() => handleMetricClick("cpu")} <div>
> <div className="text-xs text-muted-foreground mb-2">CPU Usage</div>
<div className={`font-semibold mb-2 ${getUsageColor(selectedVM.cpu * 100)}`}> <div className={`text-2xl font-semibold mb-2 ${getUsageColor(selectedVM.cpu * 100)}`}>
{(selectedVM.cpu * 100).toFixed(1)}% {(selectedVM.cpu * 100).toFixed(1)}%
</div> </div>
<Progress <Progress
value={selectedVM.cpu * 100} value={selectedVM.cpu * 100}
className={`h-1.5 ${getModalProgressColor(selectedVM.cpu * 100)}`} className={`h-2 ${getModalProgressColor(selectedVM.cpu * 100)}`}
/> />
</div> </div>
</CardContent>
</Card>
{/* Memory Card */} {/* Memory */}
<Card className="border border-border bg-card/50"> <div>
<CardContent className="p-3"> <div className="text-xs text-muted-foreground mb-2">Memory</div>
<div className="text-xs text-muted-foreground mb-2">Memory</div>
<div
className="cursor-pointer hover:opacity-80 transition-opacity"
onClick={() => handleMetricClick("memory")}
>
<div <div
className={`font-semibold mb-2 ${getUsageColor((selectedVM.mem / selectedVM.maxmem) * 100)}`} className={`text-2xl font-semibold mb-2 ${getUsageColor((selectedVM.mem / selectedVM.maxmem) * 100)}`}
> >
{(selectedVM.mem / 1024 ** 3).toFixed(1)} /{" "} {(selectedVM.mem / 1024 ** 3).toFixed(1)} /{" "}
{(selectedVM.maxmem / 1024 ** 3).toFixed(1)} GB {(selectedVM.maxmem / 1024 ** 3).toFixed(1)} GB
</div> </div>
<Progress <Progress
value={(selectedVM.mem / selectedVM.maxmem) * 100} value={(selectedVM.mem / selectedVM.maxmem) * 100}
className={`h-1.5 ${getModalProgressColor((selectedVM.mem / selectedVM.maxmem) * 100)}`} className={`h-2 ${getModalProgressColor((selectedVM.mem / selectedVM.maxmem) * 100)}`}
/> />
</div> </div>
</CardContent>
</Card>
{/* Disk Card */} {/* Disk I/O */}
<Card className="border border-border bg-card/50"> <div>
<CardContent className="p-3"> <div className="text-xs text-muted-foreground mb-2">Disk I/O</div>
<div className="text-xs text-muted-foreground mb-2">Disk</div> <div className="space-y-1">
<div <div className="text-sm text-green-500 flex items-center gap-1">
className="cursor-pointer hover:opacity-80 transition-opacity" <span></span>
onClick={() => handleMetricClick("disk")} <span>{((selectedVM.diskread || 0) / 1024 ** 2).toFixed(2)} MB</span>
> </div>
<div <div className="text-sm text-blue-500 flex items-center gap-1">
className={`font-semibold mb-2 ${getUsageColor((selectedVM.disk / selectedVM.maxdisk) * 100)}`} <span></span>
> <span>{((selectedVM.diskwrite || 0) / 1024 ** 2).toFixed(2)} MB</span>
{(selectedVM.disk / 1024 ** 3).toFixed(1)} /{" "} </div>
{(selectedVM.maxdisk / 1024 ** 3).toFixed(1)} GB
</div>
<Progress
value={(selectedVM.disk / selectedVM.maxdisk) * 100}
className={`h-1.5 ${getModalProgressColor((selectedVM.disk / selectedVM.maxdisk) * 100)}`}
/>
</div>
</CardContent>
</Card>
{/* Disk I/O Card */}
<Card className="border border-border bg-card/50">
<CardContent className="p-3">
<div className="text-xs text-muted-foreground mb-2">Disk I/O</div>
<div
className="cursor-pointer hover:opacity-80 transition-opacity"
onClick={() => handleMetricClick("disk")}
>
<div className="text-sm text-green-500 flex items-center gap-1 mb-1">
<span></span>
<span>{((selectedVM.diskread || 0) / 1024 ** 2).toFixed(2)} MB</span>
</div>
<div className="text-sm text-blue-500 flex items-center gap-1">
<span></span>
<span>{((selectedVM.diskwrite || 0) / 1024 ** 2).toFixed(2)} MB</span>
</div> </div>
</div> </div>
</CardContent>
</Card>
{/* Network I/O Card */} {/* Network I/O */}
<Card className="border border-border bg-card/50"> <div>
<CardContent className="p-3"> <div className="text-xs text-muted-foreground mb-2">Network I/O</div>
<div className="text-xs text-muted-foreground mb-2">Network I/O</div> <div className="space-y-1">
<div <div className="text-sm text-green-500 flex items-center gap-1">
className="cursor-pointer hover:opacity-80 transition-opacity" <span></span>
onClick={() => handleMetricClick("network")} <span>{((selectedVM.netin || 0) / 1024 ** 2).toFixed(2)} MB</span>
> </div>
<div className="text-sm text-green-500 flex items-center gap-1 mb-1"> <div className="text-sm text-blue-500 flex items-center gap-1">
<span></span> <span></span>
<span>{((selectedVM.netin || 0) / 1024 ** 2).toFixed(2)} MB</span> <span>{((selectedVM.netout || 0) / 1024 ** 2).toFixed(2)} MB</span>
</div> </div>
<div className="text-sm text-blue-500 flex items-center gap-1">
<span></span>
<span>{((selectedVM.netout || 0) / 1024 ** 2).toFixed(2)} MB</span>
</div> </div>
</div> </div>
</CardContent>
</Card> {/* OS Icon / VM Icon */}
</div> <div className="flex items-center justify-center col-span-2 lg:col-span-1">
{getOSIcon(vmDetails?.config?.ostype, selectedVM.type)} {/* undeclared variable fix */}
</div>
</div>
</CardContent>
</Card>
</div> </div>
{/* ... existing RESOURCES card and additional info ... */}
{detailsLoading ? ( {detailsLoading ? (
<div className="text-center py-8 text-muted-foreground">Loading configuration...</div> <div className="text-center py-8 text-muted-foreground">Loading configuration...</div>
) : vmDetails?.config ? ( ) : vmDetails?.config ? (
@@ -1140,13 +1130,12 @@ export function VirtualMachines() {
</div> </div>
</> </>
) : ( ) : (
selectedVM && selectedVM && (
selectedMetric && ( // Pass only vmid, vmName, vmType and onBack
<MetricsView <MetricsView
vmid={selectedVM.vmid} vmid={selectedVM.vmid}
vmName={selectedVM.name} vmName={selectedVM.name}
vmType={selectedVM.type as "qemu" | "lxc"} vmType={selectedVM.type as "qemu" | "lxc"}
metricType={selectedMetric}
onBack={handleBackToMain} onBack={handleBackToMain}
/> />
) )