import useSWR from "swr"; import { BiError } from "react-icons/bi"; import { useTranslation } from "next-i18next"; import Node from "./node"; export default function Longhorn({ options }) { const { expanded, total, labels, include, nodes } = options; const { t } = useTranslation(); const { data, error } = useSWR(`/api/widgets/longhorn`, { refreshInterval: 1500 }); if (error || data?.error) { return (
{t("widget.api_error")}
); } if (!data) { return (
); } return (
{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; }) .map((node) =>
)}
); }