WIP: Add maintainerr widget
This commit is contained in:
parent
0a75c831a6
commit
edaab688bb
@ -111,6 +111,7 @@ export async function servicesResponse() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
configuredServices = cleanServiceGroups(await servicesFromConfig());
|
configuredServices = cleanServiceGroups(await servicesFromConfig());
|
||||||
|
console.log({configuredServices: configuredServices[2]})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to load services.yaml, please check for errors");
|
console.error("Failed to load services.yaml, please check for errors");
|
||||||
if (e) console.error(e.toString());
|
if (e) console.error(e.toString());
|
||||||
|
|||||||
@ -434,6 +434,9 @@ export function cleanServiceGroups(groups) {
|
|||||||
namespace,
|
namespace,
|
||||||
podSelector,
|
podSelector,
|
||||||
|
|
||||||
|
// maintainerr
|
||||||
|
collectionId,
|
||||||
|
|
||||||
// mjpeg
|
// mjpeg
|
||||||
fit,
|
fit,
|
||||||
stream,
|
stream,
|
||||||
@ -564,6 +567,10 @@ export function cleanServiceGroups(groups) {
|
|||||||
if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit;
|
if (pointsLimit) cleanedService.widget.pointsLimit = pointsLimit;
|
||||||
if (diskUnits) cleanedService.widget.diskUnits = diskUnits;
|
if (diskUnits) cleanedService.widget.diskUnits = diskUnits;
|
||||||
}
|
}
|
||||||
|
if (type === "maintainerr") {
|
||||||
|
if (collectionId) cleanedService.widget.collectionId = collectionId;
|
||||||
|
console.log({ collectionId, cleanedService });
|
||||||
|
}
|
||||||
if (type === "mjpeg") {
|
if (type === "mjpeg") {
|
||||||
if (stream) cleanedService.widget.stream = stream;
|
if (stream) cleanedService.widget.stream = stream;
|
||||||
if (fit) cleanedService.widget.fit = fit;
|
if (fit) cleanedService.widget.fit = fit;
|
||||||
|
|||||||
@ -99,7 +99,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
return res
|
return res
|
||||||
.status(500)
|
.status(500)
|
||||||
.json({ error: { message: "Invalid data", url: sanitizeErrorURL(url), data: resultData } });
|
.json({ error: { message: "Invalid data", url: sanitizeErrorURL(url), data: resultData } });
|
||||||
}
|
}
|
||||||
if (map) resultData = map(resultData);
|
if (map) resultData = map(resultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ export default function validateWidgetData(widget, endpoint, data) {
|
|||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataParsed && Object.entries(dataParsed).length) {
|
if (dataParsed && Object.entries(dataParsed).length) {
|
||||||
const mappings = widgets[widget.type]?.mappings;
|
const mappings = widgets[widget.type]?.mappings;
|
||||||
if (mappings) {
|
if (mappings) {
|
||||||
|
|||||||
@ -53,6 +53,7 @@ const components = {
|
|||||||
komga: dynamic(() => import("./komga/component")),
|
komga: dynamic(() => import("./komga/component")),
|
||||||
kopia: dynamic(() => import("./kopia/component")),
|
kopia: dynamic(() => import("./kopia/component")),
|
||||||
lidarr: dynamic(() => import("./lidarr/component")),
|
lidarr: dynamic(() => import("./lidarr/component")),
|
||||||
|
maintainerr: dynamic(() => import("./maintainerr/component")),
|
||||||
mastodon: dynamic(() => import("./mastodon/component")),
|
mastodon: dynamic(() => import("./mastodon/component")),
|
||||||
mealie: dynamic(() => import("./mealie/component")),
|
mealie: dynamic(() => import("./mealie/component")),
|
||||||
medusa: dynamic(() => import("./medusa/component")),
|
medusa: dynamic(() => import("./medusa/component")),
|
||||||
|
|||||||
36
src/widgets/maintainerr/component.jsx
Normal file
36
src/widgets/maintainerr/component.jsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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 { categoryId } = widget;
|
||||||
|
|
||||||
|
console.log({categoryId});
|
||||||
|
|
||||||
|
const { data: collections, error: statsError } = useWidgetAPI(widget, "collections");
|
||||||
|
|
||||||
|
if (statsError) {
|
||||||
|
return <Container service={service} error={statsError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!collections) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="overseerr.pending" />
|
||||||
|
<Block label="overseerr.processing" />
|
||||||
|
<Block label="overseerr.approved" />
|
||||||
|
<Block label="overseerr.available" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="overseerr.pending" value={t("common.number", { value: collections.length })} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
9
src/widgets/maintainerr/widget.js
Normal file
9
src/widgets/maintainerr/widget.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
import { asJson, jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -45,6 +45,7 @@ import kavita from "./kavita/widget";
|
|||||||
import komga from "./komga/widget";
|
import komga from "./komga/widget";
|
||||||
import kopia from "./kopia/widget";
|
import kopia from "./kopia/widget";
|
||||||
import lidarr from "./lidarr/widget";
|
import lidarr from "./lidarr/widget";
|
||||||
|
import maintainerr from "./maintainerr/widget";
|
||||||
import mastodon from "./mastodon/widget";
|
import mastodon from "./mastodon/widget";
|
||||||
import mealie from "./mealie/widget";
|
import mealie from "./mealie/widget";
|
||||||
import medusa from "./medusa/widget";
|
import medusa from "./medusa/widget";
|
||||||
@ -162,6 +163,7 @@ const widgets = {
|
|||||||
komga,
|
komga,
|
||||||
kopia,
|
kopia,
|
||||||
lidarr,
|
lidarr,
|
||||||
|
maintainerr,
|
||||||
mastodon,
|
mastodon,
|
||||||
mealie,
|
mealie,
|
||||||
medusa,
|
medusa,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user