Merge pull request #935 from KillahB33/Mylar

Mylar widget
pull/940/head
shamoon 2 years ago committed by GitHub
commit 46d4b3e19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -460,5 +460,10 @@
"libraries": "Libraries",
"series": "Series",
"books": "Books"
},
"mylar": {
"series": "Series",
"issues": "Issues",
"wanted": "Wanted"
}
}

@ -28,6 +28,7 @@ const components = {
miniflux: dynamic(() => import("./miniflux/component")),
mikrotik: dynamic(() => import("./mikrotik/component")),
moonraker: dynamic(() => import("./moonraker/component")),
mylar: dynamic(() => import("./mylar/component")),
navidrome: dynamic(() => import("./navidrome/component")),
nextdns: dynamic(() => import("./nextdns/component")),
npm: dynamic(() => import("./npm/component")),

@ -0,0 +1,40 @@
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: seriesData, error: seriesError } = useWidgetAPI(widget, "series");
const { data: issuesData, error: issuesError } = useWidgetAPI(widget, "issues");
const { data: wantedData, error: wantedError } = useWidgetAPI(widget, "wanted");
if (seriesError || issuesError || wantedError) {
const finalError = seriesError ?? issuesError ?? wantedError;
return <Container error={finalError} />;
}
if (!seriesData || !issuesData || !wantedData) {
return (
<Container service={service}>
<Block label="mylar.series" />
<Block label="mylar.issues" />
<Block label="mylar.wanted" />
</Container>
);
}
const totalIssues = issuesData.data.reduce((acc, series) => acc + series.totalIssues, 0);
return (
<Container service={service}>
<Block label="mylar.series" value={t("common.number", { value: seriesData.data.length })} />
<Block label="mylar.issues" value={t("common.number", { value: totalIssues })} />
<Block label="mylar.wanted" value={t("common.number", { value: wantedData.issues.length })} />
</Container>
);
}

@ -0,0 +1,20 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/api?cmd={endpoint}&apikey={key}",
proxyHandler: genericProxyHandler,
mappings: {
issues: {
endpoint: "getIndex"
},
series: {
endpoint: "seriesjsonListing"
},
wanted: {
endpoint: "getWanted"
},
},
};
export default widget;

@ -22,6 +22,7 @@ import medusa from "./medusa/widget";
import miniflux from "./miniflux/widget";
import mikrotik from "./mikrotik/widget";
import moonraker from "./moonraker/widget";
import mylar from "./mylar/widget";
import navidrome from "./navidrome/widget";
import nextdns from "./nextdns/widget";
import npm from "./npm/widget";
@ -87,6 +88,7 @@ const widgets = {
miniflux,
mikrotik,
moonraker,
mylar,
navidrome,
nextdns,
npm,

Loading…
Cancel
Save