mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-04 06:12:12 +08:00
Enhancement: support different bytes multipliers for disk space for resources / glances and metrics widgets (#2966)
This commit is contained in:
@@ -5,8 +5,9 @@ import { useTranslation } from "next-i18next";
|
||||
import Resource from "../widget/resource";
|
||||
import Error from "../widget/error";
|
||||
|
||||
export default function Disk({ options, expanded, refresh = 1500 }) {
|
||||
export default function Disk({ options, expanded, diskUnits, refresh = 1500 }) {
|
||||
const { t } = useTranslation();
|
||||
const diskUnitsName = diskUnits === "bbytes" ? "common.bbytes" : "common.bytes";
|
||||
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
|
||||
refreshInterval: refresh,
|
||||
@@ -36,9 +37,9 @@ export default function Disk({ options, expanded, refresh = 1500 }) {
|
||||
return (
|
||||
<Resource
|
||||
icon={FiHardDrive}
|
||||
value={t("common.bytes", { value: data.drive.available })}
|
||||
value={t(diskUnitsName, { value: data.drive.available })}
|
||||
label={t("resources.free")}
|
||||
expandedValue={t("common.bytes", { value: data.drive.size })}
|
||||
expandedValue={t(diskUnitsName, { value: data.drive.size })}
|
||||
expandedLabel={t("resources.total")}
|
||||
percentage={percent}
|
||||
expanded={expanded}
|
||||
|
||||
Reference in New Issue
Block a user