diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 6ab72683..8ba3c44a 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -818,5 +818,9 @@ "totalTemplates": "Total Templates", "totalSyncs": "Total Syncs", "loadedCards": "Loaded Cards" + }, + "romm": { + "platforms": "Platforms", + "totalRoms": "Total ROMs" } } \ No newline at end of file diff --git a/src/widgets/components.js b/src/widgets/components.js index 223aed5c..14a09cec 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -88,6 +88,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")), diff --git a/src/widgets/romm/component.jsx b/src/widgets/romm/component.jsx new file mode 100644 index 00000000..c84669d1 --- /dev/null +++ b/src/widgets/romm/component.jsx @@ -0,0 +1,32 @@ +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: response, error: responseError } = useWidgetAPI(widget, "statistics"); + + if (responseError) { + return ( + + + + ); + } + + if (responseError) { + return ; + } + + if (response) { + const platforms = response.filter(x => x.n_roms!==0).length + const totalRoms = response.reduce((total, stat) => total + stat.n_roms, 0); + return ( + + + + + ); + } +} \ No newline at end of file diff --git a/src/widgets/romm/widget.js b/src/widgets/romm/widget.js new file mode 100644 index 00000000..ee80f9bc --- /dev/null +++ b/src/widgets/romm/widget.js @@ -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; \ No newline at end of file diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 8a14e289..f4091f63 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -80,6 +80,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"; @@ -190,6 +191,7 @@ const widgets = { qnap, radarr, readarr, + romm, rutorrent, sabnzbd, scrutiny,