From 69dbe93c33491c757782e9483257b511057d6706 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Sat, 9 Dec 2023 11:08:47 +0000 Subject: [PATCH] working titlecardmaker widget --- public/locales/en/common.json | 12 ++++++ src/widgets/components.js | 1 + src/widgets/titlecardmaker/component.jsx | 52 ++++++++++++++++++++++++ src/widgets/titlecardmaker/widget.js | 14 +++++++ src/widgets/widgets.js | 2 + 5 files changed, 81 insertions(+) create mode 100644 src/widgets/titlecardmaker/component.jsx create mode 100644 src/widgets/titlecardmaker/widget.js diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 5e4324a1..7e6ea3e9 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -797,5 +797,17 @@ "digitalRelease": "Digital release", "noEventsToday": "No events for today!", "noEventsFound": "No events found" + }, + "titlecardmaker": { + "totalCards": "Total Cards", + "totalSeries": "Total Series", + "monitoredSeries": "Monitored Series", + "unmonitoredSeries": "Unmonitored Series", + "totalEpisodes": "Total Episodes", + "cardSize": "File Size Of Cards", + "totalFonts": "Total Fonts", + "totalTemplates": "Total Templates", + "totalSyncs": "Total Syncs", + "loadedCards": "Loaded Cards" } } \ No newline at end of file diff --git a/src/widgets/components.js b/src/widgets/components.js index cd9e2921..9bbb60de 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -96,6 +96,7 @@ const components = { tailscale: dynamic(() => import("./tailscale/component")), tautulli: dynamic(() => import("./tautulli/component")), tdarr: dynamic(() => import("./tdarr/component")), + titlecardmaker: dynamic(() => import("./titlecardmaker/component")), traefik: dynamic(() => import("./traefik/component")), transmission: dynamic(() => import("./transmission/component")), tubearchivist: dynamic(() => import("./tubearchivist/component")), diff --git a/src/widgets/titlecardmaker/component.jsx b/src/widgets/titlecardmaker/component.jsx new file mode 100644 index 00000000..a4e649b6 --- /dev/null +++ b/src/widgets/titlecardmaker/component.jsx @@ -0,0 +1,52 @@ +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 ( + + + + ); + } + + if (statisticsStatsError) { + return ; + } + + if (statistics) { + if (widget.fields) { + return ( + + + + + + + + + + + + + ); + } + return ( + + + + + + + ); + } +} \ No newline at end of file diff --git a/src/widgets/titlecardmaker/widget.js b/src/widgets/titlecardmaker/widget.js new file mode 100644 index 00000000..57059f07 --- /dev/null +++ b/src/widgets/titlecardmaker/widget.js @@ -0,0 +1,14 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + statistics: { + endpoint: "statistics", + } + }, +}; + +export default widget; \ No newline at end of file diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 0480554d..1f6e88d5 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -88,6 +88,7 @@ import strelaysrv from "./strelaysrv/widget"; import tailscale from "./tailscale/widget"; import tautulli from "./tautulli/widget"; import tdarr from "./tdarr/widget"; +import titlecardmaker from "./titlecardmaker/widget"; import traefik from "./traefik/widget"; import transmission from "./transmission/widget"; import tubearchivist from "./tubearchivist/widget"; @@ -196,6 +197,7 @@ const widgets = { tailscale, tautulli, tdarr, + titlecardmaker, traefik, transmission, tubearchivist,