mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +00:00
Merge pull request #448 from jameswynn/kubernetes
Support for Kubernetes and Longhorn
This commit is contained in:
commit
627ce179ef
33 changed files with 1789 additions and 43 deletions
|
@ -10,6 +10,7 @@ const components = {
|
|||
deluge: dynamic(() => import("./deluge/component")),
|
||||
downloadstation: dynamic(() => import("./downloadstation/component")),
|
||||
docker: dynamic(() => import("./docker/component")),
|
||||
kubernetes: dynamic(() => import("./kubernetes/component")),
|
||||
emby: dynamic(() => import("./emby/component")),
|
||||
flood: dynamic(() => import("./flood/component")),
|
||||
gluetun: dynamic(() => import("./gluetun/component")),
|
||||
|
|
50
src/widgets/kubernetes/component.jsx
Normal file
50
src/widgets/kubernetes/component.jsx
Normal file
|
@ -0,0 +1,50 @@
|
|||
import useSWR from "swr";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
const podSelectorString = widget.podSelector !== undefined ? `podSelector=${widget.podSelector}` : "";
|
||||
const { data: statusData, error: statusError } = useSWR(
|
||||
`/api/kubernetes/status/${widget.namespace}/${widget.app}?${podSelectorString}`);
|
||||
|
||||
const { data: statsData, error: statsError } = useSWR(
|
||||
`/api/kubernetes/stats/${widget.namespace}/${widget.app}?${podSelectorString}`);
|
||||
|
||||
if (statsError || statusError) {
|
||||
return <Container error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (statusData && statusData.status !== "running") {
|
||||
return (
|
||||
<Container>
|
||||
<Block label={t("widget.status")} value={t("docker.offline")} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
if (!statsData || !statusData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="docker.cpu" />
|
||||
<Block label="docker.mem" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
{statsData.stats.cpuLimit && (
|
||||
<Block label="docker.cpu" value={t("common.percent", { value: statsData.stats.cpuUsage })} />
|
||||
) || (
|
||||
<Block label="docker.cpu" value={t("common.number", { value: statsData.stats.cpu, maximumFractionDigits: 4 })}
|
||||
/>
|
||||
)}
|
||||
<Block label="docker.mem" value={t("common.bytes", { value: statsData.stats.mem })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue