diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index fd41c84..3a93215 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -7,7 +7,7 @@ import { PopoverTrigger, } from "@/components/ui/popover"; import { formatNezhaInfo } from "@/lib/utils"; -import ServerCardPopover from "./ServerPopover"; +import ServerCardPopover from "./ServerCardPopover"; export default function ServerCard({ timestamp, diff --git a/components/ServerCardPopover.tsx b/components/ServerCardPopover.tsx new file mode 100644 index 0000000..aab2299 --- /dev/null +++ b/components/ServerCardPopover.tsx @@ -0,0 +1,68 @@ +import { NezhaAPISafe } from "@/app/types/nezha-api"; +import { cn, formatBytes } from "@/lib/utils"; + +export function ServerCardPopoverCard({ + className, + title, + content, + children, +}: { + className?: string; + title: string; + content?: string; + children?: React.ReactNode; +}) { + return ( +
+
{title}
+ {children ? children :
{content}
} +
+
+ ); +} + +export default function ServerCardPopover({ + host, + status, +}: { + host: NezhaAPISafe["host"]; + status: NezhaAPISafe["status"]; +}) { + return ( +
+ + item).join(", ")}`} + /> + + + + + + +
+ ); +} diff --git a/components/ServerPopover.tsx b/components/ServerPopover.tsx deleted file mode 100644 index f25f5a2..0000000 --- a/components/ServerPopover.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { NezhaAPISafe } from "@/app/types/nezha-api"; -import { formatBytes } from "@/lib/utils"; - -export default function ServerCardPopover({ - host, - status, -}: { - host: NezhaAPISafe["host"]; - status: NezhaAPISafe["status"]; -}) { - return ( -
-
- System: {host.Platform}-{host.PlatformVersion} [{host.Virtualization}:{" "} - {host.Arch}] -
-
CPU: [{host.CPU.map((item) => item).join(", ")}]
-
- STG: {formatBytes(status.DiskUsed)}/{formatBytes(host.DiskTotal)} -
-
- Mem: {formatBytes(status.MemUsed)}/{formatBytes(host.MemTotal)} -
-
- Swap: {formatBytes(status.SwapUsed)}/{formatBytes(host.SwapTotal)} -
-
-
- Load: {status.Load1.toFixed(2)}/{status.Load5.toFixed(2)}/ - {status.Load15.toFixed(2)} -
-
Online: {(status.Uptime / 86400).toFixed(0)} Days
-
- ); -}