You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1013 B
38 lines
1013 B
import useSWR from "swr";
|
|
import { useTranslation } from "next-i18next";
|
|
|
|
import Widget from "../widget";
|
|
import Block from "../block";
|
|
|
|
import { formatProxyUrl } from "utils/api-helpers";
|
|
|
|
export default function Traefik({ service }) {
|
|
const { t } = useTranslation();
|
|
|
|
const config = service.widget;
|
|
|
|
const { data: traefikData, error: traefikError } = useSWR(formatProxyUrl(config, "overview"));
|
|
|
|
if (traefikError) {
|
|
return <Widget error={t("widget.api_error")} />;
|
|
}
|
|
|
|
if (!traefikData) {
|
|
return (
|
|
<Widget>
|
|
<Block label={t("traefik.routers")} />
|
|
<Block label={t("traefik.services")} />
|
|
<Block label={t("traefik.middleware")} />
|
|
</Widget>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Widget>
|
|
<Block label={t("traefik.routers")} value={traefikData.http.routers.total} />
|
|
<Block label={t("traefik.services")} value={traefikData.http.services.total} />
|
|
<Block label={t("traefik.middleware")} value={traefikData.http.middlewares.total} />
|
|
</Widget>
|
|
);
|
|
}
|