From b520713dc324fd9e4dfc430d6051f4ab95522621 Mon Sep 17 00:00:00 2001 From: Jason Fischer Date: Wed, 14 Sep 2022 16:15:26 -0700 Subject: [PATCH] Add Bazarr widget associated: #110 --- public/locales/en/common.json | 4 +++ src/components/services/widget.jsx | 2 ++ .../services/widgets/service/bazarr.jsx | 36 +++++++++++++++++++ src/pages/api/services/proxy.js | 1 + src/utils/api-helpers.js | 1 + 5 files changed, 44 insertions(+) create mode 100644 src/components/services/widgets/service/bazarr.jsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index b81009351..6fe1f98f4 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -85,6 +85,10 @@ "queued": "Queued", "books": "Books" }, + "bazarr": { + "missingEpisodes": "Missing Episodes", + "missingMovies": "Missing Movies" + }, "ombi": { "pending": "Pending", "approved": "Approved", diff --git a/src/components/services/widget.jsx b/src/components/services/widget.jsx index 0bb5c08d5..9a7254ef2 100644 --- a/src/components/services/widget.jsx +++ b/src/components/services/widget.jsx @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import Sonarr from "./widgets/service/sonarr"; import Radarr from "./widgets/service/radarr"; import Readarr from "./widgets/service/readarr"; +import Bazarr from "./widgets/service/bazarr"; import Ombi from "./widgets/service/ombi"; import Portainer from "./widgets/service/portainer"; import Emby from "./widgets/service/emby"; @@ -29,6 +30,7 @@ const widgetMappings = { sonarr: Sonarr, radarr: Radarr, readarr: Readarr, + bazarr: Bazarr, ombi: Ombi, portainer: Portainer, emby: Emby, diff --git a/src/components/services/widgets/service/bazarr.jsx b/src/components/services/widgets/service/bazarr.jsx new file mode 100644 index 000000000..030af3f40 --- /dev/null +++ b/src/components/services/widgets/service/bazarr.jsx @@ -0,0 +1,36 @@ +import useSWR from "swr"; +import { useTranslation } from "react-i18next"; + +import Widget from "../widget"; +import Block from "../block"; + +import { formatApiUrl } from "utils/api-helpers"; + +export default function Bazarr({ service }) { + const { t } = useTranslation(); + + const config = service.widget; + + const { data: episodesData, error: episodesError } = useSWR(formatApiUrl(config, "episodes")); + const { data: moviesData, error: moviesError } = useSWR(formatApiUrl(config, "movies")); + + if (episodesError || moviesError) { + return ; + } + + if (!episodesData || !moviesData) { + return ( + + + + + ); + } + + return ( + + + + + ); +} diff --git a/src/pages/api/services/proxy.js b/src/pages/api/services/proxy.js index 9e3a57ff8..4a18fca63 100644 --- a/src/pages/api/services/proxy.js +++ b/src/pages/api/services/proxy.js @@ -13,6 +13,7 @@ const serviceProxyHandlers = { radarr: genericProxyHandler, sonarr: genericProxyHandler, readarr: genericProxyHandler, + bazarr: genericProxyHandler, speedtest: genericProxyHandler, tautulli: genericProxyHandler, traefik: genericProxyHandler, diff --git a/src/utils/api-helpers.js b/src/utils/api-helpers.js index 2c1929df9..cf0ea99ac 100644 --- a/src/utils/api-helpers.js +++ b/src/utils/api-helpers.js @@ -15,6 +15,7 @@ const formats = { ombi: `{url}/api/v1/{endpoint}`, npm: `{url}/api/{endpoint}`, readarr: `{url}/api/v1/{endpoint}?apikey={key}`, + bazarr: `{url}/api/{endpoint}/wanted?apikey={key}`, sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`, coinmarketcap: `https://pro-api.coinmarketcap.com/{endpoint}`, gotify: `{url}/{endpoint}`,