diff --git a/src/widgets/truenas/component.jsx b/src/widgets/truenas/component.jsx index 29c31adf3..917358571 100644 --- a/src/widgets/truenas/component.jsx +++ b/src/widgets/truenas/component.jsx @@ -3,8 +3,7 @@ import { useTranslation } from "next-i18next"; import Container from "components/services/widget/container"; import Block from "components/services/widget/block"; import useWidgetAPI from "utils/proxy/use-widget-api"; -import ScalePool from "widgets/truenas/scale-pool"; -import CorePool from "widgets/truenas/core-pool"; +import Pool from "widgets/truenas/pool"; export default function Component({ service }) { const { t } = useTranslation(); @@ -40,19 +39,17 @@ export default function Component({ service }) { {enablePools && - widget?.nasType === "scale" && poolsData.map((pool) => ( - ))} - {enablePools && - widget?.nasType === "core" && - poolsData.map((pool) => )} ); } diff --git a/src/widgets/truenas/core-pool.jsx b/src/widgets/truenas/pool.jsx similarity index 78% rename from src/widgets/truenas/core-pool.jsx rename to src/widgets/truenas/pool.jsx index 01bf7788f..612fc740b 100644 --- a/src/widgets/truenas/core-pool.jsx +++ b/src/widgets/truenas/pool.jsx @@ -1,14 +1,19 @@ import classNames from "classnames"; import prettyBytes from "pretty-bytes"; -export default function CorePool({ name, data, healthy }) { +export default function Pool({ name, scaleFree, scaleAllocated, healthy, data, nasType }) { let total = 0; let allocated = 0; - for (let i = 0; i < data.length; i += 1) { - total += data[i].stats.size; - allocated += data[i].stats.allocated; + if (nasType === "scale") { + total = scaleFree + scaleAllocated; + allocated = scaleAllocated; + } else { + for (let i = 0; i < data.length; i += 1) { + total += data[i].stats.size; + allocated += data[i].stats.allocated; + } } - // const total = free + allocated; + const usedPercent = Math.round((allocated / total) * 100); const statusColor = healthy ? "bg-green-500" : "bg-yellow-500"; diff --git a/src/widgets/truenas/scale-pool.jsx b/src/widgets/truenas/scale-pool.jsx deleted file mode 100644 index 7aa59f206..000000000 --- a/src/widgets/truenas/scale-pool.jsx +++ /dev/null @@ -1,31 +0,0 @@ -import classNames from "classnames"; -import prettyBytes from "pretty-bytes"; - -export default function ScalePool({ name, free, allocated, healthy }) { - const total = free + allocated; - const usedPercent = Math.round((allocated / total) * 100); - const statusColor = healthy ? "bg-green-500" : "bg-yellow-500"; - - return ( -
-
- - - -
-
{name}
-
-
- - {prettyBytes(allocated)} / {prettyBytes(total)} - - ({usedPercent}%) -
-
- ); -}