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.
|
|
|
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 Jackett({ service }) {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
const config = service.widget;
|
|
|
|
|
|
|
|
const { data: indexersData, error: indexersError } = useSWR(formatProxyUrl(config, "indexers"));
|
|
|
|
|
|
|
|
if (indexersError) {
|
|
|
|
return <Widget error={t("widget.api_error")} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!indexersData) {
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<Block label={t("jackett.configured")} />
|
|
|
|
<Block label={t("jackett.errored")} />
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const errored = indexersData.filter((indexer) => indexer.last_error);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<Block label={t("jackett.configured")} value={t("common.number", { value: indexersData.length })} />
|
|
|
|
<Block label={t("jackett.errored")} value={t("common.number", { value: errored.length })} />
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|