diff --git a/src/components/widgets/resources/disk.jsx b/src/components/widgets/resources/disk.jsx index 15da7780..d80988d8 100644 --- a/src/components/widgets/resources/disk.jsx +++ b/src/components/widgets/resources/disk.jsx @@ -31,15 +31,19 @@ export default function Disk({ options, expanded, diskUnits, refresh = 1500 }) { ); } - // data.drive.used not accurate? - const percent = Math.round(((data.drive.size - data.drive.available) / data.drive.size) * 100); + // Calculate the total size and available space from the data.drive array + const totalSize = data.drive.reduce((acc, drive) => acc + drive.size, 0); + const totalAvailable = data.drive.reduce((acc, drive) => acc + drive.available, 0); + + // Calculate the percentage of used space + const percent = Math.round(((totalSize - totalAvailable) / totalSize) * 100); return ( fs.mount === "/"); + driveData = rootTarget ?? [rootTarget]; + } else { + const foundTarget = fsSize.find((fs) => fs.mount === target); + driveData = foundTarget ? [foundTarget] : fsSize; + } return res.status(200).json({ - drive: fsSize.find((fs) => fs.mount === target) ?? fsSize.find((fs) => fs.mount === "/"), + drive: driveData, }); }