Add Medusa widget

pull/832/head
Ulysse Mensa 2 years ago
parent a04c7677e4
commit 2a24277757

@ -255,6 +255,11 @@
"status_count": "Posts",
"domain_count": "Domains"
},
"medusa": {
"wanted": "Wanted",
"queued": "Queued",
"series": "Series"
},
"miniflux": {
"read": "Read",
"unread": "Unread"
@ -413,4 +418,4 @@
"wanUpload": "WAN Upload",
"wanDownload": "WAN Download"
}
}
}

@ -21,6 +21,7 @@ const components = {
jellyseerr: dynamic(() => import("./jellyseerr/component")),
lidarr: dynamic(() => import("./lidarr/component")),
mastodon: dynamic(() => import("./mastodon/component")),
medusa: dynamic(() => import("./medusa/component")),
miniflux: dynamic(() => import("./miniflux/component")),
mikrotik: dynamic(() => import("./mikrotik/component")),
navidrome: dynamic(() => import("./navidrome/component")),

@ -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: futureData, error: futureError } = useWidgetAPI(widget, "future");
if (statsError || futureError) {
const finalError = statsError ?? futureError;
return <Container error={finalError} />;
}
if (!statsData || !futureData) {
return (
<Container service={service}>
<Block label="medusa.wanted" />
<Block label="medusa.queued" />
<Block label="medusa.series" />
</Container>
);
}
const { later, missed, soon, today } = futureData.data;
const future = later.length + missed.length + soon.length + today.length;
return (
<Container service={service}>
<Block label="medusa.wanted" value={t("common.number", { value: future })} />
<Block label="medusa.queued" value={t("common.number", { value: statsData.data.ep_snatched })} />
<Block label="medusa.series" value={t("common.number", { value: statsData.data.shows_active })} />
</Container>
);
}

@ -0,0 +1,23 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/api/v1/{key}/{endpoint}/",
proxyHandler: genericProxyHandler,
mappings: {
stats: {
endpoint: "?cmd=shows.stats",
validate: [
"data"
]
},
future: {
endpoint: "?cmd=future",
validate: [
"data"
]
}
}
};
export default widget;

@ -16,6 +16,7 @@ import jackett from "./jackett/widget";
import jellyseerr from "./jellyseerr/widget";
import lidarr from "./lidarr/widget";
import mastodon from "./mastodon/widget";
import medusa from "./medusa/widget";
import miniflux from "./miniflux/widget";
import mikrotik from "./mikrotik/widget";
import navidrome from "./navidrome/widget";
@ -73,6 +74,7 @@ const widgets = {
jellyseerr,
lidarr,
mastodon,
medusa,
miniflux,
mikrotik,
navidrome,

Loading…
Cancel
Save