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 ;
}
if (statusData && statusData.status !== "running") {
return (
);
}
if (!statsData || !statusData) {
return (
);
}
return (
{statsData.stats.cpuLimit && (
) || (
)}
);
}