From 2845990fe64cc5c2f1366caf3ea3c4ae26898b17 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Wed, 17 Jan 2024 16:33:32 +0000 Subject: [PATCH] changes to add romm --- public/locales/en/common.json | 4 ++++ src/widgets/components.js | 1 + src/widgets/romm/component.jsx | 32 ++++++++++++++++++++++++++++++++ src/widgets/romm/widget.js | 14 ++++++++++++++ src/widgets/widgets.js | 2 ++ 5 files changed, 53 insertions(+) create mode 100644 src/widgets/romm/component.jsx create mode 100644 src/widgets/romm/widget.js diff --git a/public/locales/en/common.json b/public/locales/en/common.json index bf39f1d9..0bb1f0e1 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -794,5 +794,9 @@ "digitalRelease": "Digital release", "noEventsToday": "No events for today!", "noEventsFound": "No events found" + }, + "romm": { + "platforms": "Platforms", + "totalRoms": "Total ROMs" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index 4209b69a..4ac55437 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -86,6 +86,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..098d8362 --- /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.rom_count !== 0).length + const totalRoms = response.reduce((total, stat) => total + stat.rom_count, 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..a1cbd738 --- /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 904bd701..4d970a7e 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -100,6 +100,7 @@ import watchtower from "./watchtower/widget"; import whatsupdocker from "./whatsupdocker/widget"; import xteve from "./xteve/widget"; import urbackup from "./urbackup/widget"; +import romm from "./romm/widget"; const widgets = { adguard, @@ -184,6 +185,7 @@ const widgets = { qnap, radarr, readarr, + romm, rutorrent, sabnzbd, scrutiny,