mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 11:36:17 +00:00
Update storage-metrics.tsx
This commit is contained in:
@@ -66,6 +66,15 @@ const fetchStorageData = async (): Promise<StorageData | null> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
console.log("[v0] Storage data received:", data)
|
||||||
|
console.log("[v0] Disks:", data.disks)
|
||||||
|
if (data.disks && data.disks.length > 0) {
|
||||||
|
console.log("[v0] First disk details:", data.disks[0])
|
||||||
|
console.log(
|
||||||
|
"[v0] Disk types:",
|
||||||
|
data.disks.map((d: DiskInfo) => ({ name: d.name, type: d.disk_type })),
|
||||||
|
)
|
||||||
|
}
|
||||||
return data
|
return data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[v0] Failed to fetch storage data from Flask server:", error)
|
console.error("[v0] Failed to fetch storage data from Flask server:", error)
|
||||||
@@ -94,17 +103,20 @@ const getTempStatus = (temp: number, diskType: string): "safe" | "warning" | "cr
|
|||||||
}
|
}
|
||||||
|
|
||||||
const groupDisksByType = (disks: DiskInfo[]): DiskGroup[] => {
|
const groupDisksByType = (disks: DiskInfo[]): DiskGroup[] => {
|
||||||
|
console.log("[v0] Grouping disks by type, total disks:", disks.length)
|
||||||
|
|
||||||
const groups: { [key: string]: DiskInfo[] } = {}
|
const groups: { [key: string]: DiskInfo[] } = {}
|
||||||
|
|
||||||
disks.forEach((disk) => {
|
disks.forEach((disk) => {
|
||||||
const type = disk.disk_type || "Unknown"
|
const type = disk.disk_type || "Unknown"
|
||||||
|
console.log("[v0] Disk:", disk.name, "Type:", type, "Temp:", disk.temperature)
|
||||||
if (!groups[type]) {
|
if (!groups[type]) {
|
||||||
groups[type] = []
|
groups[type] = []
|
||||||
}
|
}
|
||||||
groups[type].push(disk)
|
groups[type].push(disk)
|
||||||
})
|
})
|
||||||
|
|
||||||
return Object.entries(groups).map(([type, disks]) => {
|
const result = Object.entries(groups).map(([type, disks]) => {
|
||||||
const temps = disks.map((d) => d.temperature).filter((t) => t > 0)
|
const temps = disks.map((d) => d.temperature).filter((t) => t > 0)
|
||||||
const avgTemp = temps.length > 0 ? Math.round(temps.reduce((a, b) => a + b, 0) / temps.length) : 0
|
const avgTemp = temps.length > 0 ? Math.round(temps.reduce((a, b) => a + b, 0) / temps.length) : 0
|
||||||
|
|
||||||
@@ -116,8 +128,13 @@ const groupDisksByType = (disks: DiskInfo[]): DiskGroup[] => {
|
|||||||
else if (diskStatus === "warning" && status !== "critical") status = "warning"
|
else if (diskStatus === "warning" && status !== "critical") status = "warning"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log("[v0] Group:", type, "Disks:", disks.length, "Avg Temp:", avgTemp, "Status:", status)
|
||||||
|
|
||||||
return { type, disks, avgTemp, status }
|
return { type, disks, avgTemp, status }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log("[v0] Total groups created:", result.length)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DiskGroup {
|
interface DiskGroup {
|
||||||
|
|||||||
Reference in New Issue
Block a user