diff --git a/src/components/bookmarks/item.jsx b/src/components/bookmarks/item.jsx index c3c5b452f..b87d4a563 100644 --- a/src/components/bookmarks/item.jsx +++ b/src/components/bookmarks/item.jsx @@ -1,6 +1,6 @@ import { useContext } from "react"; -import { SettingsContext } from "utils/settings-context"; +import { SettingsContext } from "utils/contexts/settings"; export default function Item({ bookmark }) { const { hostname } = new URL(bookmark.href); diff --git a/src/components/color-toggle.jsx b/src/components/color-toggle.jsx index c05fb2f2c..aab94d728 100644 --- a/src/components/color-toggle.jsx +++ b/src/components/color-toggle.jsx @@ -3,7 +3,7 @@ import { IoColorPalette } from "react-icons/io5"; import { Popover, Transition } from "@headlessui/react"; import classNames from "classnames"; -import { ColorContext } from "utils/color-context"; +import { ColorContext } from "utils/contexts/color"; const colors = [ "slate", diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 7974789f6..efbf9076a 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -6,7 +6,7 @@ import Status from "./status"; import Widget from "./widget"; import Docker from "widgets/docker/component"; -import { SettingsContext } from "utils/settings-context"; +import { SettingsContext } from "utils/contexts/settings"; function resolveIcon(icon) { if (icon.startsWith("http")) { @@ -85,14 +85,16 @@ export default function Item({ service }) { )} -
- -
+ {service.container && service.server && ( +
+ +
+ )} {service.widget && } diff --git a/src/components/theme-toggle.jsx b/src/components/theme-toggle.jsx index ecbb17620..3cc1fccf4 100644 --- a/src/components/theme-toggle.jsx +++ b/src/components/theme-toggle.jsx @@ -1,7 +1,7 @@ import { useContext } from "react"; import { MdDarkMode, MdLightMode, MdToggleOff, MdToggleOn } from "react-icons/md"; -import { ThemeContext } from "utils/theme-context"; +import { ThemeContext } from "utils/contexts/theme"; export default function ThemeToggle() { const { theme, setTheme } = useContext(ThemeContext); diff --git a/src/components/widget.jsx b/src/components/widget.jsx index ae5795426..a5ed1eb35 100644 --- a/src/components/widget.jsx +++ b/src/components/widget.jsx @@ -1,18 +1,12 @@ -import WeatherApi from "components/widgets/weather/weather"; -import OpenWeatherMap from "components/widgets/openweathermap/weather"; -import Resources from "components/widgets/resources/resources"; -import Search from "components/widgets/search/search"; -import Greeting from "components/widgets/greeting/greeting"; -import DateTime from "components/widgets/datetime/datetime"; +import dynamic from "next/dynamic"; const widgetMappings = { - weather: WeatherApi, // This key will be deprecated in the future - weatherapi: WeatherApi, - openweathermap: OpenWeatherMap, - resources: Resources, - search: Search, - greeting: Greeting, - datetime: DateTime, + weatherapi: dynamic(() => import("components/widgets/weather/weather")), + openweathermap: dynamic(() => import("components/widgets/openweathermap/weather")), + resources: dynamic(() => import("components/widgets/resources/resources")), + search: dynamic(() => import("components/widgets/search/search")), + greeting: dynamic(() => import("components/widgets/greeting/greeting")), + datetime: dynamic(() => import("components/widgets/datetime/datetime")), }; export default function Widget({ widget }) { diff --git a/src/components/widgets/openweathermap/icon.jsx b/src/components/widgets/openweathermap/icon.jsx index da65bc918..a2b01ba19 100644 --- a/src/components/widgets/openweathermap/icon.jsx +++ b/src/components/widgets/openweathermap/icon.jsx @@ -1,4 +1,4 @@ -import mapIcon from "utils/owm-condition-map"; +import mapIcon from "utils/weather/owm-condition-map"; export default function Icon({ condition, timeOfDay }) { const IconComponent = mapIcon(condition, timeOfDay); diff --git a/src/components/widgets/openweathermap/weather.jsx b/src/components/widgets/openweathermap/weather.jsx index 5c78d74ca..9037eb3a8 100644 --- a/src/components/widgets/openweathermap/weather.jsx +++ b/src/components/widgets/openweathermap/weather.jsx @@ -80,20 +80,22 @@ export default function OpenWeatherMap({ options }) { const requestLocation = () => { setRequesting(true); - navigator.geolocation.getCurrentPosition( - (position) => { - setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude }); - setRequesting(false); - }, - () => { - setRequesting(false); - }, - { - enableHighAccuracy: true, - maximumAge: 1000 * 60 * 60 * 3, - timeout: 1000 * 30, - } - ); + if (typeof window !== "undefined") { + navigator.geolocation.getCurrentPosition( + (position) => { + setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude }); + setRequesting(false); + }, + () => { + setRequesting(false); + }, + { + enableHighAccuracy: true, + maximumAge: 1000 * 60 * 60 * 3, + timeout: 1000 * 30, + } + ); + } }; if (!requesting && !location) requestLocation(); diff --git a/src/components/widgets/weather/icon.jsx b/src/components/widgets/weather/icon.jsx index e501b0a8b..79406ae77 100644 --- a/src/components/widgets/weather/icon.jsx +++ b/src/components/widgets/weather/icon.jsx @@ -1,4 +1,4 @@ -import mapIcon from "utils/condition-map"; +import mapIcon from "utils/weather/condition-map"; export default function Icon({ condition, timeOfDay }) { const IconComponent = mapIcon(condition, timeOfDay); diff --git a/src/components/widgets/weather/weather.jsx b/src/components/widgets/weather/weather.jsx index 9fe3b2421..1c92f839e 100644 --- a/src/components/widgets/weather/weather.jsx +++ b/src/components/widgets/weather/weather.jsx @@ -81,20 +81,22 @@ export default function WeatherApi({ options }) { const requestLocation = () => { setRequesting(true); - navigator.geolocation.getCurrentPosition( - (position) => { - setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude }); - setRequesting(false); - }, - () => { - setRequesting(false); - }, - { - enableHighAccuracy: true, - maximumAge: 1000 * 60 * 60 * 3, - timeout: 1000 * 30, - } - ); + if (typeof window !== "undefined") { + navigator.geolocation.getCurrentPosition( + (position) => { + setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude }); + setRequesting(false); + }, + () => { + setRequesting(false); + }, + { + enableHighAccuracy: true, + maximumAge: 1000 * 60 * 60 * 3, + timeout: 1000 * 30, + } + ); + } }; if (!requesting && !location) requestLocation(); diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index 6cdef8a0f..e87bd90ae 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -7,9 +7,9 @@ import "styles/theme.css"; import "styles/manrope.css"; import nextI18nextConfig from "../../next-i18next.config"; -import { ColorProvider } from "utils/color-context"; -import { ThemeProvider } from "utils/theme-context"; -import { SettingsProvider } from "utils/settings-context"; +import { ColorProvider } from "utils/contexts/color"; +import { ThemeProvider } from "utils/contexts/theme"; +import { SettingsProvider } from "utils/contexts/settings"; function MyApp({ Component, pageProps }) { return ( diff --git a/src/pages/api/bookmarks.js b/src/pages/api/bookmarks.js index c50add448..63d1e29ed 100644 --- a/src/pages/api/bookmarks.js +++ b/src/pages/api/bookmarks.js @@ -1,25 +1,5 @@ -import { promises as fs } from "fs"; -import path from "path"; - -import yaml from "js-yaml"; - -import checkAndCopyConfig from "utils/config"; +import { bookmarksResponse } from "utils/config/api-response"; export default async function handler(req, res) { - checkAndCopyConfig("bookmarks.yaml"); - - const bookmarksYaml = path.join(process.cwd(), "config", "bookmarks.yaml"); - const fileContents = await fs.readFile(bookmarksYaml, "utf8"); - const bookmarks = yaml.load(fileContents); - - // map easy to write YAML objects into easy to consume JS arrays - const bookmarksArray = bookmarks.map((group) => ({ - name: Object.keys(group)[0], - bookmarks: group[Object.keys(group)[0]].map((entries) => ({ - name: Object.keys(entries)[0], - ...entries[Object.keys(entries)[0]][0], - })), - })); - - res.send(bookmarksArray); + res.send(await bookmarksResponse()); } diff --git a/src/pages/api/proxy.js b/src/pages/api/proxy.js index ff7ca357b..7ab95edcc 100644 --- a/src/pages/api/proxy.js +++ b/src/pages/api/proxy.js @@ -2,7 +2,7 @@ import https from "https"; import getRawBody from "raw-body"; -import { httpRequest, httpsRequest } from "utils/http"; +import { httpRequest, httpsRequest } from "utils/proxy/http"; export const config = { api: { diff --git a/src/pages/api/services/index.js b/src/pages/api/services/index.js index 52951fbb2..46d0a721f 100644 --- a/src/pages/api/services/index.js +++ b/src/pages/api/services/index.js @@ -1,43 +1,5 @@ -/* eslint-disable no-console */ -import { servicesFromConfig, servicesFromDocker, cleanServiceGroups } from "utils/service-helpers"; +import { servicesResponse } from "utils/config/api-response"; export default async function handler(req, res) { - let discoveredServices; - let configuredServices; - - try { - discoveredServices = cleanServiceGroups(await servicesFromDocker()); - } catch (e) { - console.error("Failed to discover services, please check docker.yaml for errors or remove example entries."); - console.error(e); - discoveredServices = []; - } - - try { - configuredServices = cleanServiceGroups(await servicesFromConfig()); - } catch (e) { - console.error("Failed to load services.yaml, please check for errors"); - console.error(e); - configuredServices = []; - } - - const mergedGroupsNames = [ - ...new Set([discoveredServices.map((group) => group.name), configuredServices.map((group) => group.name)].flat()), - ]; - - const mergedGroups = []; - - mergedGroupsNames.forEach((groupName) => { - const discoveredGroup = discoveredServices.find((group) => group.name === groupName) || { services: [] }; - const configuredGroup = configuredServices.find((group) => group.name === groupName) || { services: [] }; - - const mergedGroup = { - name: groupName, - services: [...discoveredGroup.services, ...configuredGroup.services].filter((service) => service), - }; - - mergedGroups.push(mergedGroup); - }); - - res.send(mergedGroups); + res.send(await servicesResponse()); } diff --git a/src/pages/api/services/proxy.js b/src/pages/api/services/proxy.js index 895f86178..31c21a98f 100644 --- a/src/pages/api/services/proxy.js +++ b/src/pages/api/services/proxy.js @@ -1,6 +1,6 @@ -import { formatApiCall } from "utils/api-helpers"; +import { formatApiCall } from "utils/proxy/api-helpers"; import createLogger from "utils/logger"; -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; import widgets from "widgets/widgets"; const logger = createLogger("servicesProxy"); diff --git a/src/pages/api/widgets/index.js b/src/pages/api/widgets/index.js index 3e96c26b5..513e02e91 100644 --- a/src/pages/api/widgets/index.js +++ b/src/pages/api/widgets/index.js @@ -1,22 +1,5 @@ -import { promises as fs } from "fs"; -import path from "path"; - -import yaml from "js-yaml"; - -import checkAndCopyConfig from "utils/config"; +import { widgetsResponse } from "utils/config/api-response"; export default async function handler(req, res) { - checkAndCopyConfig("widgets.yaml"); - - const widgetsYaml = path.join(process.cwd(), "config", "widgets.yaml"); - const fileContents = await fs.readFile(widgetsYaml, "utf8"); - const widgets = yaml.load(fileContents); - - // map easy to write YAML objects into easy to consume JS arrays - const widgetsArray = widgets.map((group) => ({ - type: Object.keys(group)[0], - options: { ...group[Object.keys(group)[0]] }, - })); - - res.send(widgetsArray); + res.send(await widgetsResponse()); } diff --git a/src/pages/api/widgets/openweathermap.js b/src/pages/api/widgets/openweathermap.js index 93eeb93db..b94c9d8dc 100644 --- a/src/pages/api/widgets/openweathermap.js +++ b/src/pages/api/widgets/openweathermap.js @@ -1,4 +1,4 @@ -import cachedFetch from "utils/cached-fetch"; +import cachedFetch from "utils/proxy/cached-fetch"; import { getSettings } from "utils/config"; export default async function handler(req, res) { diff --git a/src/pages/api/widgets/weather.js b/src/pages/api/widgets/weather.js index 5154a6dc3..893d3054b 100644 --- a/src/pages/api/widgets/weather.js +++ b/src/pages/api/widgets/weather.js @@ -1,4 +1,4 @@ -import cachedFetch from "utils/cached-fetch"; +import cachedFetch from "utils/proxy/cached-fetch"; import { getSettings } from "utils/config"; export default async function handler(req, res) { diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 614201c94..a1faafb7b 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,5 +1,5 @@ /* eslint-disable react/no-array-index-key */ -import useSWR from "swr"; +import useSWR, { SWRConfig } from "swr"; import Head from "next/head"; import dynamic from "next/dynamic"; import { useTranslation } from "next-i18next"; @@ -13,9 +13,10 @@ import Widget from "components/widget"; import Revalidate from "components/revalidate"; import createLogger from "utils/logger"; import { getSettings } from "utils/config"; -import { ColorContext } from "utils/color-context"; -import { ThemeContext } from "utils/theme-context"; -import { SettingsContext } from "utils/settings-context"; +import { ColorContext } from "utils/contexts/color"; +import { ThemeContext } from "utils/contexts/theme"; +import { SettingsContext } from "utils/contexts/settings"; +import { bookmarksResponse, servicesResponse, widgetsResponse } from "utils/config/api-response"; const ThemeToggle = dynamic(() => import("components/theme-toggle"), { ssr: false, @@ -37,9 +38,18 @@ export async function getStaticProps() { logger = createLogger("index"); const { providers, ...settings } = getSettings(); + const services = await servicesResponse(); + const bookmarks = await bookmarksResponse(); + const widgets = await widgetsResponse(); + return { props: { initialSettings: settings, + fallback: { + "/api/services": services, + "/api/bookmarks": bookmarks, + "/api/widgets": widgets, + }, ...(await serverSideTranslations(settings.language ?? "en")), }, }; @@ -56,7 +66,7 @@ export async function getStaticProps() { } } -export default function Index({ initialSettings }) { +export default function Index({ initialSettings, fallback }) { const { data: errorsData } = useSWR("/api/validate"); if (errorsData && errorsData.length > 0) { @@ -83,7 +93,11 @@ export default function Index({ initialSettings }) { ); } - return ; + return ( + fetch(resource, init).then((res) => res.json()) }}> + + + ); } function Home({ initialSettings }) { diff --git a/src/utils/config/api-response.js b/src/utils/config/api-response.js new file mode 100644 index 000000000..502b2796d --- /dev/null +++ b/src/utils/config/api-response.js @@ -0,0 +1,84 @@ +/* eslint-disable no-console */ +import { promises as fs } from "fs"; +import path from "path"; + +import yaml from "js-yaml"; + +import checkAndCopyConfig from "utils/config"; +import { servicesFromConfig, servicesFromDocker, cleanServiceGroups } from "utils/service-helpers"; + +export async function bookmarksResponse() { + checkAndCopyConfig("bookmarks.yaml"); + + const bookmarksYaml = path.join(process.cwd(), "config", "bookmarks.yaml"); + const fileContents = await fs.readFile(bookmarksYaml, "utf8"); + const bookmarks = yaml.load(fileContents); + + // map easy to write YAML objects into easy to consume JS arrays + const bookmarksArray = bookmarks.map((group) => ({ + name: Object.keys(group)[0], + bookmarks: group[Object.keys(group)[0]].map((entries) => ({ + name: Object.keys(entries)[0], + ...entries[Object.keys(entries)[0]][0], + })), + })); + + return bookmarksArray; +} + +export async function widgetsResponse() { + checkAndCopyConfig("widgets.yaml"); + + const widgetsYaml = path.join(process.cwd(), "config", "widgets.yaml"); + const fileContents = await fs.readFile(widgetsYaml, "utf8"); + const widgets = yaml.load(fileContents); + + // map easy to write YAML objects into easy to consume JS arrays + const widgetsArray = widgets.map((group) => ({ + type: Object.keys(group)[0], + options: { ...group[Object.keys(group)[0]] }, + })); + + return widgetsArray; +} + +export async function servicesResponse() { + let discoveredServices; + let configuredServices; + + try { + discoveredServices = cleanServiceGroups(await servicesFromDocker()); + } catch (e) { + console.error("Failed to discover services, please check docker.yaml for errors or remove example entries."); + console.error(e); + discoveredServices = []; + } + + try { + configuredServices = cleanServiceGroups(await servicesFromConfig()); + } catch (e) { + console.error("Failed to load services.yaml, please check for errors"); + console.error(e); + configuredServices = []; + } + + const mergedGroupsNames = [ + ...new Set([discoveredServices.map((group) => group.name), configuredServices.map((group) => group.name)].flat()), + ]; + + const mergedGroups = []; + + mergedGroupsNames.forEach((groupName) => { + const discoveredGroup = discoveredServices.find((group) => group.name === groupName) || { services: [] }; + const configuredGroup = configuredServices.find((group) => group.name === groupName) || { services: [] }; + + const mergedGroup = { + name: groupName, + services: [...discoveredGroup.services, ...configuredGroup.services].filter((service) => service), + }; + + mergedGroups.push(mergedGroup); + }); + + return mergedGroups; +} diff --git a/src/utils/color-context.jsx b/src/utils/contexts/color.jsx similarity index 100% rename from src/utils/color-context.jsx rename to src/utils/contexts/color.jsx diff --git a/src/utils/settings-context.jsx b/src/utils/contexts/settings.jsx similarity index 100% rename from src/utils/settings-context.jsx rename to src/utils/contexts/settings.jsx diff --git a/src/utils/theme-context.jsx b/src/utils/contexts/theme.jsx similarity index 100% rename from src/utils/theme-context.jsx rename to src/utils/contexts/theme.jsx diff --git a/src/utils/api-helpers.js b/src/utils/proxy/api-helpers.js similarity index 100% rename from src/utils/api-helpers.js rename to src/utils/proxy/api-helpers.js diff --git a/src/utils/cached-fetch.js b/src/utils/proxy/cached-fetch.js similarity index 100% rename from src/utils/cached-fetch.js rename to src/utils/proxy/cached-fetch.js diff --git a/src/utils/cookie-jar.js b/src/utils/proxy/cookie-jar.js similarity index 100% rename from src/utils/cookie-jar.js rename to src/utils/proxy/cookie-jar.js diff --git a/src/utils/proxies/credentialed.js b/src/utils/proxy/handlers/credentialed.js similarity index 94% rename from src/utils/proxies/credentialed.js rename to src/utils/proxy/handlers/credentialed.js index 098fd8bc6..7bea34f75 100644 --- a/src/utils/proxies/credentialed.js +++ b/src/utils/proxy/handlers/credentialed.js @@ -1,6 +1,6 @@ import getServiceWidget from "utils/service-helpers"; -import { formatApiCall } from "utils/api-helpers"; -import { httpProxy } from "utils/http"; +import { formatApiCall } from "utils/proxy/api-helpers"; +import { httpProxy } from "utils/proxy/http"; import createLogger from "utils/logger"; import widgets from "widgets/widgets"; diff --git a/src/utils/proxies/generic.js b/src/utils/proxy/handlers/generic.js similarity index 93% rename from src/utils/proxies/generic.js rename to src/utils/proxy/handlers/generic.js index 0f911aeb6..b25042f12 100644 --- a/src/utils/proxies/generic.js +++ b/src/utils/proxy/handlers/generic.js @@ -1,6 +1,6 @@ import getServiceWidget from "utils/service-helpers"; -import { formatApiCall } from "utils/api-helpers"; -import { httpProxy } from "utils/http"; +import { formatApiCall } from "utils/proxy/api-helpers"; +import { httpProxy } from "utils/proxy/http"; import createLogger from "utils/logger"; import widgets from "widgets/widgets"; diff --git a/src/utils/http.js b/src/utils/proxy/http.js similarity index 96% rename from src/utils/http.js rename to src/utils/proxy/http.js index bfeec046f..feed71ddf 100644 --- a/src/utils/http.js +++ b/src/utils/proxy/http.js @@ -2,7 +2,7 @@ /* eslint-disable no-param-reassign */ import { http, https } from "follow-redirects"; -import { addCookieToJar, setCookieHeader } from "utils/cookie-jar"; +import { addCookieToJar, setCookieHeader } from "./cookie-jar"; function addCookieHandler(url, params) { setCookieHeader(url, params); diff --git a/src/utils/service-helpers.js b/src/utils/service-helpers.js index 595d5e360..8918e264b 100644 --- a/src/utils/service-helpers.js +++ b/src/utils/service-helpers.js @@ -121,15 +121,16 @@ export function cleanServiceGroups(groups) { cleanedService.widget = { type, - currency, - symbols, service_name: service.name, service_group: serviceGroup.name, }; + if (currency) cleanedService.widget.currency = currency; + if (symbols) cleanedService.widget.symbols = symbols; + if (type === "docker") { - cleanedService.widget.server = server; - cleanedService.widget.container = container; + if (server) cleanedService.widget.server = server; + if (container) cleanedService.widget.container = container; } } diff --git a/src/utils/condition-map.js b/src/utils/weather/condition-map.js similarity index 100% rename from src/utils/condition-map.js rename to src/utils/weather/condition-map.js diff --git a/src/utils/owm-condition-map.js b/src/utils/weather/owm-condition-map.js similarity index 100% rename from src/utils/owm-condition-map.js rename to src/utils/weather/owm-condition-map.js diff --git a/src/widgets/adguard/component.jsx b/src/widgets/adguard/component.jsx index edbf14e9d..e6f0d6bef 100644 --- a/src/widgets/adguard/component.jsx +++ b/src/widgets/adguard/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/adguard/widget.js b/src/widgets/adguard/widget.js index ecbdf12af..fe8d060dd 100644 --- a/src/widgets/adguard/widget.js +++ b/src/widgets/adguard/widget.js @@ -1,11 +1,11 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/control/{endpoint}", proxyHandler: genericProxyHandler, mappings: { - "stats": { + stats: { endpoint: "stats", }, }, diff --git a/src/widgets/authentik/component.jsx b/src/widgets/authentik/component.jsx index 365060b24..63fef6f38 100644 --- a/src/widgets/authentik/component.jsx +++ b/src/widgets/authentik/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); @@ -30,11 +30,13 @@ export default function Component({ service }) { const yesterday = new Date(Date.now()).setHours(-24); const loginsLast24H = loginsData.reduce( - (total, current) => current.x_cord >= yesterday ? total + current.y_cord : total - , 0); + (total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total), + 0 + ); const failedLoginsLast24H = failedLoginsData.reduce( - (total, current) => current.x_cord >= yesterday ? total + current.y_cord : total - , 0); + (total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total), + 0 + ); return ( diff --git a/src/widgets/authentik/widget.js b/src/widgets/authentik/widget.js index e665d526d..7a7b532f8 100644 --- a/src/widgets/authentik/widget.js +++ b/src/widgets/authentik/widget.js @@ -1,18 +1,18 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/api/v3/{endpoint}", proxyHandler: credentialedProxyHandler, mappings: { - "users": { - endpoint: "core/users?page_size=1" + users: { + endpoint: "core/users?page_size=1", }, - "login": { - endpoint: "events/events/per_month/?action=login&query={}" + login: { + endpoint: "events/events/per_month/?action=login&query={}", }, - "login_failed": { - endpoint: "events/events/per_month/?action=login_failed&query={}" + login_failed: { + endpoint: "events/events/per_month/?action=login_failed&query={}", }, }, }; diff --git a/src/widgets/bazarr/component.jsx b/src/widgets/bazarr/component.jsx index c2e3b7cb1..fd0630ce0 100644 --- a/src/widgets/bazarr/component.jsx +++ b/src/widgets/bazarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/bazarr/widget.js b/src/widgets/bazarr/widget.js index 9f12c18e7..5b89b2b40 100644 --- a/src/widgets/bazarr/widget.js +++ b/src/widgets/bazarr/widget.js @@ -1,18 +1,18 @@ -import genericProxyHandler from "utils/proxies/generic"; -import { asJson } from "utils/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; +import { asJson } from "utils/proxy/api-helpers"; const widget = { api: "{url}/api/{endpoint}/wanted?apikey={key}", proxyHandler: genericProxyHandler, mappings: { - "movies": { + movies: { endpoint: "movies", map: (data) => ({ total: asJson(data).total, }), }, - "episodes": { + episodes: { endpoint: "episodes", map: (data) => ({ total: asJson(data).total, diff --git a/src/widgets/coinmarketcap/component.jsx b/src/widgets/coinmarketcap/component.jsx index 7cdb03aff..88f700417 100644 --- a/src/widgets/coinmarketcap/component.jsx +++ b/src/widgets/coinmarketcap/component.jsx @@ -6,7 +6,7 @@ import classNames from "classnames"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; import Dropdown from "components/services/dropdown"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); @@ -27,7 +27,7 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useSWR( formatProxyUrl(config, "v1/cryptocurrency/quotes/latest", { symbol: `${symbols.join(",")}`, - convert: `${currencyCode}` + convert: `${currencyCode}`, }) ); diff --git a/src/widgets/coinmarketcap/widget.js b/src/widgets/coinmarketcap/widget.js index f493e62f5..fcbafadf9 100644 --- a/src/widgets/coinmarketcap/widget.js +++ b/src/widgets/coinmarketcap/widget.js @@ -1,4 +1,4 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "https://pro-api.coinmarketcap.com/{endpoint}", diff --git a/src/widgets/docker/component.jsx b/src/widgets/docker/component.jsx index bf015060b..a9c26b1c6 100644 --- a/src/widgets/docker/component.jsx +++ b/src/widgets/docker/component.jsx @@ -12,18 +12,10 @@ export default function Component({ service }) { const config = service.widget; const { data: statusData, error: statusError } = useSWR( - `/api/docker/status/${config.container}/${config.server || ""}`, - { - refreshInterval: 5000, - } + `/api/docker/status/${config.container}/${config.server || ""}` ); - const { data: statsData, error: statsError } = useSWR( - `/api/docker/stats/${config.container}/${config.server || ""}`, - { - refreshInterval: 5000, - } - ); + const { data: statsData, error: statsError } = useSWR(`/api/docker/stats/${config.container}/${config.server || ""}`); if (statsError || statusError) { return ; diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx index 5096174da..c3217b3a6 100644 --- a/src/widgets/emby/component.jsx +++ b/src/widgets/emby/component.jsx @@ -4,7 +4,7 @@ import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } f import { MdOutlineSmartDisplay } from "react-icons/md"; import Widget from "components/services/widgets/widget"; -import { formatProxyUrl, formatProxyUrlWithSegments } from "utils/api-helpers"; +import { formatProxyUrl, formatProxyUrlWithSegments } from "utils/proxy/api-helpers"; function ticksToTime(ticks) { const milliseconds = ticks / 10000; @@ -164,7 +164,7 @@ export default function Component({ service }) { async function handlePlayCommand(session, command) { const url = formatProxyUrlWithSegments(config, "PlayControl", { sessionId: session.Id, - command + command, }); await fetch(url).then(() => { sessionMutate(); diff --git a/src/widgets/emby/widget.js b/src/widgets/emby/widget.js index 421575221..1bb5a7260 100644 --- a/src/widgets/emby/widget.js +++ b/src/widgets/emby/widget.js @@ -1,18 +1,18 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/emby/{endpoint}?api_key={key}", proxyHandler: genericProxyHandler, mappings: { - "Sessions": { + Sessions: { endpoint: "Sessions", }, - "PlayControl": { + PlayControl: { method: "POST", enpoint: "Sessions/{sessionId}/Playing/{command}", - segments: ["sessionId", "command"] - } + segments: ["sessionId", "command"], + }, }, }; diff --git a/src/widgets/gotify/component.jsx b/src/widgets/gotify/component.jsx index 178dedcaf..943a74787 100644 --- a/src/widgets/gotify/component.jsx +++ b/src/widgets/gotify/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/gotify/widget.js b/src/widgets/gotify/widget.js index 2ad711802..251f35f96 100644 --- a/src/widgets/gotify/widget.js +++ b/src/widgets/gotify/widget.js @@ -1,18 +1,18 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/{endpoint}", proxyHandler: credentialedProxyHandler, mappings: { - "application": { - endpoint: "application" + application: { + endpoint: "application", }, - "client": { - endpoint: "client" + client: { + endpoint: "client", }, - "message": { - endpoint: "message" + message: { + endpoint: "message", }, }, }; diff --git a/src/widgets/jackett/component.jsx b/src/widgets/jackett/component.jsx index 738355fce..e1d4083f7 100644 --- a/src/widgets/jackett/component.jsx +++ b/src/widgets/jackett/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/jackett/widget.js b/src/widgets/jackett/widget.js index d787c3e45..9d2a9b5cf 100644 --- a/src/widgets/jackett/widget.js +++ b/src/widgets/jackett/widget.js @@ -1,12 +1,12 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/v2.0/{endpoint}?apikey={key}&configured=true", proxyHandler: genericProxyHandler, mappings: { - "indexers": { - endpoint: "indexers" + indexers: { + endpoint: "indexers", }, }, }; diff --git a/src/widgets/jellyseerr/component.jsx b/src/widgets/jellyseerr/component.jsx index 74685ddc1..1254d8d44 100644 --- a/src/widgets/jellyseerr/component.jsx +++ b/src/widgets/jellyseerr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/jellyseerr/widget.js b/src/widgets/jellyseerr/widget.js index 4b823efcc..d752e3391 100644 --- a/src/widgets/jellyseerr/widget.js +++ b/src/widgets/jellyseerr/widget.js @@ -1,4 +1,4 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/api/v1/{endpoint}", @@ -6,7 +6,7 @@ const widget = { mappings: { "request/count": { - endpoint: "request/count" + endpoint: "request/count", }, }, }; diff --git a/src/widgets/lidarr/component.jsx b/src/widgets/lidarr/component.jsx index fc0e7a952..588ca94b7 100644 --- a/src/widgets/lidarr/component.jsx +++ b/src/widgets/lidarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/lidarr/widget.js b/src/widgets/lidarr/widget.js index aac84b74b..6ff932544 100644 --- a/src/widgets/lidarr/widget.js +++ b/src/widgets/lidarr/widget.js @@ -1,5 +1,5 @@ -import genericProxyHandler from "utils/proxies/generic"; -import { jsonArrayFilter } from "utils/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; +import { jsonArrayFilter } from "utils/proxy/api-helpers"; const widget = { api: "{url}/api/v1/{endpoint}?apikey={key}", diff --git a/src/widgets/mastodon/component.jsx b/src/widgets/mastodon/component.jsx index fbee420fa..cbd3635d5 100644 --- a/src/widgets/mastodon/component.jsx +++ b/src/widgets/mastodon/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/mastodon/widget.js b/src/widgets/mastodon/widget.js index c9761c5eb..2daebb0fd 100644 --- a/src/widgets/mastodon/widget.js +++ b/src/widgets/mastodon/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/v1/{endpoint}", diff --git a/src/widgets/npm/component.jsx b/src/widgets/npm/component.jsx index 59a709e8e..0d2ab75ec 100644 --- a/src/widgets/npm/component.jsx +++ b/src/widgets/npm/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/npm/proxy.js b/src/widgets/npm/proxy.js index bd612a504..44e760ebb 100644 --- a/src/widgets/npm/proxy.js +++ b/src/widgets/npm/proxy.js @@ -1,5 +1,5 @@ import getServiceWidget from "utils/service-helpers"; -import { formatApiCall } from "utils/api-helpers"; +import { formatApiCall } from "utils/proxy/api-helpers"; import widgets from "widgets/widgets"; export default async function npmProxyHandler(req, res) { diff --git a/src/widgets/nzbget/component.jsx b/src/widgets/nzbget/component.jsx index fe85cdb50..c57ba4156 100644 --- a/src/widgets/nzbget/component.jsx +++ b/src/widgets/nzbget/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation("common"); diff --git a/src/widgets/ombi/component.jsx b/src/widgets/ombi/component.jsx index 55435b54d..d2b9544ba 100644 --- a/src/widgets/ombi/component.jsx +++ b/src/widgets/ombi/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/ombi/widget.js b/src/widgets/ombi/widget.js index d0dbea934..e7928e7e5 100644 --- a/src/widgets/ombi/widget.js +++ b/src/widgets/ombi/widget.js @@ -1,4 +1,4 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/api/v1/{endpoint}", diff --git a/src/widgets/overseerr/component.jsx b/src/widgets/overseerr/component.jsx index 0201ca81c..cb49dfbaa 100644 --- a/src/widgets/overseerr/component.jsx +++ b/src/widgets/overseerr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/overseerr/widget.js b/src/widgets/overseerr/widget.js index b46bad902..d752e3391 100644 --- a/src/widgets/overseerr/widget.js +++ b/src/widgets/overseerr/widget.js @@ -1,4 +1,4 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/api/v1/{endpoint}", diff --git a/src/widgets/pihole/component.jsx b/src/widgets/pihole/component.jsx index fea8e68c3..e6c6862de 100644 --- a/src/widgets/pihole/component.jsx +++ b/src/widgets/pihole/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/pihole/widget.js b/src/widgets/pihole/widget.js index 5198ea2cd..2e20fe8a3 100644 --- a/src/widgets/pihole/widget.js +++ b/src/widgets/pihole/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/admin/{endpoint}", diff --git a/src/widgets/portainer/component.jsx b/src/widgets/portainer/component.jsx index 272b8449a..171a7f468 100644 --- a/src/widgets/portainer/component.jsx +++ b/src/widgets/portainer/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/portainer/widget.js b/src/widgets/portainer/widget.js index 3a75a6e63..ca3d5bb0b 100644 --- a/src/widgets/portainer/widget.js +++ b/src/widgets/portainer/widget.js @@ -1,4 +1,4 @@ -import credentialedProxyHandler from "utils/proxies/credentialed"; +import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { api: "{url}/api/endpoints/{env}/{endpoint}", diff --git a/src/widgets/prowlarr/component.jsx b/src/widgets/prowlarr/component.jsx index c7ebdf96e..9a3514938 100644 --- a/src/widgets/prowlarr/component.jsx +++ b/src/widgets/prowlarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/prowlarr/widget.js b/src/widgets/prowlarr/widget.js index a19b83a34..3b7b27879 100644 --- a/src/widgets/prowlarr/widget.js +++ b/src/widgets/prowlarr/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/v1/{endpoint}", diff --git a/src/widgets/qbittorrent/component.jsx b/src/widgets/qbittorrent/component.jsx index 1c98541be..d38c7eafd 100644 --- a/src/widgets/qbittorrent/component.jsx +++ b/src/widgets/qbittorrent/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/qbittorrent/proxy.js b/src/widgets/qbittorrent/proxy.js index dfb46a258..e9a83e13e 100644 --- a/src/widgets/qbittorrent/proxy.js +++ b/src/widgets/qbittorrent/proxy.js @@ -1,6 +1,6 @@ -import { formatApiCall } from "utils/api-helpers"; -import { addCookieToJar, setCookieHeader } from "utils/cookie-jar"; -import { httpProxy } from "utils/http"; +import { formatApiCall } from "utils/proxy/api-helpers"; +import { addCookieToJar, setCookieHeader } from "utils/proxy/cookie-jar"; +import { httpProxy } from "utils/proxy/http"; import getServiceWidget from "utils/service-helpers"; async function login(widget, params) { diff --git a/src/widgets/radarr/component.jsx b/src/widgets/radarr/component.jsx index 94b85acd3..856724ef1 100644 --- a/src/widgets/radarr/component.jsx +++ b/src/widgets/radarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/radarr/widget.js b/src/widgets/radarr/widget.js index 8e8325592..da3f2a6b9 100644 --- a/src/widgets/radarr/widget.js +++ b/src/widgets/radarr/widget.js @@ -1,5 +1,5 @@ -import genericProxyHandler from "utils/proxies/generic"; -import { jsonArrayFilter } from "utils/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; +import { jsonArrayFilter } from "utils/proxy/api-helpers"; const widget = { api: "{url}/api/v3/{endpoint}?apikey={key}", diff --git a/src/widgets/readarr/component.jsx b/src/widgets/readarr/component.jsx index 131d94d7c..64852ded9 100644 --- a/src/widgets/readarr/component.jsx +++ b/src/widgets/readarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/readarr/widget.js b/src/widgets/readarr/widget.js index f826cf1ff..75a5e8174 100644 --- a/src/widgets/readarr/widget.js +++ b/src/widgets/readarr/widget.js @@ -1,5 +1,5 @@ -import genericProxyHandler from "utils/proxies/generic"; -import { jsonArrayFilter } from "utils/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; +import { jsonArrayFilter } from "utils/proxy/api-helpers"; const widget = { api: "{url}/api/v1/{endpoint}?apikey={key}", diff --git a/src/widgets/rutorrent/component.jsx b/src/widgets/rutorrent/component.jsx index 5766fbab6..0f3a45bd2 100644 --- a/src/widgets/rutorrent/component.jsx +++ b/src/widgets/rutorrent/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/sabnzbd/component.jsx b/src/widgets/sabnzbd/component.jsx index 7e77ae04f..6ca6e35a6 100644 --- a/src/widgets/sabnzbd/component.jsx +++ b/src/widgets/sabnzbd/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/sabnzbd/widget.js b/src/widgets/sabnzbd/widget.js index 67e64e973..e30973768 100644 --- a/src/widgets/sabnzbd/widget.js +++ b/src/widgets/sabnzbd/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/?apikey={key}&output=json&mode={endpoint}", diff --git a/src/widgets/sonarr/component.jsx b/src/widgets/sonarr/component.jsx index f46c0f863..05f5ecb41 100644 --- a/src/widgets/sonarr/component.jsx +++ b/src/widgets/sonarr/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/sonarr/widget.js b/src/widgets/sonarr/widget.js index 45d6e533a..32780bdae 100644 --- a/src/widgets/sonarr/widget.js +++ b/src/widgets/sonarr/widget.js @@ -1,5 +1,5 @@ -import genericProxyHandler from "utils/proxies/generic"; -import { asJson } from "utils/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; +import { asJson } from "utils/proxy/api-helpers"; const widget = { api: "{url}/api/v3/{endpoint}?apikey={key}", diff --git a/src/widgets/speedtest/component.jsx b/src/widgets/speedtest/component.jsx index 6e30231fa..bc15f8407 100644 --- a/src/widgets/speedtest/component.jsx +++ b/src/widgets/speedtest/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/speedtest/widget.js b/src/widgets/speedtest/widget.js index 6c89b913c..b227848a6 100644 --- a/src/widgets/speedtest/widget.js +++ b/src/widgets/speedtest/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/{endpoint}", diff --git a/src/widgets/strelaysrv/component.jsx b/src/widgets/strelaysrv/component.jsx index 1e0578308..b77be020d 100644 --- a/src/widgets/strelaysrv/component.jsx +++ b/src/widgets/strelaysrv/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/strelaysrv/widget.js b/src/widgets/strelaysrv/widget.js index b0c8139bb..713f05b4d 100644 --- a/src/widgets/strelaysrv/widget.js +++ b/src/widgets/strelaysrv/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/{endpoint}", diff --git a/src/widgets/tautulli/component.jsx b/src/widgets/tautulli/component.jsx index 084d457ba..a4bb1d81d 100644 --- a/src/widgets/tautulli/component.jsx +++ b/src/widgets/tautulli/component.jsx @@ -5,7 +5,7 @@ import { BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/b import { MdOutlineSmartDisplay, MdSmartDisplay } from "react-icons/md"; import Widget from "components/services/widgets/widget"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; function millisecondsToTime(milliseconds) { const seconds = Math.floor((milliseconds / 1000) % 60); diff --git a/src/widgets/tautulli/widget.js b/src/widgets/tautulli/widget.js index 4f7239947..7450e15a6 100644 --- a/src/widgets/tautulli/widget.js +++ b/src/widgets/tautulli/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/v2?apikey={key}&cmd={endpoint}", diff --git a/src/widgets/traefik/component.jsx b/src/widgets/traefik/component.jsx index a87b35ee0..5ffb767f1 100644 --- a/src/widgets/traefik/component.jsx +++ b/src/widgets/traefik/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/traefik/widget.js b/src/widgets/traefik/widget.js index ed39af2c7..aa92fa1e7 100644 --- a/src/widgets/traefik/widget.js +++ b/src/widgets/traefik/widget.js @@ -1,4 +1,4 @@ -import genericProxyHandler from "utils/proxies/generic"; +import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { api: "{url}/api/{endpoint}", diff --git a/src/widgets/transmission/component.jsx b/src/widgets/transmission/component.jsx index b935f4b57..c4e7560af 100644 --- a/src/widgets/transmission/component.jsx +++ b/src/widgets/transmission/component.jsx @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"; import Widget from "components/services/widgets/widget"; import Block from "components/services/widgets/block"; -import { formatProxyUrl } from "utils/api-helpers"; +import { formatProxyUrl } from "utils/proxy/api-helpers"; export default function Component({ service }) { const { t } = useTranslation(); diff --git a/src/widgets/transmission/proxy.js b/src/widgets/transmission/proxy.js index cd909a68b..5d118922c 100644 --- a/src/widgets/transmission/proxy.js +++ b/src/widgets/transmission/proxy.js @@ -1,5 +1,5 @@ -import { httpProxy } from "utils/http"; -import { formatApiCall } from "utils/api-helpers"; +import { httpProxy } from "utils/proxy/http"; +import { formatApiCall } from "utils/proxy/api-helpers"; import getServiceWidget from "utils/service-helpers"; export default async function transmissionProxyHandler(req, res) { @@ -23,8 +23,8 @@ export default async function transmissionProxyHandler(req, res) { const body = JSON.stringify({ method: "torrent-get", arguments: { - fields: ["percentDone", "status", "rateDownload", "rateUpload"] - } + fields: ["percentDone", "status", "rateDownload", "rateUpload"], + }, }); const headers = {