From 63ccf6b553f9eea1c92821030c8cf5c78e4ac42d Mon Sep 17 00:00:00 2001 From: MacRimi Date: Tue, 14 Oct 2025 17:23:59 +0200 Subject: [PATCH] Update hardware.tsx --- AppImage/components/hardware.tsx | 262 ++++++++++++++++++++++++++++--- 1 file changed, 238 insertions(+), 24 deletions(-) diff --git a/AppImage/components/hardware.tsx b/AppImage/components/hardware.tsx index 4e1f09f..10aea3a 100644 --- a/AppImage/components/hardware.tsx +++ b/AppImage/components/hardware.tsx @@ -102,6 +102,35 @@ const getMonitoringToolRecommendation = (vendor: string): string => { return "To get extended GPU monitoring information, please install the appropriate GPU monitoring tools for your hardware." } +const groupAndSortTemperatures = (temperatures: any[]) => { + const groups = { + CPU: [] as any[], + GPU: [] as any[], + NVME: [] as any[], + PCI: [] as any[], + OTHER: [] as any[], + } + + temperatures.forEach((temp) => { + const nameLower = temp.name.toLowerCase() + const adapterLower = temp.adapter?.toLowerCase() || "" + + if (nameLower.includes("cpu") || nameLower.includes("core") || nameLower.includes("package")) { + groups.CPU.push(temp) + } else if (nameLower.includes("gpu") || adapterLower.includes("gpu")) { + groups.GPU.push(temp) + } else if (nameLower.includes("nvme") || adapterLower.includes("nvme")) { + groups.NVME.push(temp) + } else if (adapterLower.includes("pci")) { + groups.PCI.push(temp) + } else { + groups.OTHER.push(temp) + } + }) + + return groups +} + export default function Hardware() { const { data: hardwareData, error } = useSWR("/api/hardware", fetcher, { refreshInterval: 5000, @@ -357,33 +386,218 @@ export default function Hardware() { -
- {hardwareData.temperatures.map((temp, index) => { - const percentage = temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 - const isHot = temp.current > (temp.high || 80) - const isCritical = temp.current > (temp.critical || 90) + {(() => { + const groupedTemps = groupAndSortTemperatures(hardwareData.temperatures) - return ( -
-
- {temp.name} - - {temp.current.toFixed(1)}°C - + return ( +
+ {/* CPU Sensors */} + {groupedTemps.CPU.length > 0 && ( +
+
+ +

CPU

+ + {groupedTemps.CPU.length} + +
+
+ {groupedTemps.CPU.map((temp, index) => { + const percentage = + temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 + const isHot = temp.current > (temp.high || 80) + const isCritical = temp.current > (temp.critical || 90) + + return ( +
+
+ {temp.name} + + {temp.current.toFixed(1)}°C + +
+
+
+
+ {temp.adapter && {temp.adapter}} +
+ ) + })} +
-
-
+ )} + + {/* GPU Sensors */} + {groupedTemps.GPU.length > 0 && ( +
+
+ +

GPU

+ + {groupedTemps.GPU.length} + +
+
+ {groupedTemps.GPU.map((temp, index) => { + const percentage = + temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 + const isHot = temp.current > (temp.high || 80) + const isCritical = temp.current > (temp.critical || 90) + + return ( +
+
+ {temp.name} + + {temp.current.toFixed(1)}°C + +
+
+
+
+ {temp.adapter && {temp.adapter}} +
+ ) + })} +
- {temp.adapter && {temp.adapter}} -
- ) - })} -
+ )} + + {/* NVME Sensors */} + {groupedTemps.NVME.length > 0 && ( +
+
+ +

NVME

+ + {groupedTemps.NVME.length} + +
+
+ {groupedTemps.NVME.map((temp, index) => { + const percentage = + temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 + const isHot = temp.current > (temp.high || 80) + const isCritical = temp.current > (temp.critical || 90) + + return ( +
+
+ {temp.name} + + {temp.current.toFixed(1)}°C + +
+
+
+
+ {temp.adapter && {temp.adapter}} +
+ ) + })} +
+
+ )} + + {/* PCI Sensors */} + {groupedTemps.PCI.length > 0 && ( +
+
+ +

PCI

+ + {groupedTemps.PCI.length} + +
+
+ {groupedTemps.PCI.map((temp, index) => { + const percentage = + temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 + const isHot = temp.current > (temp.high || 80) + const isCritical = temp.current > (temp.critical || 90) + + return ( +
+
+ {temp.name} + + {temp.current.toFixed(1)}°C + +
+
+
+
+ {temp.adapter && {temp.adapter}} +
+ ) + })} +
+
+ )} + + {/* OTHER Sensors */} + {groupedTemps.OTHER.length > 0 && ( +
+
+ +

OTHER

+ + {groupedTemps.OTHER.length} + +
+
+ {groupedTemps.OTHER.map((temp, index) => { + const percentage = + temp.critical > 0 ? (temp.current / temp.critical) * 100 : (temp.current / 100) * 100 + const isHot = temp.current > (temp.high || 80) + const isCritical = temp.current > (temp.critical || 90) + + return ( +
+
+ {temp.name} + + {temp.current.toFixed(1)}°C + +
+
+
+
+ {temp.adapter && {temp.adapter}} +
+ ) + })} +
+
+ )} +
+ ) + })()} )}