Merge pull request #34 from ilusi0n/jellyseerr-integration
Implement Jellyseerr integration
This commit is contained in:
commit
f40ca1e25c
3 changed files with 54 additions and 1 deletions
|
@ -9,7 +9,7 @@
|
|||
- Docker Integration
|
||||
- Status light + CPU, Memory & Network Reporting *(click on the status light)*
|
||||
- Service Integration
|
||||
- Currently supports Sonarr, Radarr, Ombi, Emby, Jellyfin, NZBGet, ruTorrent
|
||||
- Currently supports Sonarr, Radarr, Ombi, Emby, Jellyfin, Jellyseerr, NZBGet, ruTorrent
|
||||
- Portainer, Traefik, Speedtest Tracker, PiHole
|
||||
* Homepage Widgets
|
||||
- System Stats (Disk, CPU, Memory)
|
||||
|
|
|
@ -10,6 +10,7 @@ import Rutorrent from "./widgets/service/rutorrent";
|
|||
import Jellyfin from "./widgets/service/jellyfin";
|
||||
import Speedtest from "./widgets/service/speedtest";
|
||||
import Traefik from "./widgets/service/traefik";
|
||||
import Jellyseerr from "./widgets/service/jellyseerr";
|
||||
|
||||
const widgetMappings = {
|
||||
docker: Docker,
|
||||
|
@ -24,6 +25,7 @@ const widgetMappings = {
|
|||
rutorrent: Rutorrent,
|
||||
speedtest: Speedtest,
|
||||
traefik: Traefik,
|
||||
jellyseerr: Jellyseerr
|
||||
};
|
||||
|
||||
export default function Widget({ service }) {
|
||||
|
|
51
src/components/services/widgets/service/jellyseerr.jsx
Normal file
51
src/components/services/widgets/service/jellyseerr.jsx
Normal file
|
@ -0,0 +1,51 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
import Widget from "../widget";
|
||||
import Block from "../block";
|
||||
|
||||
export default function Jellyseerr({ service }) {
|
||||
const config = service.widget;
|
||||
|
||||
function buildApiUrl(endpoint) {
|
||||
const { url } = config;
|
||||
const reqUrl = new URL(`/api/v1/${endpoint}`, url);
|
||||
return `/api/proxy?url=${encodeURIComponent(reqUrl)}`;
|
||||
}
|
||||
|
||||
const fetcher = async (url) => {
|
||||
const res = await fetch(url, {
|
||||
method: "GET",
|
||||
withCredentials: true,
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"X-Api-Key": `${config.key}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
return await res.json();
|
||||
};
|
||||
|
||||
const { data: statsData, error: statsError } = useSWR(buildApiUrl(`request/count`), fetcher);
|
||||
|
||||
if (statsError) {
|
||||
return <Widget error="Jellyseerr API Error" />;
|
||||
}
|
||||
|
||||
if (!statsData) {
|
||||
return (
|
||||
<Widget>
|
||||
<Block label="Pending" />
|
||||
<Block label="Approved" />
|
||||
<Block label="Available" />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Widget>
|
||||
<Block label="Pending" value={statsData.pending} />
|
||||
<Block label="Approved" value={statsData.approved} />
|
||||
<Block label="Available" value={statsData.available} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
Loading…
Add table
Reference in a new issue