diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 46a69588e..cc946e783 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -325,5 +325,10 @@ "active": "Active", "queue": "Queue", "total": "Total" + }, + "gluetun": { + "public_ip": "Public IP", + "region": "Region", + "country": "Country" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index f501e0128..a8a06e770 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -9,6 +9,7 @@ const components = { coinmarketcap: dynamic(() => import("./coinmarketcap/component")), docker: dynamic(() => import("./docker/component")), emby: dynamic(() => import("./emby/component")), + gluetun: dynamic(() => import("./gluetun/component")), gotify: dynamic(() => import("./gotify/component")), homebridge: dynamic(() => import("./homebridge/component")), jackett: dynamic(() => import("./jackett/component")), diff --git a/src/widgets/gluetun/component.jsx b/src/widgets/gluetun/component.jsx new file mode 100644 index 000000000..f20c400b9 --- /dev/null +++ b/src/widgets/gluetun/component.jsx @@ -0,0 +1,35 @@ +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: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip"); + + if (gluetunError) { + return ; + } + + if (!gluetunData) { + return ( + + + + + + ); + } + + return ( + + + + + + ); +} diff --git a/src/widgets/gluetun/widget.js b/src/widgets/gluetun/widget.js new file mode 100644 index 000000000..59aa39efe --- /dev/null +++ b/src/widgets/gluetun/widget.js @@ -0,0 +1,14 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/v1/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + ip: { + endpoint: "publicip/ip", + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index fd67357d2..66e29086a 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -5,6 +5,7 @@ import bazarr from "./bazarr/widget"; import changedetectionio from "./changedetectionio/widget"; import coinmarketcap from "./coinmarketcap/widget"; import emby from "./emby/widget"; +import gluetun from "./gluetun/widget"; import gotify from "./gotify/widget"; import homebridge from "./homebridge/widget"; import jackett from "./jackett/widget"; @@ -46,6 +47,7 @@ const widgets = { changedetectionio, coinmarketcap, emby, + gluetun, gotify, homebridge, jackett,