mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-17 18:29:48 +00:00
Add the Jackett widget
- add the follow-redirect package - add the tough-cookie package Jackett API uses a redirect mechanism to set a CSRF token. This CSRF token is stored in a cookie that is required to be present or the API won't work.
This commit is contained in:
parent
945ed854a4
commit
f750876425
8 changed files with 135 additions and 5 deletions
|
@ -22,6 +22,7 @@ import Tautulli from "./widgets/service/tautulli";
|
|||
import CoinMarketCap from "./widgets/service/coinmarketcap";
|
||||
import Gotify from "./widgets/service/gotify";
|
||||
import Prowlarr from "./widgets/service/prowlarr";
|
||||
import Jackett from "./widgets/service/jackett";
|
||||
|
||||
const widgetMappings = {
|
||||
docker: Docker,
|
||||
|
@ -45,7 +46,8 @@ const widgetMappings = {
|
|||
npm: Npm,
|
||||
tautulli: Tautulli,
|
||||
gotify: Gotify,
|
||||
prowlarr: Prowlarr
|
||||
prowlarr: Prowlarr,
|
||||
jackett: Jackett
|
||||
};
|
||||
|
||||
export default function Widget({ service }) {
|
||||
|
|
37
src/components/services/widgets/service/jackett.jsx
Normal file
37
src/components/services/widgets/service/jackett.jsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
import useSWR from "swr";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import Widget from "../widget";
|
||||
import Block from "../block";
|
||||
|
||||
import { formatApiUrl } from "utils/api-helpers";
|
||||
|
||||
export default function Jackett({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const config = service.widget;
|
||||
|
||||
const { data: indexersData, error: indexersError } = useSWR(formatApiUrl(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={indexersData.length} />
|
||||
<Block label={t("jackett.errored")} value={errored.length} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue