import useSWR from "swr"; import { useTranslation } from "next-i18next"; import Error from "../widget/error"; import Container from "../widget/container"; import Raw from "../widget/raw"; import Node from "./node"; export default function Widget({ options }) { const { cluster, nodes } = options; const { i18n } = useTranslation(); const defaultData = { cpu: { load: 0, total: 0, percent: 0 }, memory: { used: 0, total: 0, free: 0, percent: 0 } }; const { data, error } = useSWR( `/api/widgets/kubernetes?${new URLSearchParams({ lang: i18n.language }).toString()}`, { refreshInterval: 1500 } ); if (error || data?.error) { return } if (!data) { return
{cluster.show && } {nodes.show && }
; } return
{cluster.show && } {nodes.show && data.nodes && data.nodes.map((node) => ) }
; }