Add widget for calibre-web with reverse-proxy auth
This commit is contained in:
parent
3bc750bfe7
commit
dd22df974f
@ -645,5 +645,10 @@
|
||||
"whatsupdocker": {
|
||||
"monitoring": "Monitoring",
|
||||
"updates": "Updates"
|
||||
},
|
||||
"calibreweb": {
|
||||
"books": "Books",
|
||||
"authors": "Authors",
|
||||
"series": "Series"
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,8 +35,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
"tailscale",
|
||||
"truenas",
|
||||
"pterodactyl",
|
||||
].includes(widget.type))
|
||||
{
|
||||
].includes(widget.type)) {
|
||||
headers.Authorization = `Bearer ${widget.key}`;
|
||||
} else if (widget.type === "proxmox") {
|
||||
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
||||
@ -55,6 +54,8 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
} else {
|
||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||
}
|
||||
} else if (widget.type === "calibreweb") {
|
||||
headers["X-Authenticated-User"] = widget.username;
|
||||
} else {
|
||||
headers["X-API-Key"] = `${widget.key}`;
|
||||
}
|
||||
|
||||
37
src/widgets/calibreweb/component.jsx
Normal file
37
src/widgets/calibreweb/component.jsx
Normal file
@ -0,0 +1,37 @@
|
||||
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: booksData, error: booksError } = useWidgetAPI(widget, "books");
|
||||
const { data: authorsData, error: authorsError } = useWidgetAPI(widget, "authors");
|
||||
const { data: seriesData, error: seriesError } = useWidgetAPI(widget, "series");
|
||||
|
||||
if (booksError || authorsError || seriesError) {
|
||||
const finalError = booksError ?? authorsError ?? seriesError;
|
||||
return <Container service={service} error={finalError} />;
|
||||
}
|
||||
|
||||
if (!booksData || !authorsData || !seriesData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" />
|
||||
<Block label="calibreweb.authors" />
|
||||
<Block label="calibreweb.series" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" value={t("common.number", { value: booksData.total })} />
|
||||
<Block label="calibreweb.authors" value={t("common.number", { value: authorsData.length })} />
|
||||
<Block label="calibreweb.series" value={t("common.number", { value: seriesData.length })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
20
src/widgets/calibreweb/widget.js
Normal file
20
src/widgets/calibreweb/widget.js
Normal file
@ -0,0 +1,20 @@
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
books: {
|
||||
endpoint: "ajax/listbooks",
|
||||
},
|
||||
authors: {
|
||||
endpoint: "get_authors_json",
|
||||
},
|
||||
series: {
|
||||
endpoint: "get_series_json",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
@ -7,6 +7,7 @@ const components = {
|
||||
autobrr: dynamic(() => import("./autobrr/component")),
|
||||
bazarr: dynamic(() => import("./bazarr/component")),
|
||||
caddy: dynamic(() => import("./caddy/component")),
|
||||
calibreweb: dynamic(() => import("./calibreweb/component")),
|
||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||
channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")),
|
||||
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||
|
||||
@ -4,6 +4,7 @@ import authentik from "./authentik/widget";
|
||||
import autobrr from "./autobrr/widget";
|
||||
import bazarr from "./bazarr/widget";
|
||||
import caddy from "./caddy/widget";
|
||||
import calibreweb from "./calibreweb/widget";
|
||||
import changedetectionio from "./changedetectionio/widget";
|
||||
import channelsdvrserver from "./channelsdvrserver/widget";
|
||||
import cloudflared from "./cloudflared/widget";
|
||||
@ -91,6 +92,7 @@ const widgets = {
|
||||
autobrr,
|
||||
bazarr,
|
||||
caddy,
|
||||
calibreweb,
|
||||
changedetectionio,
|
||||
channelsdvrserver,
|
||||
cloudflared,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user