mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-16 23:02:08 +08:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
@@ -9,43 +9,47 @@ import Node from "./node";
|
||||
export default function Longhorn({ options }) {
|
||||
const { expanded, total, labels, include, nodes } = options;
|
||||
const { data, error } = useSWR(`api/widgets/longhorn`, {
|
||||
refreshInterval: 1500
|
||||
refreshInterval: 1500,
|
||||
});
|
||||
|
||||
if (error || data?.error) {
|
||||
return <Error options={options} />
|
||||
return <Error options={options} />;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return <Container options={options} additionalClassNames="infomation-widget-longhorn">
|
||||
<Raw>
|
||||
<div className="flex flex-row self-center flex-wrap justify-between" />
|
||||
</Raw>
|
||||
</Container>;
|
||||
return (
|
||||
<Container options={options} additionalClassNames="infomation-widget-longhorn">
|
||||
<Raw>
|
||||
<div className="flex flex-row self-center flex-wrap justify-between" />
|
||||
</Raw>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return <Container options={options} additionalClassNames="infomation-widget-longhorn">
|
||||
<Raw>
|
||||
<div className="flex flex-row self-center flex-wrap justify-between">
|
||||
{data.nodes
|
||||
.filter((node) => {
|
||||
if (node.id === 'total' && total) {
|
||||
return (
|
||||
<Container options={options} additionalClassNames="infomation-widget-longhorn">
|
||||
<Raw>
|
||||
<div className="flex flex-row self-center flex-wrap justify-between">
|
||||
{data.nodes
|
||||
.filter((node) => {
|
||||
if (node.id === "total" && total) {
|
||||
return true;
|
||||
}
|
||||
if (!nodes) {
|
||||
return false;
|
||||
}
|
||||
if (include && !include.includes(node.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!nodes) {
|
||||
return false;
|
||||
}
|
||||
if (include && !include.includes(node.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map((node) =>
|
||||
<div key={node.id}>
|
||||
<Node data={{ node }} expanded={expanded} labels={labels} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Raw>
|
||||
</Container>;
|
||||
})
|
||||
.map((node) => (
|
||||
<div key={node.id}>
|
||||
<Node data={{ node }} expanded={expanded} labels={labels} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Raw>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,18 @@ import WidgetLabel from "../widget/widget_label";
|
||||
export default function Node({ data, expanded, labels }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <Resource
|
||||
additionalClassNames="information-widget-longhorn-node"
|
||||
icon={FaThermometerHalf}
|
||||
value={t("common.bytes", { value: data.node.available })}
|
||||
label={t("resources.free")}
|
||||
expandedValue={t("common.bytes", { value: data.node.maximum })}
|
||||
expandedLabel={t("resources.total")}
|
||||
percentage={Math.round(((data.node.maximum - data.node.available) / data.node.maximum) * 100)}
|
||||
expanded={expanded}
|
||||
>{ labels && <WidgetLabel label={data.node.id} /> }
|
||||
</Resource>
|
||||
return (
|
||||
<Resource
|
||||
additionalClassNames="information-widget-longhorn-node"
|
||||
icon={FaThermometerHalf}
|
||||
value={t("common.bytes", { value: data.node.available })}
|
||||
label={t("resources.free")}
|
||||
expandedValue={t("common.bytes", { value: data.node.maximum })}
|
||||
expandedLabel={t("resources.total")}
|
||||
percentage={Math.round(((data.node.maximum - data.node.available) / data.node.maximum) * 100)}
|
||||
expanded={expanded}
|
||||
>
|
||||
{labels && <WidgetLabel label={data.node.id} />}
|
||||
</Resource>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user