From fb2492e57744d835df896559906da052771716a3 Mon Sep 17 00:00:00 2001 From: Luis Brito Date: Fri, 16 Dec 2022 14:38:48 -0300 Subject: [PATCH] Adds widget for NextDNS --- src/widgets/components.js | 1 + src/widgets/nextdns/component.jsx | 31 +++++++++++++++++++++++++++++++ src/widgets/nextdns/widget.js | 17 +++++++++++++++++ src/widgets/widgets.js | 2 ++ 4 files changed, 51 insertions(+) create mode 100644 src/widgets/nextdns/component.jsx create mode 100644 src/widgets/nextdns/widget.js diff --git a/src/widgets/components.js b/src/widgets/components.js index b0752b62f..552e49346 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -22,6 +22,7 @@ const components = { lidarr: dynamic(() => import("./lidarr/component")), mastodon: dynamic(() => import("./mastodon/component")), navidrome: dynamic(() => import("./navidrome/component")), + nextdns: dynamic(() => import("./nextdns/component")), npm: dynamic(() => import("./npm/component")), nzbget: dynamic(() => import("./nzbget/component")), ombi: dynamic(() => import("./ombi/component")), diff --git a/src/widgets/nextdns/component.jsx b/src/widgets/nextdns/component.jsx new file mode 100644 index 000000000..75ef04f01 --- /dev/null +++ b/src/widgets/nextdns/component.jsx @@ -0,0 +1,31 @@ +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: nextdnsData, error: nextdnsError } = useWidgetAPI(widget, "analytics/status"); + + if (nextdnsError) { + return ; + } + + if (!nextdnsData) { + return ( + + No data + + ); + } + + return ( + + {nextdnsData?.data?.map(d => )} + + ); +} diff --git a/src/widgets/nextdns/widget.js b/src/widgets/nextdns/widget.js new file mode 100644 index 000000000..012ef0298 --- /dev/null +++ b/src/widgets/nextdns/widget.js @@ -0,0 +1,17 @@ +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; + +const widget = { + api: "https://api.nextdns.io/profiles/{profile}/{endpoint}", + proxyHandler: credentialedProxyHandler, + + mappings: { + "analytics/status": { + endpoint: "analytics/status", + validate: [ + "data", + ] + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index b3eaa8855..e89981648 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -17,6 +17,7 @@ import jellyseerr from "./jellyseerr/widget"; import lidarr from "./lidarr/widget"; import mastodon from "./mastodon/widget"; import navidrome from "./navidrome/widget"; +import nextdns from "./nextdns/widget"; import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; import ombi from "./ombi/widget"; @@ -66,6 +67,7 @@ const widgets = { lidarr, mastodon, navidrome, + nextdns, npm, nzbget, ombi,