working romm widget

This commit is contained in:
Karl Hudgell 2023-12-31 16:20:30 +00:00
parent d3427e1bfc
commit 266cfe7a93
5 changed files with 57 additions and 0 deletions

View File

@ -809,5 +809,9 @@
"totalTemplates": "Total Templates",
"totalSyncs": "Total Syncs",
"loadedCards": "Loaded Cards"
},
"romm": {
"platforms": "Platforms",
"totalRoms": "Total ROMs"
}
}

View File

@ -87,6 +87,7 @@ const components = {
qnap: dynamic(() => import("./qnap/component")),
radarr: dynamic(() => import("./radarr/component")),
readarr: dynamic(() => import("./readarr/component")),
romm: dynamic(() => import("./romm/component")),
rutorrent: dynamic(() => import("./rutorrent/component")),
sabnzbd: dynamic(() => import("./sabnzbd/component")),
scrutiny: dynamic(() => import("./scrutiny/component")),

View 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 { data: statistics, error: statisticsStatsError } = useWidgetAPI(widget, "statistics");
if (statisticsStatsError) {
return (
<Container service={service}>
<Block label="Error" value={statisticsStatsError.message} />
</Container>
);
}
if (statisticsStatsError) {
return <Container service={service} error={statisticsStatsError} />;
}
if (statistics) {
const platforms = statistics.filter(x => x.n_roms!=0).length
const totalRoms = statistics.reduce((total, stat) => total + stat.n_roms, 0);
return (
<Container service={service}>
<Block label="romm.platforms" value={platforms} />
<Block label="romm.totalRoms" value={totalRoms} />
</Container>
);
}
}

View File

@ -0,0 +1,14 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/api/{endpoint}",
proxyHandler: genericProxyHandler,
mappings: {
statistics: {
endpoint: "platforms",
}
},
};
export default widget;

View File

@ -79,6 +79,7 @@ import qbittorrent from "./qbittorrent/widget";
import qnap from "./qnap/widget";
import radarr from "./radarr/widget";
import readarr from "./readarr/widget";
import romm from "./romm/widget";
import rutorrent from "./rutorrent/widget";
import sabnzbd from "./sabnzbd/widget";
import scrutiny from "./scrutiny/widget";
@ -188,6 +189,7 @@ const widgets = {
qnap,
radarr,
readarr,
romm,
rutorrent,
sabnzbd,
scrutiny,