mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-17 18:29:48 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -4,7 +4,6 @@ import Container from "components/services/widget/container";
|
|||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
|
||||
function calcRunning(total, current) {
|
||||
return current.status === "running" ? total + 1 : total;
|
||||
}
|
||||
|
@ -31,10 +30,20 @@ export default function Component({ service }) {
|
|||
);
|
||||
}
|
||||
|
||||
const { data } = clusterData ;
|
||||
const vms = data.filter(item => item.type === "qemu" && item.template === 0 && (widget.node === undefined || widget.node === item.node)) || [];
|
||||
const lxc = data.filter(item => item.type === "lxc" && item.template === 0 && (widget.node === undefined || widget.node === item.node)) || [];
|
||||
const nodes = data.filter(item => item.type === "node" && item.status === "online" && (widget.node === undefined || widget.node === item.node)) || [];
|
||||
const { data } = clusterData;
|
||||
const vms =
|
||||
data.filter(
|
||||
(item) => item.type === "qemu" && item.template === 0 && (widget.node === undefined || widget.node === item.node),
|
||||
) || [];
|
||||
const lxc =
|
||||
data.filter(
|
||||
(item) => item.type === "lxc" && item.template === 0 && (widget.node === undefined || widget.node === item.node),
|
||||
) || [];
|
||||
const nodes =
|
||||
data.filter(
|
||||
(item) =>
|
||||
item.type === "node" && item.status === "online" && (widget.node === undefined || widget.node === item.node),
|
||||
) || [];
|
||||
const runningVMs = vms.reduce(calcRunning, 0);
|
||||
const runningLXC = lxc.reduce(calcRunning, 0);
|
||||
|
||||
|
@ -52,14 +61,14 @@ export default function Component({ service }) {
|
|||
const maxMemory = nodes.reduce((sum, n) => n.maxmem + sum, 0);
|
||||
const usedMemory = nodes.reduce((sum, n) => n.mem + sum, 0);
|
||||
const maxCpu = nodes.reduce((sum, n) => n.maxcpu + sum, 0);
|
||||
const usedCpu = nodes.reduce((sum, n) => (n.cpu * n.maxcpu) + sum, 0);
|
||||
const usedCpu = nodes.reduce((sum, n) => n.cpu * n.maxcpu + sum, 0);
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="proxmox.vms" value={`${runningVMs} / ${vms.length}`} />
|
||||
<Block label="proxmox.lxc" value={`${runningLXC} / ${lxc.length}`} />
|
||||
<Block label="resources.cpu" value={t("common.percent", { value: ((usedCpu / maxCpu) * 100) })} />
|
||||
<Block label="resources.mem" value={t("common.percent", { value: ((usedMemory / maxMemory) * 100) })} />
|
||||
<Block label="resources.cpu" value={t("common.percent", { value: (usedCpu / maxCpu) * 100 })} />
|
||||
<Block label="resources.mem" value={t("common.percent", { value: (usedMemory / maxMemory) * 100 })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue