adding Komga
This commit is contained in:
parent
b1fbbf2264
commit
8920217411
@ -447,5 +447,11 @@
|
|||||||
"photos": "Photos",
|
"photos": "Photos",
|
||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"storage": "Storage"
|
"storage": "Storage"
|
||||||
|
},
|
||||||
|
"komga": {
|
||||||
|
"users": "Users",
|
||||||
|
"libraries": "Libraries",
|
||||||
|
"series": "Series",
|
||||||
|
"books": "Books"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
|
|
||||||
if (widget) {
|
if (widget) {
|
||||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||||
|
const version = process.env.NEXT_PUBLIC_VERSION?.length ? process.env.NEXT_PUBLIC_VERSION : "dev";
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -46,6 +47,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else if (widget.type === "cloudflared") {
|
} else if (widget.type === "cloudflared") {
|
||||||
headers["X-Auth-Email"] = `${widget.email}`;
|
headers["X-Auth-Email"] = `${widget.email}`;
|
||||||
headers["X-Auth-Key"] = `${widget.key}`;
|
headers["X-Auth-Key"] = `${widget.key}`;
|
||||||
|
} else if (widget.type === "komga") {
|
||||||
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`
|
||||||
|
headers["User-Agent"] = `HomepageRuntime/${version} `
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ const components = {
|
|||||||
jackett: dynamic(() => import("./jackett/component")),
|
jackett: dynamic(() => import("./jackett/component")),
|
||||||
jellyfin: dynamic(() => import("./emby/component")),
|
jellyfin: dynamic(() => import("./emby/component")),
|
||||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||||
|
komga: dynamic(() => import("./komga/component")),
|
||||||
lidarr: dynamic(() => import("./lidarr/component")),
|
lidarr: dynamic(() => import("./lidarr/component")),
|
||||||
mastodon: dynamic(() => import("./mastodon/component")),
|
mastodon: dynamic(() => import("./mastodon/component")),
|
||||||
medusa: dynamic(() => import("./medusa/component")),
|
medusa: dynamic(() => import("./medusa/component")),
|
||||||
|
|||||||
35
src/widgets/komga/component.jsx
Normal file
35
src/widgets/komga/component.jsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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 { widget } = service;
|
||||||
|
|
||||||
|
const { data: libraryData, error: libraryError } = useWidgetAPI(widget, "komga.libraries");
|
||||||
|
const { data: seriesData, error: seriesError } = useWidgetAPI(widget, "komga.series");
|
||||||
|
const { data: bookData, error: bookError } = useWidgetAPI(widget, "komga.books");
|
||||||
|
|
||||||
|
if (libraryError || seriesError || bookError) {
|
||||||
|
const finalError = libraryError ?? seriesError ?? bookError;
|
||||||
|
return <Container error={finalError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!libraryError || !seriesError || !bookError) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="komga.libraries" />
|
||||||
|
<Block label="komga.series" />
|
||||||
|
<Block label="komga.books" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="komga.libraries" value={parseInt(libraryData.measurements.value, 10) } />
|
||||||
|
<Block label="komga.series" value={parseInt(seriesData.measurements.value, 10) } />
|
||||||
|
<Block label="komga.books" value={parseInt(bookData.measurements.value, 10) } />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
20
src/widgets/komga/widget.js
Normal file
20
src/widgets/komga/widget.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/actuator/metrics/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
"komga.libraries": {
|
||||||
|
endpoint: "komga.libraries"
|
||||||
|
},
|
||||||
|
"komga.series": {
|
||||||
|
endpoint: "komga.series"
|
||||||
|
},
|
||||||
|
"komga.books": {
|
||||||
|
endpoint: "komga.books"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -15,6 +15,7 @@ import hdhomerun from "./hdhomerun/widget";
|
|||||||
import homebridge from "./homebridge/widget";
|
import homebridge from "./homebridge/widget";
|
||||||
import jackett from "./jackett/widget";
|
import jackett from "./jackett/widget";
|
||||||
import jellyseerr from "./jellyseerr/widget";
|
import jellyseerr from "./jellyseerr/widget";
|
||||||
|
import komga from "./komga/widget";
|
||||||
import lidarr from "./lidarr/widget";
|
import lidarr from "./lidarr/widget";
|
||||||
import mastodon from "./mastodon/widget";
|
import mastodon from "./mastodon/widget";
|
||||||
import medusa from "./medusa/widget";
|
import medusa from "./medusa/widget";
|
||||||
@ -78,6 +79,7 @@ const widgets = {
|
|||||||
jackett,
|
jackett,
|
||||||
jellyfin: emby,
|
jellyfin: emby,
|
||||||
jellyseerr,
|
jellyseerr,
|
||||||
|
komga,
|
||||||
lidarr,
|
lidarr,
|
||||||
mastodon,
|
mastodon,
|
||||||
medusa,
|
medusa,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user