mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
feat: add autobrr widget
This commit is contained in:
parent
6d46647fc9
commit
a2a5382ddb
@ -292,5 +292,11 @@
|
|||||||
"up_to_date": "Up to Date",
|
"up_to_date": "Up to Date",
|
||||||
"child_bridges": "Child Bridges",
|
"child_bridges": "Child Bridges",
|
||||||
"child_bridges_status": "{{ok}}/{{total}}"
|
"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}`;
|
headers.Authorization = `Bearer ${widget.key}`;
|
||||||
} else if (widget.type === "proxmox") {
|
} else if (widget.type === "proxmox") {
|
||||||
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
||||||
|
} else if (widget.type === "autobrr") {
|
||||||
|
headers["X-API-Token"] = `${widget.key}`;
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
39
src/widgets/autobrr/component.jsx
Normal file
39
src/widgets/autobrr/component.jsx
Normal file
@ -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>
|
||||||
|
);
|
||||||
|
}
|
20
src/widgets/autobrr/widget.js
Normal file
20
src/widgets/autobrr/widget.js
Normal file
@ -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 = {
|
const components = {
|
||||||
adguard: dynamic(() => import("./adguard/component")),
|
adguard: dynamic(() => import("./adguard/component")),
|
||||||
authentik: dynamic(() => import("./authentik/component")),
|
authentik: dynamic(() => import("./authentik/component")),
|
||||||
|
autobrr: dynamic(() => import("./autobrr/component")),
|
||||||
bazarr: dynamic(() => import("./bazarr/component")),
|
bazarr: dynamic(() => import("./bazarr/component")),
|
||||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import adguard from "./adguard/widget";
|
import adguard from "./adguard/widget";
|
||||||
import authentik from "./authentik/widget";
|
import authentik from "./authentik/widget";
|
||||||
|
import autobrr from "./autobrr/widget";
|
||||||
import bazarr from "./bazarr/widget";
|
import bazarr from "./bazarr/widget";
|
||||||
import changedetectionio from "./changedetectionio/widget";
|
import changedetectionio from "./changedetectionio/widget";
|
||||||
import coinmarketcap from "./coinmarketcap/widget";
|
import coinmarketcap from "./coinmarketcap/widget";
|
||||||
@ -35,6 +36,7 @@ import unifi from "./unifi/widget";
|
|||||||
const widgets = {
|
const widgets = {
|
||||||
adguard,
|
adguard,
|
||||||
authentik,
|
authentik,
|
||||||
|
autobrr,
|
||||||
bazarr,
|
bazarr,
|
||||||
changedetectionio,
|
changedetectionio,
|
||||||
coinmarketcap,
|
coinmarketcap,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user