Merge pull request #688 from luiseduardobrito/feat-nextdns
Adds widget for NextDNS
This commit is contained in:
commit
a11f22cd49
5 changed files with 63 additions and 0 deletions
|
@ -382,5 +382,9 @@
|
|||
"paperlessngx": {
|
||||
"inbox": "Inbox",
|
||||
"total": "Total"
|
||||
},
|
||||
"nextdns": {
|
||||
"wait": "Please Wait",
|
||||
"no_devices": "No Device Data Received"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")),
|
||||
|
|
39
src/widgets/nextdns/component.jsx
Normal file
39
src/widgets/nextdns/component.jsx
Normal file
|
@ -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>
|
||||
);
|
||||
}
|
17
src/widgets/nextdns/widget.js
Normal file
17
src/widgets/nextdns/widget.js
Normal file
|
@ -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 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,
|
||||
|
|
Loading…
Add table
Reference in a new issue