Refine storage metrics and highlight device links

This commit is contained in:
2025-08-13 02:33:13 -06:00
parent 7f5e0c69da
commit 76bd4fb33b
2 changed files with 17 additions and 8 deletions

View File

@@ -465,7 +465,8 @@ def collect_storage():
"disk_type": "Removable" if "removable" in part.opts.lower() else "Fixed Disk", "disk_type": "Removable" if "removable" in part.opts.lower() else "Fixed Disk",
"usage": usage.percent, "usage": usage.percent,
"total": usage.total, "total": usage.total,
"free": 100 - usage.percent, "free": usage.free,
"used": usage.used,
}) })
elif plat == "windows": elif plat == "windows":
try: try:
@@ -485,13 +486,13 @@ def collect_storage():
free_bytes = float(free) free_bytes = float(free)
used = total - free_bytes used = total - free_bytes
usage = (used / total * 100) if total else 0 usage = (used / total * 100) if total else 0
free_pct = 100 - usage
disks.append({ disks.append({
"drive": drive, "drive": drive,
"disk_type": "Fixed Disk", "disk_type": "Fixed Disk",
"usage": usage, "usage": usage,
"total": total, "total": total,
"free": free_pct, "free": free_bytes,
"used": used,
}) })
except Exception: except Exception:
pass pass
@@ -512,15 +513,16 @@ def collect_storage():
for d in data: for d in data:
total = d.get("Capacity") or 0 total = d.get("Capacity") or 0
used = d.get("Used") or 0 used = d.get("Used") or 0
free_bytes = d.get("Free") or max(total - used, 0)
usage = (used / total * 100) if total else 0 usage = (used / total * 100) if total else 0
free = 100 - usage
drive = d.get("Root") or f"{d.get('Name','')}:" drive = d.get("Root") or f"{d.get('Name','')}:"
disks.append({ disks.append({
"drive": drive, "drive": drive,
"disk_type": "Fixed Disk", "disk_type": "Fixed Disk",
"usage": usage, "usage": usage,
"total": total, "total": total,
"free": free, "free": free_bytes,
"used": used,
}) })
else: else:
out = subprocess.run( out = subprocess.run(
@@ -532,14 +534,15 @@ def collect_storage():
if len(parts) >= 6: if len(parts) >= 6:
total = int(parts[1]) * 1024 total = int(parts[1]) * 1024
used = int(parts[2]) * 1024 used = int(parts[2]) * 1024
free_bytes = int(parts[3]) * 1024
usage = float(parts[4].rstrip("%")) usage = float(parts[4].rstrip("%"))
free = 100 - usage
disks.append({ disks.append({
"drive": parts[5], "drive": parts[5],
"disk_type": "Fixed Disk", "disk_type": "Fixed Disk",
"usage": usage, "usage": usage,
"total": total, "total": total,
"free": free, "free": free_bytes,
"used": used,
}) })
except Exception as e: except Exception as e:
print(f"[WARN] collect_storage failed: {e}") print(f"[WARN] collect_storage failed: {e}")

View File

@@ -184,7 +184,13 @@ export default function DeviceList({ onSelectDevice }) {
</TableCell> </TableCell>
<TableCell <TableCell
onClick={() => onSelectDevice && onSelectDevice(r)} onClick={() => onSelectDevice && onSelectDevice(r)}
sx={{ cursor: onSelectDevice ? "pointer" : "default" }} sx={{
color: "#58a6ff",
"&:hover": {
cursor: onSelectDevice ? "pointer" : "default",
textDecoration: onSelectDevice ? "underline" : "none",
},
}}
> >
{r.hostname} {r.hostname}
</TableCell> </TableCell>