diff --git a/docs/widgets/info/glances.md b/docs/widgets/info/glances.md index e6fc2a616..b7fd7efd4 100644 --- a/docs/widgets/info/glances.md +++ b/docs/widgets/info/glances.md @@ -17,6 +17,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te cputemp: true # disabled by default uptime: true # disabled by default disk: / # disabled by default, use mount point of disk(s) in glances. Can also be a list (see below) + diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk expanded: true # show the expanded view label: MyMachine # optional ``` diff --git a/docs/widgets/info/resources.md b/docs/widgets/info/resources.md index 35f2177b4..b4f85d695 100644 --- a/docs/widgets/info/resources.md +++ b/docs/widgets/info/resources.md @@ -22,6 +22,7 @@ _Note: unfortunately, the package used for getting CPU temp ([systeminformation] uptime: true units: imperial # only used by cpu temp refresh: 3000 # optional, in ms + diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk ``` You can also pass a `label` option, which allows you to group resources under named sections, diff --git a/docs/widgets/services/glances.md b/docs/widgets/services/glances.md index d8f9e9ca0..134dcb5f6 100644 --- a/docs/widgets/services/glances.md +++ b/docs/widgets/services/glances.md @@ -18,6 +18,7 @@ widget: username: user # optional if auth enabled in Glances password: pass # optional if auth enabled in Glances metric: cpu + diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk ``` _Please note, this widget does not need an `href`, `icon` or `description` on its parent service. To achieve the same effect as the examples above, see as an example:_ diff --git a/src/components/widgets/glances/glances.jsx b/src/components/widgets/glances/glances.jsx index 0834b7756..905a179a8 100644 --- a/src/components/widgets/glances/glances.jsx +++ b/src/components/widgets/glances/glances.jsx @@ -21,6 +21,7 @@ function convertToFahrenheit(t) { export default function Widget({ options }) { const { t, i18n } = useTranslation(); const { settings } = useContext(SettingsContext); + const diskUnits = options.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes"; const { data, error } = useSWR( `/api/widgets/glances?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`, @@ -132,9 +133,9 @@ export default function Widget({ options }) { } {options.memory && } {Array.isArray(options.disk) - ? options.disk.map((disk) => ) - : options.disk && } + ? options.disk.map((disk) => ( + + )) + : options.disk && } {options.cputemp && } {options.uptime && } diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 67502a7a7..9f9979150 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -395,6 +395,7 @@ export function cleanServiceGroups(groups) { chart, metric, pointsLimit, + diskUnits, // glances, customapi, iframe refreshInterval, @@ -533,6 +534,7 @@ export function cleanServiceGroups(groups) { } if (refreshInterval) cleanedService.widget.refreshInterval = refreshInterval; if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit; + if (diskUnits) cleanedService.widget.diskUnits = diskUnits; } if (type === "mjpeg") { if (stream) cleanedService.widget.stream = stream; diff --git a/src/widgets/glances/metrics/fs.jsx b/src/widgets/glances/metrics/fs.jsx index 9cd0cec6d..16d8d153b 100644 --- a/src/widgets/glances/metrics/fs.jsx +++ b/src/widgets/glances/metrics/fs.jsx @@ -13,6 +13,7 @@ export default function Component({ service }) { const { widget } = service; const { chart, refreshInterval = defaultInterval } = widget; const [, fsName] = widget.metric.split("fs:"); + const diskUnits = widget.diskUnits === "bbytes" ? "common.bbytes" : "common.bytes"; const { data, error } = useWidgetAPI(widget, "fs", { refreshInterval: Math.max(defaultInterval, refreshInterval), @@ -60,7 +61,7 @@ export default function Component({ service }) { {fsData.used && chart && (
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.used, maximumFractionDigits: 0, })}{" "} @@ -69,7 +70,7 @@ export default function Component({ service }) { )}
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.free, maximumFractionDigits: 1, })}{" "} @@ -81,7 +82,7 @@ export default function Component({ service }) { {fsData.used && (
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.used, maximumFractionDigits: 0, })}{" "} @@ -93,7 +94,7 @@ export default function Component({ service }) {
- {t("common.bbytes", { + {t(diskUnits, { value: fsData.size, maximumFractionDigits: 1, })}{" "}