Update AppImage

This commit is contained in:
MacRimi
2025-10-05 15:54:24 +02:00
parent 7297edf16f
commit 497814f80c
2 changed files with 287 additions and 256 deletions

View File

@@ -4,7 +4,7 @@ import { useState } 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"
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "./ui/dialog" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "./ui/dialog"
import { Wifi, Activity, Network, Router, AlertCircle, Zap, Shield } from "lucide-react" import { Wifi, Activity, Network, Router, AlertCircle, Zap } from "lucide-react"
import useSWR from "swr" import useSWR from "swr"
interface NetworkData { interface NetworkData {
@@ -214,36 +214,6 @@ export function NetworkMetrics() {
</CardContent> </CardContent>
</Card> </Card>
<Card className="bg-card border-border">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Firewall Status</CardTitle>
<Shield className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-foreground">Active</div>
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20 mt-2">
Protected
</Badge>
<p className="text-xs text-muted-foreground mt-2">System protected</p>
</CardContent>
</Card>
<Card className="bg-card border-border">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">Packets</CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-foreground">{packetsRecvK}K</div>
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20 mt-2">
Received
</Badge>
<p className="text-xs text-muted-foreground mt-2">No packet loss</p>
</CardContent>
</Card>
</div>
{networkData.physical_interfaces && networkData.physical_interfaces.length > 0 && (
<Card className="bg-card border-border"> <Card className="bg-card border-border">
<CardHeader> <CardHeader>
<CardTitle className="text-foreground flex items-center"> <CardTitle className="text-foreground flex items-center">
@@ -268,7 +238,7 @@ export function NetworkMetrics() {
{/* First row: Icon, Name, Type Badge, Status */} {/* First row: Icon, Name, Type Badge, Status */}
<div className="flex items-center gap-3 flex-wrap"> <div className="flex items-center gap-3 flex-wrap">
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" /> <Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
<div className="flex items-center gap-2 min-w-0 flex-1"> <div className="flex items-center gap-2 min-w-0 flex-1 flex-wrap">
<div className="font-medium text-foreground">{interface_.name}</div> <div className="font-medium text-foreground">{interface_.name}</div>
<Badge variant="outline" className={typeBadge.color}> <Badge variant="outline" className={typeBadge.color}>
{typeBadge.label} {typeBadge.label}
@@ -327,208 +297,208 @@ export function NetworkMetrics() {
</div> </div>
</CardContent> </CardContent>
</Card> </Card>
)}
{networkData.bridge_interfaces && networkData.bridge_interfaces.length > 0 && ( {networkData.bridge_interfaces && networkData.bridge_interfaces.length > 0 && (
<Card className="bg-card border-border"> <Card className="bg-card border-border">
<CardHeader> <CardHeader>
<CardTitle className="text-foreground flex items-center"> <CardTitle className="text-foreground flex items-center">
<Network className="h-5 w-5 mr-2" /> <Network className="h-5 w-5 mr-2" />
Bridge Interfaces Bridge Interfaces
<Badge variant="outline" className="ml-3 bg-green-500/10 text-green-500 border-green-500/20"> <Badge variant="outline" className="ml-3 bg-green-500/10 text-green-500 border-green-500/20">
{networkData.bridge_active_count ?? 0} / {networkData.bridge_total_count ?? 0} Active {networkData.bridge_active_count ?? 0} / {networkData.bridge_total_count ?? 0} Active
</Badge> </Badge>
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="space-y-4"> <div className="space-y-4">
{networkData.bridge_interfaces.map((interface_, index) => { {networkData.bridge_interfaces.map((interface_, index) => {
const typeBadge = getInterfaceTypeBadge(interface_.type) const typeBadge = getInterfaceTypeBadge(interface_.type)
return ( return (
<div <div
key={index} key={index}
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer" className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
onClick={() => setSelectedInterface(interface_)} onClick={() => setSelectedInterface(interface_)}
> >
{/* First row: Icon, Name, Type Badge, Physical Interface, Status */} {/* First row: Icon, Name, Type Badge, Physical Interface, Status */}
<div className="flex items-center gap-3 flex-wrap"> <div className="flex items-center gap-3 flex-wrap">
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" /> <Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
<div className="flex items-center gap-2 min-w-0 flex-1"> <div className="flex items-center gap-2 min-w-0 flex-1 flex-wrap">
<div className="font-medium text-foreground">{interface_.name}</div> <div className="font-medium text-foreground">{interface_.name}</div>
<Badge variant="outline" className={typeBadge.color}> <Badge variant="outline" className={typeBadge.color}>
{typeBadge.label} {typeBadge.label}
</Badge> </Badge>
{interface_.bridge_physical_interface && ( {interface_.bridge_physical_interface && (
<div className="text-sm text-blue-500 font-medium flex items-center gap-1 flex-wrap"> <div className="text-sm text-blue-500 font-medium flex items-center gap-1 flex-wrap">
{interface_.bridge_physical_interface} {interface_.bridge_physical_interface}
{interface_.bridge_physical_interface.startsWith("bond") && {interface_.bridge_physical_interface.startsWith("bond") &&
networkData.physical_interfaces && ( networkData.physical_interfaces && (
<> <>
{(() => { {(() => {
const bondInterface = networkData.physical_interfaces.find( const bondInterface = networkData.physical_interfaces.find(
(iface) => iface.name === interface_.bridge_physical_interface, (iface) => iface.name === interface_.bridge_physical_interface,
)
if (bondInterface?.bond_slaves && bondInterface.bond_slaves.length > 0) {
return (
<span className="text-muted-foreground text-xs">
({bondInterface.bond_slaves.join(", ")})
</span>
) )
} if (bondInterface?.bond_slaves && bondInterface.bond_slaves.length > 0) {
return null return (
})()} <span className="text-muted-foreground text-xs break-all">
</> ({bondInterface.bond_slaves.join(", ")})
</span>
)
}
return null
})()}
</>
)}
{interface_.bridge_bond_slaves && interface_.bridge_bond_slaves.length > 0 && (
<span className="text-muted-foreground text-xs break-all">
({interface_.bridge_bond_slaves.join(", ")})
</span>
)} )}
{interface_.bridge_bond_slaves && interface_.bridge_bond_slaves.length > 0 && ( </div>
<span className="text-muted-foreground text-xs"> )}
({interface_.bridge_bond_slaves.join(", ")})
</span>
)}
</div>
)}
</div>
<Badge
variant="outline"
className={
interface_.status === "up"
? "bg-green-500/10 text-green-500 border-green-500/20"
: "bg-red-500/10 text-red-500 border-red-500/20"
}
>
{interface_.status.toUpperCase()}
</Badge>
</div>
{/* Second row: Details - Responsive layout */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div>
<div className="text-muted-foreground text-xs">IP Address</div>
<div className="font-medium text-foreground font-mono text-sm truncate">
{interface_.addresses.length > 0 ? interface_.addresses[0].ip : "N/A"}
</div> </div>
</div> <Badge
variant="outline"
<div> className={
<div className="text-muted-foreground text-xs">Speed</div> interface_.status === "up"
<div className="font-medium text-foreground flex items-center gap-1"> ? "bg-green-500/10 text-green-500 border-green-500/20"
<Zap className="h-3 w-3" /> : "bg-red-500/10 text-red-500 border-red-500/20"
{formatSpeed(interface_.speed)} }
</div> >
</div> {interface_.status.toUpperCase()}
<div className="col-span-2 md:col-span-1">
<div className="text-muted-foreground text-xs">Traffic</div>
<div className="font-medium text-foreground text-xs">
<span className="text-green-500"> {formatBytes(interface_.bytes_recv)}</span>
{" / "}
<span className="text-blue-500"> {formatBytes(interface_.bytes_sent)}</span>
</div>
</div>
{interface_.mac_address && (
<div className="col-span-2 md:col-span-1">
<div className="text-muted-foreground text-xs">MAC</div>
<div className="font-medium text-foreground font-mono text-xs truncate">
{interface_.mac_address}
</div>
</div>
)}
</div>
</div>
)
})}
</div>
</CardContent>
</Card>
)}
{networkData.vm_lxc_interfaces && networkData.vm_lxc_interfaces.length > 0 && (
<Card className="bg-card border-border">
<CardHeader>
<CardTitle className="text-foreground flex items-center">
<Network className="h-5 w-5 mr-2" />
VM & LXC Network Interfaces
<Badge variant="outline" className="ml-3 bg-orange-500/10 text-orange-500 border-orange-500/20">
{networkData.vm_lxc_active_count ?? 0} / {networkData.vm_lxc_total_count ?? 0} Active
</Badge>
</CardTitle>
</CardHeader>
<CardContent>
<div className="space-y-4">
{networkData.vm_lxc_interfaces.map((interface_, index) => {
const vmTypeBadge = getVMTypeBadge(interface_.vm_type)
return (
<div
key={index}
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
onClick={() => setSelectedInterface(interface_)}
>
{/* First row: Icon, Name, VM/LXC Badge, VM Name, Status */}
<div className="flex items-center gap-3 flex-wrap">
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
<div className="flex items-center gap-2 min-w-0 flex-1">
<div className="font-medium text-foreground">{interface_.name}</div>
<Badge variant="outline" className={vmTypeBadge.color}>
{vmTypeBadge.label}
</Badge> </Badge>
{interface_.vm_name && (
<div className="text-sm text-muted-foreground truncate"> {interface_.vm_name}</div>
)}
</div>
<Badge
variant="outline"
className={
interface_.status === "up"
? "bg-green-500/10 text-green-500 border-green-500/20"
: "bg-red-500/10 text-red-500 border-red-500/20"
}
>
{interface_.status.toUpperCase()}
</Badge>
</div>
{/* Second row: Details - Responsive layout */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div>
<div className="text-sm text-muted-foreground">VMID</div>
<div className="font-medium">{interface_.vmid ?? "N/A"}</div>
</div> </div>
<div> {/* Second row: Details - Responsive layout */}
<div className="text-sm text-muted-foreground">Speed</div> <div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div className="font-medium text-foreground flex items-center gap-1"> <div>
<Zap className="h-3 w-3" /> <div className="text-muted-foreground text-xs">IP Address</div>
{formatSpeed(interface_.speed)} <div className="font-medium text-foreground font-mono text-sm truncate">
</div> {interface_.addresses.length > 0 ? interface_.addresses[0].ip : "N/A"}
</div>
<div className="col-span-2 md:col-span-1">
<div className="text-sm text-muted-foreground">Traffic</div>
<div className="font-medium text-foreground text-xs">
<span className="text-green-500"> {formatBytes(interface_.bytes_recv)}</span>
{" / "}
<span className="text-blue-500"> {formatBytes(interface_.bytes_sent)}</span>
</div>
</div>
{interface_.mac_address && (
<div className="col-span-2 md:col-span-1">
<div className="text-sm text-muted-foreground">MAC</div>
<div className="font-medium text-foreground font-mono text-xs truncate">
{interface_.mac_address}
</div> </div>
</div> </div>
)}
<div>
<div className="text-muted-foreground text-xs">Speed</div>
<div className="font-medium text-foreground flex items-center gap-1">
<Zap className="h-3 w-3" />
{formatSpeed(interface_.speed)}
</div>
</div>
<div className="col-span-2 md:col-span-1">
<div className="text-muted-foreground text-xs">Traffic</div>
<div className="font-medium text-foreground text-xs">
<span className="text-green-500"> {formatBytes(interface_.bytes_recv)}</span>
{" / "}
<span className="text-blue-500"> {formatBytes(interface_.bytes_sent)}</span>
</div>
</div>
{interface_.mac_address && (
<div className="col-span-2 md:col-span-1">
<div className="text-muted-foreground text-xs">MAC</div>
<div className="font-medium text-foreground font-mono text-xs truncate">
{interface_.mac_address}
</div>
</div>
)}
</div>
</div> </div>
</div> )
) })}
})} </div>
</div> </CardContent>
</CardContent> </Card>
</Card> )}
)}
{networkData.vm_lxc_interfaces && networkData.vm_lxc_interfaces.length > 0 && (
<Card className="bg-card border-border">
<CardHeader>
<CardTitle className="text-foreground flex items-center">
<Network className="h-5 w-5 mr-2" />
VM & LXC Network Interfaces
<Badge variant="outline" className="ml-3 bg-orange-500/10 text-orange-500 border-orange-500/20">
{networkData.vm_lxc_active_count ?? 0} / {networkData.vm_lxc_total_count ?? 0} Active
</Badge>
</CardTitle>
</CardHeader>
<CardContent>
<div className="space-y-4">
{networkData.vm_lxc_interfaces.map((interface_, index) => {
const vmTypeBadge = getVMTypeBadge(interface_.vm_type)
return (
<div
key={index}
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
onClick={() => setSelectedInterface(interface_)}
>
{/* First row: Icon, Name, VM/LXC Badge, VM Name, Status */}
<div className="flex items-center gap-3 flex-wrap">
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
<div className="flex items-center gap-2 min-w-0 flex-1 flex-wrap">
<div className="font-medium text-foreground">{interface_.name}</div>
<Badge variant="outline" className={vmTypeBadge.color}>
{vmTypeBadge.label}
</Badge>
{interface_.vm_name && (
<div className="text-sm text-muted-foreground truncate"> {interface_.vm_name}</div>
)}
</div>
<Badge
variant="outline"
className={
interface_.status === "up"
? "bg-green-500/10 text-green-500 border-green-500/20"
: "bg-red-500/10 text-red-500 border-red-500/20"
}
>
{interface_.status.toUpperCase()}
</Badge>
</div>
{/* Second row: Details - Responsive layout */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div>
<div className="text-sm text-muted-foreground">VMID</div>
<div className="font-medium">{interface_.vmid ?? "N/A"}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Speed</div>
<div className="font-medium text-foreground flex items-center gap-1">
<Zap className="h-3 w-3" />
{formatSpeed(interface_.speed)}
</div>
</div>
<div className="col-span-2 md:col-span-1">
<div className="text-sm text-muted-foreground">Traffic</div>
<div className="font-medium text-foreground text-xs">
<span className="text-green-500"> {formatBytes(interface_.bytes_recv)}</span>
{" / "}
<span className="text-blue-500"> {formatBytes(interface_.bytes_sent)}</span>
</div>
</div>
{interface_.mac_address && (
<div className="col-span-2 md:col-span-1">
<div className="text-sm text-muted-foreground">MAC</div>
<div className="font-medium text-foreground font-mono text-xs truncate">
{interface_.mac_address}
</div>
</div>
)}
</div>
</div>
)
})}
</div>
</CardContent>
</Card>
)}
</div>
{/* Interface Details Modal */} {/* Interface Details Modal */}
<Dialog open={!!selectedInterface} onOpenChange={() => setSelectedInterface(null)}> <Dialog open={!!selectedInterface} onOpenChange={() => setSelectedInterface(null)}>
@@ -721,36 +691,64 @@ export function NetworkMetrics() {
)} )}
{/* Bridge Information */} {/* Bridge Information */}
{selectedInterface.type === "bridge" && selectedInterface.bridge_members && ( {selectedInterface.type === "bridge" && (
<div> <div>
<h3 className="text-sm font-semibold text-muted-foreground mb-3">Bridge Configuration</h3> <h3 className="text-sm font-semibold text-muted-foreground mb-3">Bridge Configuration</h3>
<div> <div className="space-y-3">
<div className="text-sm text-muted-foreground mb-2">Virtual Member Interfaces</div> {selectedInterface.bridge_physical_interface && (
<div className="flex flex-wrap gap-2"> <div>
{selectedInterface.bridge_members.length > 0 ? ( <div className="text-sm text-muted-foreground mb-2">Physical Interface</div>
selectedInterface.bridge_members <div className="font-medium text-blue-500 text-lg">
.filter( {selectedInterface.bridge_physical_interface}
(member) => </div>
!member.startsWith("enp") && </div>
!member.startsWith("eth") && )}
!member.startsWith("eno") && {selectedInterface.bridge_bond_slaves && selectedInterface.bridge_bond_slaves.length > 0 && (
!member.startsWith("ens") && <div>
!member.startsWith("wlan") && <div className="text-sm text-muted-foreground mb-2">Bond Slave Interfaces</div>
!member.startsWith("wlp"), <div className="flex flex-wrap gap-2">
) {selectedInterface.bridge_bond_slaves.map((slave, idx) => (
.map((member, idx) => (
<Badge <Badge
key={idx} key={idx}
variant="outline" variant="outline"
className="bg-green-500/10 text-green-500 border-green-500/20" className="bg-purple-500/10 text-purple-500 border-purple-500/20"
> >
{member} {slave}
</Badge> </Badge>
)) ))}
) : ( </div>
<div className="text-sm text-muted-foreground">No virtual members</div> </div>
)} )}
</div> {selectedInterface.bridge_members && (
<div>
<div className="text-sm text-muted-foreground mb-2">Virtual Member Interfaces</div>
<div className="flex flex-wrap gap-2">
{selectedInterface.bridge_members.length > 0 ? (
selectedInterface.bridge_members
.filter(
(member) =>
!member.startsWith("enp") &&
!member.startsWith("eth") &&
!member.startsWith("eno") &&
!member.startsWith("ens") &&
!member.startsWith("wlan") &&
!member.startsWith("wlp"),
)
.map((member, idx) => (
<Badge
key={idx}
variant="outline"
className="bg-green-500/10 text-green-500 border-green-500/20"
>
{member}
</Badge>
))
) : (
<div className="text-sm text-muted-foreground">No virtual members</div>
)}
</div>
</div>
)}
</div> </div>
</div> </div>
)} )}

View File

@@ -94,6 +94,24 @@ const formatBytes = (bytes: number | undefined): string => {
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}` return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`
} }
const extractIPFromNetConfig = (netConfig: string | undefined): string => {
if (!netConfig) return "N/A"
// Parse the network config string: name=eth0,bridge=vmbr0,gw=192.168.0.1,hwaddr=...,ip=192.168.0.4/24,type=veth
const ipMatch = netConfig.match(/ip=([^,]+)/)
if (ipMatch && ipMatch[1]) {
const ip = ipMatch[1]
// Check if it's DHCP
if (ip.toLowerCase() === "dhcp") {
return "DHCP"
}
// Return the IP without the subnet mask for cleaner display
return ip.split("/")[0]
}
return "N/A"
}
export function VirtualMachines() { export function VirtualMachines() {
const { const {
data: vmData, data: vmData,
@@ -396,7 +414,7 @@ export function VirtualMachines() {
</Badge> </Badge>
</div> </div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"> <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
<div> <div>
<div className="text-sm text-muted-foreground mb-2">CPU Usage</div> <div className="text-sm text-muted-foreground mb-2">CPU Usage</div>
<div className="text-lg font-semibold text-foreground mb-1">{cpuPercent}%</div> <div className="text-lg font-semibold text-foreground mb-1">{cpuPercent}%</div>
@@ -624,16 +642,31 @@ export function VirtualMachines() {
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4"> <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
{Object.keys(vmDetails.config) {Object.keys(vmDetails.config)
.filter((key) => key.match(/^net\d+$/)) .filter((key) => key.match(/^net\d+$/))
.map((netKey) => ( .map((netKey) => {
<div key={netKey} className="col-span-1"> const netConfig = vmDetails.config[netKey]
<div className="text-xs text-muted-foreground mb-1"> const ipAddress = selectedVM?.type === "lxc" ? extractIPFromNetConfig(netConfig) : null
Network Interface {netKey.replace("net", "")}
return (
<div key={netKey} className="col-span-1">
<div className="text-xs text-muted-foreground mb-1">
Network Interface {netKey.replace("net", "")}
</div>
{ipAddress && (
<div className="mb-2">
<span className="text-xs text-muted-foreground">IP Address: </span>
<span
className={`font-semibold ${ipAddress === "DHCP" ? "text-yellow-500" : "text-blue-500"}`}
>
{ipAddress}
</span>
</div>
)}
<div className="font-medium text-green-500 text-xs break-all font-mono">
{netConfig}
</div>
</div> </div>
<div className="font-medium text-green-500 text-sm break-all font-mono"> )
{vmDetails.config[netKey]} })}
</div>
</div>
))}
{vmDetails.config.nameserver && ( {vmDetails.config.nameserver && (
<div> <div>
<div className="text-xs text-muted-foreground mb-1">DNS Nameserver</div> <div className="text-xs text-muted-foreground mb-1">DNS Nameserver</div>