mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-06 20:28:48 +00:00
Enhancement: use datasets for truenas pools (#4716)
This commit is contained in:
parent
cc6fe63d40
commit
839f6d4baf
3 changed files with 39 additions and 33 deletions
|
@ -1,19 +1,9 @@
|
|||
import classNames from "classnames";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
export default function Pool({ name, free, allocated, healthy, data, nasType }) {
|
||||
let total = 0;
|
||||
if (nasType === "scale") {
|
||||
total = free + allocated;
|
||||
} else {
|
||||
allocated = 0; // eslint-disable-line no-param-reassign
|
||||
for (let i = 0; i < data.length; i += 1) {
|
||||
total += data[i].stats.size;
|
||||
allocated += data[i].stats.allocated; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
}
|
||||
|
||||
const usedPercent = Math.round((allocated / total) * 100);
|
||||
export default function Pool({ name, free, allocated, healthy }) {
|
||||
const { t } = useTranslation();
|
||||
const usedPercent = Math.round((allocated / (free + allocated)) * 100);
|
||||
const statusColor = healthy ? "bg-green-500" : "bg-yellow-500";
|
||||
|
||||
return (
|
||||
|
@ -32,7 +22,15 @@ export default function Pool({ name, free, allocated, healthy, data, nasType })
|
|||
</div>
|
||||
<div className="self-center text-xs flex justify-end mr-1.5 pl-1 z-10 text-ellipsis overflow-hidden whitespace-nowrap">
|
||||
<span>
|
||||
{prettyBytes(allocated)} / {prettyBytes(total)}
|
||||
{`${t("common.bytes", {
|
||||
value: allocated,
|
||||
maximumFractionDigits: 1,
|
||||
binary: true,
|
||||
})} / ${t("common.bytes", {
|
||||
value: free + allocated,
|
||||
maximumFractionDigits: 1,
|
||||
binary: true,
|
||||
})}`}
|
||||
</span>
|
||||
<span className="pl-2">({usedPercent}%)</span>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue