Add Prowlarr widget

pull/134/head
Francisco Coelho 2 years ago
parent 406358aae9
commit b5538655e0

@ -7,6 +7,7 @@ const nextConfig = {
domains: ["cdn.jsdelivr.net"], domains: ["cdn.jsdelivr.net"],
unoptimized: true, unoptimized: true,
}, },
experimental: { images: { allowFutureImage: true } }
}; };
module.exports = nextConfig; module.exports = nextConfig;

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -125,5 +125,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -125,5 +125,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -125,5 +125,12 @@
"apps": "Aplicações", "apps": "Aplicações",
"clients": "Clientes", "clients": "Clientes",
"messages": "Mensagens" "messages": "Mensagens"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -114,5 +114,12 @@
"apps": "Applications", "apps": "Applications",
"clients": "Clients", "clients": "Clients",
"messages": "Messages" "messages": "Messages"
},
"prowlarr":{
"enableIndexers": "Indexers",
"numberOfGrabs": "Grabs",
"numberOfQueries": "Queries",
"numberOfFailGrabs": "Fail Grabs",
"numberOfFailQueries": "Fail Queries"
} }
} }

@ -20,6 +20,7 @@ import Npm from "./widgets/service/npm";
import Tautulli from "./widgets/service/tautulli"; import Tautulli from "./widgets/service/tautulli";
import CoinMarketCap from "./widgets/service/coinmarketcap"; import CoinMarketCap from "./widgets/service/coinmarketcap";
import Gotify from "./widgets/service/gotify"; import Gotify from "./widgets/service/gotify";
import Prowlarr from "./widgets/service/prowlarr";
const widgetMappings = { const widgetMappings = {
docker: Docker, docker: Docker,
@ -41,7 +42,8 @@ const widgetMappings = {
npm: Npm, npm: Npm,
tautulli: Tautulli, tautulli: Tautulli,
gotify: Gotify, gotify: Gotify,
sabnzbd: SABnzbd sabnzbd: SABnzbd,
prowlarr: Prowlarr
}; };
export default function Widget({ service }) { export default function Widget({ service }) {

@ -0,0 +1,55 @@
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 Prowlarr({ service }) {
const { t } = useTranslation();
const config = service.widget;
const { data: indexersData, error: indexersError } = useSWR(formatApiUrl(config, "indexer"));
const { data: grabsData, error: grabsError } = useSWR(formatApiUrl(config, "indexerstats"));
if (indexersError || grabsError) {
return <Widget error={t("widget.api_error")} />;
}
if (!indexersData || !grabsData) {
return (
<Widget>
<Block label={t("prowlarr.enableIndexers")} />
<Block label={t("prowlarr.numberOfGrabs")} />
<Block label={t("prowlarr.numberOfQueries")} />
<Block label={t("prowlarr.numberOfFailGrabs")} />
<Block label={t("prowlarr.numberOfFailQueries")} />
</Widget>
);
}
const indexers = indexersData?.filter((indexer) => indexer.enable === true);
let numberOfGrabs = 0
let numberOfQueries = 0
let numberOfFailedGrabs = 0
let numberOfFailedQueries = 0
grabsData?.indexers?.forEach(element => {
numberOfGrabs = numberOfGrabs + element.numberOfGrabs;
numberOfQueries = numberOfQueries + element.numberOfQueries;
numberOfFailedGrabs = numberOfFailedGrabs + element.numberOfFailedGrabs;
numberOfFailedQueries = numberOfFailedQueries + element.numberOfFailedQueries;
});
return (
<Widget>
<Block label={t("prowlarr.enableIndexers")} value={indexers.length} />
<Block label={t("prowlarr.numberOfGrabs")} value={numberOfGrabs} />
<Block label={t("prowlarr.numberOfQueries")} value={numberOfQueries} />
<Block label={t("prowlarr.numberOfFailGrabs")} value={numberOfFailedGrabs} />
<Block label={t("prowlarr.numberOfFailQueries")} value={numberOfFailedQueries} />
</Widget>
);
}

@ -23,6 +23,7 @@ const serviceProxyHandlers = {
overseerr: credentialedProxyHandler, overseerr: credentialedProxyHandler,
ombi: credentialedProxyHandler, ombi: credentialedProxyHandler,
coinmarketcap: credentialedProxyHandler, coinmarketcap: credentialedProxyHandler,
prowlarr: credentialedProxyHandler,
// super specific handlers // super specific handlers
rutorrent: rutorrentProxyHandler, rutorrent: rutorrentProxyHandler,
nzbget: nzbgetProxyHandler, nzbget: nzbgetProxyHandler,

@ -17,6 +17,7 @@ const formats = {
sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`, sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`,
coinmarketcap: `https://pro-api.coinmarketcap.com/{endpoint}`, coinmarketcap: `https://pro-api.coinmarketcap.com/{endpoint}`,
gotify: `{url}/{endpoint}`, gotify: `{url}/{endpoint}`,
prowlarr: `{url}/api/v1/{endpoint}`,
}; };
export function formatApiCall(api, args) { export function formatApiCall(api, args) {

Loading…
Cancel
Save