diff --git a/public/locales/ar/common.json b/public/locales/ar/common.json index 276f37bc..d231138a 100644 --- a/public/locales/ar/common.json +++ b/public/locales/ar/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/bg/common.json b/public/locales/bg/common.json index 68dff21e..2e6fc021 100644 --- a/public/locales/bg/common.json +++ b/public/locales/bg/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ca/common.json b/public/locales/ca/common.json index 66287d51..040c0269 100644 --- a/public/locales/ca/common.json +++ b/public/locales/ca/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/cs/common.json b/public/locales/cs/common.json index 9d3304a2..c199fa5a 100644 --- a/public/locales/cs/common.json +++ b/public/locales/cs/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/da/common.json b/public/locales/da/common.json index 87214075..ebd2e3ab 100644 --- a/public/locales/da/common.json +++ b/public/locales/da/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 49b691ce..89f567fc 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/el/common.json b/public/locales/el/common.json index 5db2d2dc..0181311b 100644 --- a/public/locales/el/common.json +++ b/public/locales/el/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 9dd10d04..c1941a33 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -591,5 +591,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/eo/common.json b/public/locales/eo/common.json index d66f2684..53a7a699 100644 --- a/public/locales/eo/common.json +++ b/public/locales/eo/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index f4be257b..db3b36f4 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/fi/common.json b/public/locales/fi/common.json index c6e3dd10..0ddf3ce3 100644 --- a/public/locales/fi/common.json +++ b/public/locales/fi/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index eff53b03..79aba50d 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/he/common.json b/public/locales/he/common.json index acc05af5..c8cb7c28 100644 --- a/public/locales/he/common.json +++ b/public/locales/he/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index ba4ea214..9b53bf03 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/hr/common.json b/public/locales/hr/common.json index 485798b1..56f435e7 100644 --- a/public/locales/hr/common.json +++ b/public/locales/hr/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/hu/common.json b/public/locales/hu/common.json index 65fe4f6f..e10943eb 100644 --- a/public/locales/hu/common.json +++ b/public/locales/hu/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/it/common.json b/public/locales/it/common.json index 51d61a25..af001b45 100644 --- a/public/locales/it/common.json +++ b/public/locales/it/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index 29f40861..2707b686 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ko/common.json b/public/locales/ko/common.json index d4831d9c..2fff9b74 100644 --- a/public/locales/ko/common.json +++ b/public/locales/ko/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/lv/common.json b/public/locales/lv/common.json index 937b422d..b8dc9f6f 100644 --- a/public/locales/lv/common.json +++ b/public/locales/lv/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ms/common.json b/public/locales/ms/common.json index 91904316..48c9120d 100644 --- a/public/locales/ms/common.json +++ b/public/locales/ms/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/nb-NO/common.json b/public/locales/nb-NO/common.json index 53067bff..fc72ca69 100644 --- a/public/locales/nb-NO/common.json +++ b/public/locales/nb-NO/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index 5d69b197..160b9052 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/pl/common.json b/public/locales/pl/common.json index ee634e6b..6dcae2db 100644 --- a/public/locales/pl/common.json +++ b/public/locales/pl/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/pt-BR/common.json b/public/locales/pt-BR/common.json index 1efd556c..1a0bbc4f 100644 --- a/public/locales/pt-BR/common.json +++ b/public/locales/pt-BR/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/pt/common.json b/public/locales/pt/common.json index c21805df..0454c4bb 100644 --- a/public/locales/pt/common.json +++ b/public/locales/pt/common.json @@ -591,5 +591,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ro/common.json b/public/locales/ro/common.json index ac300f35..14bc9d3e 100644 --- a/public/locales/ro/common.json +++ b/public/locales/ro/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 86ed82d0..cbfa7d66 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/sk/common.json b/public/locales/sk/common.json index 63f9d7d0..5c3ded1a 100644 --- a/public/locales/sk/common.json +++ b/public/locales/sk/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/sl/common.json b/public/locales/sl/common.json index 86786adf..395910f4 100644 --- a/public/locales/sl/common.json +++ b/public/locales/sl/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/sr/common.json b/public/locales/sr/common.json index 7865cba6..b044f845 100644 --- a/public/locales/sr/common.json +++ b/public/locales/sr/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/sv/common.json b/public/locales/sv/common.json index 088871c4..c69833e1 100644 --- a/public/locales/sv/common.json +++ b/public/locales/sv/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/te/common.json b/public/locales/te/common.json index d3a82f36..86a8886d 100644 --- a/public/locales/te/common.json +++ b/public/locales/te/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/th/common.json b/public/locales/th/common.json index e0f5131e..bd30c6a1 100644 --- a/public/locales/th/common.json +++ b/public/locales/th/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/tr/common.json b/public/locales/tr/common.json index 88845467..f3325675 100644 --- a/public/locales/tr/common.json +++ b/public/locales/tr/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/uk/common.json b/public/locales/uk/common.json index feb137c6..6529f708 100644 --- a/public/locales/uk/common.json +++ b/public/locales/uk/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/vi/common.json b/public/locales/vi/common.json index 90803e06..fed5720b 100644 --- a/public/locales/vi/common.json +++ b/public/locales/vi/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/yue/common.json b/public/locales/yue/common.json index ed7681d7..5a5a6dea 100644 --- a/public/locales/yue/common.json +++ b/public/locales/yue/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index 3b2c6270..3efe50c5 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/public/locales/zh-Hant/common.json b/public/locales/zh-Hant/common.json index 3ea97e0d..cfd4f615 100644 --- a/public/locales/zh-Hant/common.json +++ b/public/locales/zh-Hant/common.json @@ -582,5 +582,10 @@ "whatsupdocker": { "monitoring": "Monitoring", "updates": "Updates" + }, + "nzbhydra2": { + "indexersenabled": "Enabled Indexers", + "mostpopular": "Most Popular Indexer", + "responsetime": "Average response time" } } diff --git a/src/utils/proxy/handlers/credentialed.js b/src/utils/proxy/handlers/credentialed.js index 93cdb995..21a20d2f 100644 --- a/src/utils/proxy/handlers/credentialed.js +++ b/src/utils/proxy/handlers/credentialed.js @@ -18,7 +18,7 @@ export default async function credentialedProxyHandler(req, res, map) { } if (widget) { - const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget })); + let url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget })); const headers = { "Content-Type": "application/json", @@ -54,6 +54,8 @@ export default async function credentialedProxyHandler(req, res, map) { } else { headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`; } + } else if (widget.type === "nzbhydra2") { + url += `?apikey=${widget.key}`; } else { headers["X-API-Key"] = `${widget.key}`; } diff --git a/src/widgets/components.js b/src/widgets/components.js index f8828f3b..a3776d02 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -46,6 +46,7 @@ const components = { nextdns: dynamic(() => import("./nextdns/component")), npm: dynamic(() => import("./npm/component")), nzbget: dynamic(() => import("./nzbget/component")), + nzbhydra2: dynamic(() => import("./nzbhydra2/component")), octoprint: dynamic(() => import("./octoprint/component")), omada: dynamic(() => import("./omada/component")), ombi: dynamic(() => import("./ombi/component")), diff --git a/src/widgets/nzbhydra2/component.jsx b/src/widgets/nzbhydra2/component.jsx new file mode 100644 index 00000000..a9077a41 --- /dev/null +++ b/src/widgets/nzbhydra2/component.jsx @@ -0,0 +1,51 @@ +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"; + +const calculateAverage = (key, data) => { + const count = data.length; + const sum = data.reduce((a,b) => a + b[key], 0); + const average = (sum / count).toFixed(1); + + return average; +} + +export default function Component({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + const { data: nzbhydra2Data, error: nzbhydra2Error } = useWidgetAPI(widget, "stats"); + + if (nzbhydra2Error) { + return ; + } + + if (!nzbhydra2Data) { + return ( + + + + + + ); + } + + const indexerCount = nzbhydra2Data.numberOfConfiguredIndexers; + const enabledIndexers = nzbhydra2Data.numberOfEnabledIndexers; + + + const highestDailyAccesses = Math.max(...nzbhydra2Data.indexerApiAccessStats.map(indexer => indexer.averageAccessesPerDay)); + const mostPopularIndexer = nzbhydra2Data.indexerApiAccessStats.find((indexer) => indexer.averageAccessesPerDay === highestDailyAccesses); + + const averageResponseTime = calculateAverage("avgResponseTime", nzbhydra2Data.avgResponseTimes); + + return ( + + + + + + ); +} diff --git a/src/widgets/nzbhydra2/widget.js b/src/widgets/nzbhydra2/widget.js new file mode 100644 index 00000000..df24a467 --- /dev/null +++ b/src/widgets/nzbhydra2/widget.js @@ -0,0 +1,14 @@ +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; + +const widget = { + api: "{url}/{endpoint}", + proxyHandler: credentialedProxyHandler, + + mappings: { + stats: { + endpoint: "api/stats", + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 9e155383..0ed52580 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -40,6 +40,7 @@ import nextcloud from "./nextcloud/widget"; import nextdns from "./nextdns/widget"; import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; +import nzbhydra2 from "./nzbhydra2/widget"; import octoprint from "./octoprint/widget"; import omada from "./omada/widget"; import ombi from "./ombi/widget"; @@ -122,6 +123,7 @@ const widgets = { nextdns, npm, nzbget, + nzbhydra2, octoprint, omada, ombi,