feat: gpu info

This commit is contained in:
hamster1963 2024-12-02 11:47:48 +08:00
parent a4bdf10c72
commit 3d4bd79ad5
3 changed files with 36 additions and 24 deletions

View File

@ -111,28 +111,27 @@ export const NetworkChartClient = React.memo(function NetworkChart({
const defaultChart = "All";
const [activeCharts, setActiveCharts] = React.useState<string[]>([defaultChart]);
const [activeCharts, setActiveCharts] = React.useState<string[]>([
defaultChart,
]);
const handleButtonClick = useCallback(
(chart: string) => {
const handleButtonClick = useCallback((chart: string) => {
setActiveCharts((prev) => {
if (chart === defaultChart) {
return [defaultChart];
}
const newCharts = prev.filter(c => c !== defaultChart);
const newCharts = prev.filter((c) => c !== defaultChart);
const chartIndex = newCharts.indexOf(chart);
if (chartIndex === -1) {
return newCharts.length === 0 ? [chart] : [...newCharts, chart];
} else {
const result = newCharts.filter(c => c !== chart);
const result = newCharts.filter((c) => c !== chart);
return result.length === 0 ? [defaultChart] : result;
}
});
},
[],
);
}, []);
const getColorByIndex = useCallback(
(chart: string) => {

View File

@ -179,8 +179,20 @@ export default function ServerDetailOverview({
<CardContent className="px-1.5 py-1">
<section className="flex flex-col items-start gap-0.5">
<p className="text-xs text-muted-foreground">{"CPU"}</p>
{server.host.cpu ? (
<div className="text-xs"> {server.host.cpu}</div>
{server.host.cpu.length > 0 ? (
<div className="text-xs"> {server.host.cpu.join(", ")}</div>
) : (
<div className="text-xs"> {t("serverDetail.unknown")}</div>
)}
</section>
</CardContent>
</Card>
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
<CardContent className="px-1.5 py-1">
<section className="flex flex-col items-start gap-0.5">
<p className="text-xs text-muted-foreground">{"GPU"}</p>
{server.host.gpu.length > 0 ? (
<div className="text-xs">{server.host.gpu.join(", ")}</div>
) : (
<div className="text-xs"> {t("serverDetail.unknown")}</div>
)}

View File

@ -16,6 +16,7 @@ export interface NezhaServerHost {
platform: string;
platform_version: string;
cpu: string[];
gpu: string[];
mem_total: number;
disk_total: number;
swap_total: number;