Merge pull request #452 from brandon-barker/widget/autobrr

feature: add autobrr widget
pull/454/head
shamoon 2 years ago committed by GitHub
commit 0d89c980cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -292,5 +292,11 @@
"up_to_date": "Up to Date",
"child_bridges": "Child Bridges",
"child_bridges_status": "{{ok}}/{{total}}"
},
"autobrr": {
"approvedPushes": "Approved",
"rejectedPushes": "Rejected",
"filters": "Filters",
"indexers": "Indexers"
}
}

@ -31,6 +31,8 @@ export default async function credentialedProxyHandler(req, res) {
headers.Authorization = `Bearer ${widget.key}`;
} else if (widget.type === "proxmox") {
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
} else if (widget.type === "autobrr") {
headers["X-API-Token"] = `${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

@ -0,0 +1,39 @@
import { useTranslation } from "next-i18next";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: statsData, error: statsError } = useWidgetAPI(widget, "stats");
const { data: filtersData, error: filtersError } = useWidgetAPI(widget, "filters");
const { data: indexersData, error: indexersError } = useWidgetAPI(widget, "indexers");
if (statsError || filtersError || indexersError) {
return <Container error={t("widget.api_error")} />;
}
if (!statsData || !filtersData || !indexersData) {
return (
<Container service={service}>
<Block label="autobrr.approvedPushes" />
<Block label="autobrr.rejectedPushes" />
<Block label="autobrr.filters" />
<Block label="autobrr.indexers" />
</Container>
);
}
return (
<Container service={service}>
<Block label="autobrr.approvedPushes" value={t("common.number", { value: statsData.push_approved_count })} />
<Block label="autobrr.rejectedPushes" value={t("common.number", { value: statsData.push_rejected_count })} />
<Block label="autobrr.filters" value={t("common.number", { value: filtersData.length })} />
<Block label="autobrr.indexers" value={t("common.number", { value: indexersData.length })} />
</Container>
);
}

@ -0,0 +1,20 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
stats: {
endpoint: "release/stats",
},
filters: {
endpoint: "filters",
},
indexers: {
endpoint: "release/indexers",
},
},
};
export default widget;

@ -3,6 +3,7 @@ import dynamic from "next/dynamic";
const components = {
adguard: dynamic(() => import("./adguard/component")),
authentik: dynamic(() => import("./authentik/component")),
autobrr: dynamic(() => import("./autobrr/component")),
bazarr: dynamic(() => import("./bazarr/component")),
changedetectionio: dynamic(() => import("./changedetectionio/component")),
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),

@ -1,5 +1,6 @@
import adguard from "./adguard/widget";
import authentik from "./authentik/widget";
import autobrr from "./autobrr/widget";
import bazarr from "./bazarr/widget";
import changedetectionio from "./changedetectionio/widget";
import coinmarketcap from "./coinmarketcap/widget";
@ -35,6 +36,7 @@ import unifi from "./unifi/widget";
const widgets = {
adguard,
authentik,
autobrr,
bazarr,
changedetectionio,
coinmarketcap,

Loading…
Cancel
Save