diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c844d37b2..9a17e0e22 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -27,7 +27,8 @@ "resources": { "total": "Total", "free": "Free", - "used": "Used" + "used": "Used", + "load": "Load" }, "docker": { "rx": "RX", diff --git a/src/components/widgets/resources/cpu.jsx b/src/components/widgets/resources/cpu.jsx index d6eaa1d7c..89700d773 100644 --- a/src/components/widgets/resources/cpu.jsx +++ b/src/components/widgets/resources/cpu.jsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import UsageBar from "./usage-bar"; -export default function Cpu() { +export default function Cpu({ expanded }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/widgets/resources?type=cpu`, { @@ -39,11 +39,29 @@ export default function Cpu() { return (
-
-
- {t("common.number", { value: data.cpu.usage, style: "unit", unit: "percent", maximumFractionDigits: 0 })}{" "} - {t("docker.cpu")} +
+
+
+ {t("common.number", { + value: data.cpu.usage, + style: "unit", + unit: "percent", + maximumFractionDigits: 0, + })} +
+
{t("docker.cpu")}
+ {expanded && ( +
+
+ {t("common.number", { + value: data.cpu.load, + maximumFractionDigits: 2, + })} +
+
{t("resources.load")}
+
+ )}
diff --git a/src/components/widgets/resources/disk.jsx b/src/components/widgets/resources/disk.jsx index 304799f1a..5b80a8694 100644 --- a/src/components/widgets/resources/disk.jsx +++ b/src/components/widgets/resources/disk.jsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import UsageBar from "./usage-bar"; -export default function Disk({ options }) { +export default function Disk({ options, expanded }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, { @@ -37,15 +37,19 @@ export default function Disk({ options }) { const percent = Math.round((data.drive.usedGb / data.drive.totalGb) * 100); return ( -
+
-
- - {t("common.bytes", { value: data.drive.freeGb * 1024 * 1024 * 1024 })} {t("resources.free")} - - - {t("common.bytes", { value: data.drive.totalGb * 1024 * 1024 * 1024 })} {t("resources.total")} +
+ +
{t("common.bytes", { value: data.drive.freeGb * 1024 * 1024 * 1024 })}
+
{t("resources.free")}
+ {expanded && ( + +
{t("common.bytes", { value: data.drive.totalGb * 1024 * 1024 * 1024 })}
+
{t("resources.total")}
+
+ )}
diff --git a/src/components/widgets/resources/memory.jsx b/src/components/widgets/resources/memory.jsx index 0be27c239..db530f1c5 100644 --- a/src/components/widgets/resources/memory.jsx +++ b/src/components/widgets/resources/memory.jsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import UsageBar from "./usage-bar"; -export default function Memory() { +export default function Memory({ expanded }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/widgets/resources?type=memory`, { @@ -37,15 +37,27 @@ export default function Memory() { const percent = Math.round((data.memory.usedMemMb / data.memory.totalMemMb) * 100); return ( -
+
-
- - {t("common.bytes", { value: data.memory.freeMemMb * 1024 * 1024 })} {t("resources.free")} - - - {t("common.bytes", { value: data.memory.usedMemMb * 1024 * 1024 })} {t("resources.used")} +
+ +
+ {t("common.bytes", { value: data.memory.freeMemMb * 1024 * 1024, maximumFractionDigits: 0, binary: true })} +
+
{t("resources.free")}
+ {expanded && ( + +
+ {t("common.bytes", { + value: data.memory.totalMemMb * 1024 * 1024, + maximumFractionDigits: 0, + binary: true, + })} +
+
{t("resources.total")}
+
+ )}
diff --git a/src/components/widgets/resources/resources.jsx b/src/components/widgets/resources/resources.jsx index 232816199..72933a024 100644 --- a/src/components/widgets/resources/resources.jsx +++ b/src/components/widgets/resources/resources.jsx @@ -3,14 +3,16 @@ import Cpu from "./cpu"; import Memory from "./memory"; export default function Resources({ options }) { + console.log(options); + const { expanded } = options; return (
- {options.cpu && } - {options.memory && } + {options.cpu && } + {options.memory && } {Array.isArray(options.disk) - ? options.disk.map((disk) => ) - : options.disk && } + ? options.disk.map((disk) => ) + : options.disk && }
{options.label && (
{options.label}