mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 06:38:46 +00:00
Further improvements to simplify information widgets
Signed-off-by: Denis Papec <denis.papec@gmail.com>
This commit is contained in:
parent
d4fd923be5
commit
a55fe939cb
12 changed files with 181 additions and 267 deletions
|
@ -2,14 +2,9 @@ import useSWR from "swr";
|
|||
import { FiCpu } from "react-icons/fi";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import SingleResource from "../widget/single_resource";
|
||||
import WidgetIcon from "../widget/widget_icon";
|
||||
import ResourceValue from "../widget/resource_value";
|
||||
import ResourceLabel from "../widget/resource_label";
|
||||
import Resource from "../widget/resource";
|
||||
import Error from "../widget/error";
|
||||
|
||||
import UsageBar from "./usage-bar";
|
||||
|
||||
export default function Cpu({ expanded }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
@ -22,34 +17,25 @@ export default function Cpu({ expanded }) {
|
|||
}
|
||||
|
||||
if (!data) {
|
||||
return <SingleResource expanded={expanded}>
|
||||
<WidgetIcon icon={FiCpu} />
|
||||
<ResourceValue>-</ResourceValue>
|
||||
<ResourceLabel>{t("resources.cpu")}</ResourceLabel>
|
||||
<ResourceValue>-</ResourceValue>
|
||||
<ResourceLabel>{t("resources.load")}</ResourceLabel>
|
||||
<UsageBar percent={0} />
|
||||
</SingleResource>
|
||||
return <Resource icon={FiCpu} value="-" label={t("resources.cpu")} expandedValue="-"
|
||||
expandedLabel={t("resources.load")} percentage="0" expanded={expanded} />
|
||||
}
|
||||
|
||||
return <SingleResource expanded={expanded}>
|
||||
<WidgetIcon icon={FiCpu} />
|
||||
<ResourceValue>
|
||||
{t("common.number", {
|
||||
value: data.cpu.usage,
|
||||
style: "unit",
|
||||
unit: "percent",
|
||||
maximumFractionDigits: 0,
|
||||
})}
|
||||
</ResourceValue>
|
||||
<ResourceLabel>{t("resources.cpu")}</ResourceLabel>
|
||||
<ResourceValue>
|
||||
{t("common.number", {
|
||||
value: data.cpu.load,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</ResourceValue>
|
||||
<ResourceLabel>{t("resources.load")}</ResourceLabel>
|
||||
<UsageBar percent={data.cpu.usage} />
|
||||
</SingleResource>
|
||||
return <Resource
|
||||
icon={FiCpu}
|
||||
value={t("common.number", {
|
||||
value: data.cpu.usage,
|
||||
style: "unit",
|
||||
unit: "percent",
|
||||
maximumFractionDigits: 0,
|
||||
})}
|
||||
label={t("resources.cpu")}
|
||||
expandedValue={t("common.number", {
|
||||
value: data.cpu.load,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
expandedLabel={t("resources.load")}
|
||||
percentage={data.cpu.usage}
|
||||
expanded={expanded}
|
||||
/>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue