diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 3681f9de6..0a9ebf6fe 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -382,5 +382,9 @@ "paperlessngx": { "inbox": "Inbox", "total": "Total" + }, + "nextdns": { + "wait": "Please Wait", + "no_devices": "No Device Data Received" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index 0ecce683f..eb7c686f7 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -23,6 +23,7 @@ const components = { mastodon: dynamic(() => import("./mastodon/component")), miniflux: dynamic(() => import("./miniflux/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..ae2397701 --- /dev/null +++ b/src/widgets/nextdns/component.jsx @@ -0,0 +1,39 @@ +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 ( + + + + ); + } + + if (!nextdnsData?.data?.length) { + return ( + + + + ); + } + + 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 7bb3c95da..2b45e55ad 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -18,6 +18,7 @@ import lidarr from "./lidarr/widget"; import mastodon from "./mastodon/widget"; import miniflux from "./miniflux/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"; @@ -69,6 +70,7 @@ const widgets = { mastodon, miniflux, navidrome, + nextdns, npm, nzbget, ombi,