Merge pull request #688 from luiseduardobrito/feat-nextdns

Adds widget for NextDNS
pull/702/head
shamoon 2 years ago committed by GitHub
commit a11f22cd49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -382,5 +382,9 @@
"paperlessngx": { "paperlessngx": {
"inbox": "Inbox", "inbox": "Inbox",
"total": "Total" "total": "Total"
},
"nextdns": {
"wait": "Please Wait",
"no_devices": "No Device Data Received"
} }
} }

@ -23,6 +23,7 @@ const components = {
mastodon: dynamic(() => import("./mastodon/component")), mastodon: dynamic(() => import("./mastodon/component")),
miniflux: dynamic(() => import("./miniflux/component")), miniflux: dynamic(() => import("./miniflux/component")),
navidrome: dynamic(() => import("./navidrome/component")), navidrome: dynamic(() => import("./navidrome/component")),
nextdns: dynamic(() => import("./nextdns/component")),
npm: dynamic(() => import("./npm/component")), npm: dynamic(() => import("./npm/component")),
nzbget: dynamic(() => import("./nzbget/component")), nzbget: dynamic(() => import("./nzbget/component")),
ombi: dynamic(() => import("./ombi/component")), ombi: dynamic(() => import("./ombi/component")),

@ -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 <Container error={nextdnsError} />;
}
if (!nextdnsData) {
return (
<Container service={service}>
<Block key="status" label="widget.status" value={t("nextdns.wait")} />
</Container>
);
}
if (!nextdnsData?.data?.length) {
return (
<Container service={service}>
<Block key="status" label="widget.status" value={t("nextdns.no_devices")} />
</Container>
);
}
return (
<Container service={service}>
{nextdnsData.data.map(d => <Block key={d.status} label={d.status} value={t("common.number", { value: d.queries })} />)}
</Container>
);
}

@ -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;

@ -18,6 +18,7 @@ import lidarr from "./lidarr/widget";
import mastodon from "./mastodon/widget"; import mastodon from "./mastodon/widget";
import miniflux from "./miniflux/widget"; import miniflux from "./miniflux/widget";
import navidrome from "./navidrome/widget"; import navidrome from "./navidrome/widget";
import nextdns from "./nextdns/widget";
import npm from "./npm/widget"; import npm from "./npm/widget";
import nzbget from "./nzbget/widget"; import nzbget from "./nzbget/widget";
import ombi from "./ombi/widget"; import ombi from "./ombi/widget";
@ -69,6 +70,7 @@ const widgets = {
mastodon, mastodon,
miniflux, miniflux,
navidrome, navidrome,
nextdns,
npm, npm,
nzbget, nzbget,
ombi, ombi,

Loading…
Cancel
Save