mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 14:03:40 +01:00
utils cleanup, initial static generation
This commit is contained in:
parent
ec8700f3e9
commit
e1a3a82f75
@ -1,6 +1,6 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
|
|
||||||
import { SettingsContext } from "utils/settings-context";
|
import { SettingsContext } from "utils/contexts/settings";
|
||||||
|
|
||||||
export default function Item({ bookmark }) {
|
export default function Item({ bookmark }) {
|
||||||
const { hostname } = new URL(bookmark.href);
|
const { hostname } = new URL(bookmark.href);
|
||||||
|
@ -3,7 +3,7 @@ import { IoColorPalette } from "react-icons/io5";
|
|||||||
import { Popover, Transition } from "@headlessui/react";
|
import { Popover, Transition } from "@headlessui/react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
|
||||||
import { ColorContext } from "utils/color-context";
|
import { ColorContext } from "utils/contexts/color";
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
"slate",
|
"slate",
|
||||||
|
@ -6,7 +6,7 @@ import Status from "./status";
|
|||||||
import Widget from "./widget";
|
import Widget from "./widget";
|
||||||
|
|
||||||
import Docker from "widgets/docker/component";
|
import Docker from "widgets/docker/component";
|
||||||
import { SettingsContext } from "utils/settings-context";
|
import { SettingsContext } from "utils/contexts/settings";
|
||||||
|
|
||||||
function resolveIcon(icon) {
|
function resolveIcon(icon) {
|
||||||
if (icon.startsWith("http")) {
|
if (icon.startsWith("http")) {
|
||||||
@ -85,14 +85,16 @@ export default function Item({ service }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
{service.container && service.server && (
|
||||||
className={classNames(
|
<div
|
||||||
statsOpen ? "max-h-[55px] opacity-100" : " max-h-[0] opacity-0",
|
className={classNames(
|
||||||
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
statsOpen ? "max-h-[55px] opacity-100" : " max-h-[0] opacity-0",
|
||||||
)}
|
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
||||||
>
|
)}
|
||||||
<Docker service={{ widget: { container: service.container, server: service.server } }} />
|
>
|
||||||
</div>
|
<Docker service={{ widget: { container: service.container, server: service.server } }} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{service.widget && <Widget service={service} />}
|
{service.widget && <Widget service={service} />}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { MdDarkMode, MdLightMode, MdToggleOff, MdToggleOn } from "react-icons/md";
|
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() {
|
export default function ThemeToggle() {
|
||||||
const { theme, setTheme } = useContext(ThemeContext);
|
const { theme, setTheme } = useContext(ThemeContext);
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
import WeatherApi from "components/widgets/weather/weather";
|
import dynamic from "next/dynamic";
|
||||||
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";
|
|
||||||
|
|
||||||
const widgetMappings = {
|
const widgetMappings = {
|
||||||
weather: WeatherApi, // This key will be deprecated in the future
|
weatherapi: dynamic(() => import("components/widgets/weather/weather")),
|
||||||
weatherapi: WeatherApi,
|
openweathermap: dynamic(() => import("components/widgets/openweathermap/weather")),
|
||||||
openweathermap: OpenWeatherMap,
|
resources: dynamic(() => import("components/widgets/resources/resources")),
|
||||||
resources: Resources,
|
search: dynamic(() => import("components/widgets/search/search")),
|
||||||
search: Search,
|
greeting: dynamic(() => import("components/widgets/greeting/greeting")),
|
||||||
greeting: Greeting,
|
datetime: dynamic(() => import("components/widgets/datetime/datetime")),
|
||||||
datetime: DateTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Widget({ widget }) {
|
export default function Widget({ widget }) {
|
||||||
|
@ -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 }) {
|
export default function Icon({ condition, timeOfDay }) {
|
||||||
const IconComponent = mapIcon(condition, timeOfDay);
|
const IconComponent = mapIcon(condition, timeOfDay);
|
||||||
|
@ -80,20 +80,22 @@ export default function OpenWeatherMap({ options }) {
|
|||||||
|
|
||||||
const requestLocation = () => {
|
const requestLocation = () => {
|
||||||
setRequesting(true);
|
setRequesting(true);
|
||||||
navigator.geolocation.getCurrentPosition(
|
if (typeof window !== "undefined") {
|
||||||
(position) => {
|
navigator.geolocation.getCurrentPosition(
|
||||||
setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude });
|
(position) => {
|
||||||
setRequesting(false);
|
setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude });
|
||||||
},
|
setRequesting(false);
|
||||||
() => {
|
},
|
||||||
setRequesting(false);
|
() => {
|
||||||
},
|
setRequesting(false);
|
||||||
{
|
},
|
||||||
enableHighAccuracy: true,
|
{
|
||||||
maximumAge: 1000 * 60 * 60 * 3,
|
enableHighAccuracy: true,
|
||||||
timeout: 1000 * 30,
|
maximumAge: 1000 * 60 * 60 * 3,
|
||||||
}
|
timeout: 1000 * 30,
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!requesting && !location) requestLocation();
|
if (!requesting && !location) requestLocation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import mapIcon from "utils/condition-map";
|
import mapIcon from "utils/weather/condition-map";
|
||||||
|
|
||||||
export default function Icon({ condition, timeOfDay }) {
|
export default function Icon({ condition, timeOfDay }) {
|
||||||
const IconComponent = mapIcon(condition, timeOfDay);
|
const IconComponent = mapIcon(condition, timeOfDay);
|
||||||
|
@ -81,20 +81,22 @@ export default function WeatherApi({ options }) {
|
|||||||
|
|
||||||
const requestLocation = () => {
|
const requestLocation = () => {
|
||||||
setRequesting(true);
|
setRequesting(true);
|
||||||
navigator.geolocation.getCurrentPosition(
|
if (typeof window !== "undefined") {
|
||||||
(position) => {
|
navigator.geolocation.getCurrentPosition(
|
||||||
setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude });
|
(position) => {
|
||||||
setRequesting(false);
|
setLocation({ latitude: position.coords.latitude, longitude: position.coords.longitude });
|
||||||
},
|
setRequesting(false);
|
||||||
() => {
|
},
|
||||||
setRequesting(false);
|
() => {
|
||||||
},
|
setRequesting(false);
|
||||||
{
|
},
|
||||||
enableHighAccuracy: true,
|
{
|
||||||
maximumAge: 1000 * 60 * 60 * 3,
|
enableHighAccuracy: true,
|
||||||
timeout: 1000 * 30,
|
maximumAge: 1000 * 60 * 60 * 3,
|
||||||
}
|
timeout: 1000 * 30,
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!requesting && !location) requestLocation();
|
if (!requesting && !location) requestLocation();
|
||||||
|
@ -7,9 +7,9 @@ import "styles/theme.css";
|
|||||||
import "styles/manrope.css";
|
import "styles/manrope.css";
|
||||||
import nextI18nextConfig from "../../next-i18next.config";
|
import nextI18nextConfig from "../../next-i18next.config";
|
||||||
|
|
||||||
import { ColorProvider } from "utils/color-context";
|
import { ColorProvider } from "utils/contexts/color";
|
||||||
import { ThemeProvider } from "utils/theme-context";
|
import { ThemeProvider } from "utils/contexts/theme";
|
||||||
import { SettingsProvider } from "utils/settings-context";
|
import { SettingsProvider } from "utils/contexts/settings";
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }) {
|
function MyApp({ Component, pageProps }) {
|
||||||
return (
|
return (
|
||||||
|
@ -1,25 +1,5 @@
|
|||||||
import { promises as fs } from "fs";
|
import { bookmarksResponse } from "utils/config/api-response";
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
import yaml from "js-yaml";
|
|
||||||
|
|
||||||
import checkAndCopyConfig from "utils/config";
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
checkAndCopyConfig("bookmarks.yaml");
|
res.send(await bookmarksResponse());
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import https from "https";
|
|||||||
|
|
||||||
import getRawBody from "raw-body";
|
import getRawBody from "raw-body";
|
||||||
|
|
||||||
import { httpRequest, httpsRequest } from "utils/http";
|
import { httpRequest, httpsRequest } from "utils/proxy/http";
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
api: {
|
api: {
|
||||||
|
@ -1,43 +1,5 @@
|
|||||||
/* eslint-disable no-console */
|
import { servicesResponse } from "utils/config/api-response";
|
||||||
import { servicesFromConfig, servicesFromDocker, cleanServiceGroups } from "utils/service-helpers";
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
let discoveredServices;
|
res.send(await servicesResponse());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
const logger = createLogger("servicesProxy");
|
const logger = createLogger("servicesProxy");
|
||||||
|
@ -1,22 +1,5 @@
|
|||||||
import { promises as fs } from "fs";
|
import { widgetsResponse } from "utils/config/api-response";
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
import yaml from "js-yaml";
|
|
||||||
|
|
||||||
import checkAndCopyConfig from "utils/config";
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
checkAndCopyConfig("widgets.yaml");
|
res.send(await widgetsResponse());
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import cachedFetch from "utils/cached-fetch";
|
import cachedFetch from "utils/proxy/cached-fetch";
|
||||||
import { getSettings } from "utils/config";
|
import { getSettings } from "utils/config";
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import cachedFetch from "utils/cached-fetch";
|
import cachedFetch from "utils/proxy/cached-fetch";
|
||||||
import { getSettings } from "utils/config";
|
import { getSettings } from "utils/config";
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable react/no-array-index-key */
|
/* eslint-disable react/no-array-index-key */
|
||||||
import useSWR from "swr";
|
import useSWR, { SWRConfig } from "swr";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
@ -13,9 +13,10 @@ import Widget from "components/widget";
|
|||||||
import Revalidate from "components/revalidate";
|
import Revalidate from "components/revalidate";
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import { getSettings } from "utils/config";
|
import { getSettings } from "utils/config";
|
||||||
import { ColorContext } from "utils/color-context";
|
import { ColorContext } from "utils/contexts/color";
|
||||||
import { ThemeContext } from "utils/theme-context";
|
import { ThemeContext } from "utils/contexts/theme";
|
||||||
import { SettingsContext } from "utils/settings-context";
|
import { SettingsContext } from "utils/contexts/settings";
|
||||||
|
import { bookmarksResponse, servicesResponse, widgetsResponse } from "utils/config/api-response";
|
||||||
|
|
||||||
const ThemeToggle = dynamic(() => import("components/theme-toggle"), {
|
const ThemeToggle = dynamic(() => import("components/theme-toggle"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@ -37,9 +38,18 @@ export async function getStaticProps() {
|
|||||||
logger = createLogger("index");
|
logger = createLogger("index");
|
||||||
const { providers, ...settings } = getSettings();
|
const { providers, ...settings } = getSettings();
|
||||||
|
|
||||||
|
const services = await servicesResponse();
|
||||||
|
const bookmarks = await bookmarksResponse();
|
||||||
|
const widgets = await widgetsResponse();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
initialSettings: settings,
|
initialSettings: settings,
|
||||||
|
fallback: {
|
||||||
|
"/api/services": services,
|
||||||
|
"/api/bookmarks": bookmarks,
|
||||||
|
"/api/widgets": widgets,
|
||||||
|
},
|
||||||
...(await serverSideTranslations(settings.language ?? "en")),
|
...(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");
|
const { data: errorsData } = useSWR("/api/validate");
|
||||||
|
|
||||||
if (errorsData && errorsData.length > 0) {
|
if (errorsData && errorsData.length > 0) {
|
||||||
@ -83,7 +93,11 @@ export default function Index({ initialSettings }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Home initialSettings={initialSettings} />;
|
return (
|
||||||
|
<SWRConfig value={{ fallback, fetcher: (resource, init) => fetch(resource, init).then((res) => res.json()) }}>
|
||||||
|
<Home initialSettings={initialSettings} />
|
||||||
|
</SWRConfig>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Home({ initialSettings }) {
|
function Home({ initialSettings }) {
|
||||||
|
84
src/utils/config/api-response.js
Normal file
84
src/utils/config/api-response.js
Normal file
@ -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;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import { httpProxy } from "utils/http";
|
import { httpProxy } from "utils/proxy/http";
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import { httpProxy } from "utils/http";
|
import { httpProxy } from "utils/proxy/http";
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
import { http, https } from "follow-redirects";
|
import { http, https } from "follow-redirects";
|
||||||
|
|
||||||
import { addCookieToJar, setCookieHeader } from "utils/cookie-jar";
|
import { addCookieToJar, setCookieHeader } from "./cookie-jar";
|
||||||
|
|
||||||
function addCookieHandler(url, params) {
|
function addCookieHandler(url, params) {
|
||||||
setCookieHeader(url, params);
|
setCookieHeader(url, params);
|
@ -121,15 +121,16 @@ export function cleanServiceGroups(groups) {
|
|||||||
|
|
||||||
cleanedService.widget = {
|
cleanedService.widget = {
|
||||||
type,
|
type,
|
||||||
currency,
|
|
||||||
symbols,
|
|
||||||
service_name: service.name,
|
service_name: service.name,
|
||||||
service_group: serviceGroup.name,
|
service_group: serviceGroup.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (currency) cleanedService.widget.currency = currency;
|
||||||
|
if (symbols) cleanedService.widget.symbols = symbols;
|
||||||
|
|
||||||
if (type === "docker") {
|
if (type === "docker") {
|
||||||
cleanedService.widget.server = server;
|
if (server) cleanedService.widget.server = server;
|
||||||
cleanedService.widget.container = container;
|
if (container) cleanedService.widget.container = container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/control/{endpoint}",
|
api: "{url}/control/{endpoint}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"stats": {
|
stats: {
|
||||||
endpoint: "stats",
|
endpoint: "stats",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -30,11 +30,13 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const yesterday = new Date(Date.now()).setHours(-24);
|
const yesterday = new Date(Date.now()).setHours(-24);
|
||||||
const loginsLast24H = loginsData.reduce(
|
const loginsLast24H = loginsData.reduce(
|
||||||
(total, current) => current.x_cord >= yesterday ? total + current.y_cord : total
|
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||||
, 0);
|
0
|
||||||
|
);
|
||||||
const failedLoginsLast24H = failedLoginsData.reduce(
|
const failedLoginsLast24H = failedLoginsData.reduce(
|
||||||
(total, current) => current.x_cord >= yesterday ? total + current.y_cord : total
|
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||||
, 0);
|
0
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v3/{endpoint}",
|
api: "{url}/api/v3/{endpoint}",
|
||||||
proxyHandler: credentialedProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"users": {
|
users: {
|
||||||
endpoint: "core/users?page_size=1"
|
endpoint: "core/users?page_size=1",
|
||||||
},
|
},
|
||||||
"login": {
|
login: {
|
||||||
endpoint: "events/events/per_month/?action=login&query={}"
|
endpoint: "events/events/per_month/?action=login&query={}",
|
||||||
},
|
},
|
||||||
"login_failed": {
|
login_failed: {
|
||||||
endpoint: "events/events/per_month/?action=login_failed&query={}"
|
endpoint: "events/events/per_month/?action=login_failed&query={}",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import { asJson } from "utils/api-helpers";
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}/wanted?apikey={key}",
|
api: "{url}/api/{endpoint}/wanted?apikey={key}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"movies": {
|
movies: {
|
||||||
endpoint: "movies",
|
endpoint: "movies",
|
||||||
map: (data) => ({
|
map: (data) => ({
|
||||||
total: asJson(data).total,
|
total: asJson(data).total,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
"episodes": {
|
episodes: {
|
||||||
endpoint: "episodes",
|
endpoint: "episodes",
|
||||||
map: (data) => ({
|
map: (data) => ({
|
||||||
total: asJson(data).total,
|
total: asJson(data).total,
|
||||||
|
@ -6,7 +6,7 @@ import classNames from "classnames";
|
|||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
import Block from "components/services/widgets/block";
|
||||||
import Dropdown from "components/services/dropdown";
|
import Dropdown from "components/services/dropdown";
|
||||||
import { formatProxyUrl } from "utils/api-helpers";
|
import { formatProxyUrl } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -27,7 +27,7 @@ export default function Component({ service }) {
|
|||||||
const { data: statsData, error: statsError } = useSWR(
|
const { data: statsData, error: statsError } = useSWR(
|
||||||
formatProxyUrl(config, "v1/cryptocurrency/quotes/latest", {
|
formatProxyUrl(config, "v1/cryptocurrency/quotes/latest", {
|
||||||
symbol: `${symbols.join(",")}`,
|
symbol: `${symbols.join(",")}`,
|
||||||
convert: `${currencyCode}`
|
convert: `${currencyCode}`,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "https://pro-api.coinmarketcap.com/{endpoint}",
|
api: "https://pro-api.coinmarketcap.com/{endpoint}",
|
||||||
|
@ -12,18 +12,10 @@ export default function Component({ service }) {
|
|||||||
const config = service.widget;
|
const config = service.widget;
|
||||||
|
|
||||||
const { data: statusData, error: statusError } = useSWR(
|
const { data: statusData, error: statusError } = useSWR(
|
||||||
`/api/docker/status/${config.container}/${config.server || ""}`,
|
`/api/docker/status/${config.container}/${config.server || ""}`
|
||||||
{
|
|
||||||
refreshInterval: 5000,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: statsData, error: statsError } = useSWR(
|
const { data: statsData, error: statsError } = useSWR(`/api/docker/stats/${config.container}/${config.server || ""}`);
|
||||||
`/api/docker/stats/${config.container}/${config.server || ""}`,
|
|
||||||
{
|
|
||||||
refreshInterval: 5000,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (statsError || statusError) {
|
if (statsError || statusError) {
|
||||||
return <Widget error={t("widget.api_error")} />;
|
return <Widget error={t("widget.api_error")} />;
|
||||||
|
@ -4,7 +4,7 @@ import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } f
|
|||||||
import { MdOutlineSmartDisplay } from "react-icons/md";
|
import { MdOutlineSmartDisplay } from "react-icons/md";
|
||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
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) {
|
function ticksToTime(ticks) {
|
||||||
const milliseconds = ticks / 10000;
|
const milliseconds = ticks / 10000;
|
||||||
@ -164,7 +164,7 @@ export default function Component({ service }) {
|
|||||||
async function handlePlayCommand(session, command) {
|
async function handlePlayCommand(session, command) {
|
||||||
const url = formatProxyUrlWithSegments(config, "PlayControl", {
|
const url = formatProxyUrlWithSegments(config, "PlayControl", {
|
||||||
sessionId: session.Id,
|
sessionId: session.Id,
|
||||||
command
|
command,
|
||||||
});
|
});
|
||||||
await fetch(url).then(() => {
|
await fetch(url).then(() => {
|
||||||
sessionMutate();
|
sessionMutate();
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/emby/{endpoint}?api_key={key}",
|
api: "{url}/emby/{endpoint}?api_key={key}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"Sessions": {
|
Sessions: {
|
||||||
endpoint: "Sessions",
|
endpoint: "Sessions",
|
||||||
},
|
},
|
||||||
"PlayControl": {
|
PlayControl: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
enpoint: "Sessions/{sessionId}/Playing/{command}",
|
enpoint: "Sessions/{sessionId}/Playing/{command}",
|
||||||
segments: ["sessionId", "command"]
|
segments: ["sessionId", "command"],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/{endpoint}",
|
api: "{url}/{endpoint}",
|
||||||
proxyHandler: credentialedProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"application": {
|
application: {
|
||||||
endpoint: "application"
|
endpoint: "application",
|
||||||
},
|
},
|
||||||
"client": {
|
client: {
|
||||||
endpoint: "client"
|
endpoint: "client",
|
||||||
},
|
},
|
||||||
"message": {
|
message: {
|
||||||
endpoint: "message"
|
endpoint: "message",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v2.0/{endpoint}?apikey={key}&configured=true",
|
api: "{url}/api/v2.0/{endpoint}?apikey={key}&configured=true",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"indexers": {
|
indexers: {
|
||||||
endpoint: "indexers"
|
endpoint: "indexers",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}",
|
api: "{url}/api/v1/{endpoint}",
|
||||||
@ -6,7 +6,7 @@ const widget = {
|
|||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"request/count": {
|
"request/count": {
|
||||||
endpoint: "request/count"
|
endpoint: "request/count",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import { jsonArrayFilter } from "utils/api-helpers";
|
import { jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}?apikey={key}",
|
api: "{url}/api/v1/{endpoint}?apikey={key}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}",
|
api: "{url}/api/v1/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
export default async function npmProxyHandler(req, res) {
|
export default async function npmProxyHandler(req, res) {
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation("common");
|
const { t } = useTranslation("common");
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}",
|
api: "{url}/api/v1/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}",
|
api: "{url}/api/v1/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/admin/{endpoint}",
|
api: "{url}/admin/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import credentialedProxyHandler from "utils/proxies/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/endpoints/{env}/{endpoint}",
|
api: "{url}/api/endpoints/{env}/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}",
|
api: "{url}/api/v1/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import { addCookieToJar, setCookieHeader } from "utils/cookie-jar";
|
import { addCookieToJar, setCookieHeader } from "utils/proxy/cookie-jar";
|
||||||
import { httpProxy } from "utils/http";
|
import { httpProxy } from "utils/proxy/http";
|
||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
|
|
||||||
async function login(widget, params) {
|
async function login(widget, params) {
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import { jsonArrayFilter } from "utils/api-helpers";
|
import { jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v3/{endpoint}?apikey={key}",
|
api: "{url}/api/v3/{endpoint}?apikey={key}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import { jsonArrayFilter } from "utils/api-helpers";
|
import { jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v1/{endpoint}?apikey={key}",
|
api: "{url}/api/v1/{endpoint}?apikey={key}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/?apikey={key}&output=json&mode={endpoint}",
|
api: "{url}/api/?apikey={key}&output=json&mode={endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
import { asJson } from "utils/api-helpers";
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v3/{endpoint}?apikey={key}",
|
api: "{url}/api/v3/{endpoint}?apikey={key}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}",
|
api: "{url}/api/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/{endpoint}",
|
api: "{url}/{endpoint}",
|
||||||
|
@ -5,7 +5,7 @@ import { BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/b
|
|||||||
import { MdOutlineSmartDisplay, MdSmartDisplay } from "react-icons/md";
|
import { MdOutlineSmartDisplay, MdSmartDisplay } from "react-icons/md";
|
||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import { formatProxyUrl } from "utils/api-helpers";
|
import { formatProxyUrl } from "utils/proxy/api-helpers";
|
||||||
|
|
||||||
function millisecondsToTime(milliseconds) {
|
function millisecondsToTime(milliseconds) {
|
||||||
const seconds = Math.floor((milliseconds / 1000) % 60);
|
const seconds = Math.floor((milliseconds / 1000) % 60);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v2?apikey={key}&cmd={endpoint}",
|
api: "{url}/api/v2?apikey={key}&cmd={endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import genericProxyHandler from "utils/proxies/generic";
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}",
|
api: "{url}/api/{endpoint}",
|
||||||
|
@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
|
|||||||
|
|
||||||
import Widget from "components/services/widgets/widget";
|
import Widget from "components/services/widgets/widget";
|
||||||
import Block from "components/services/widgets/block";
|
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 }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { httpProxy } from "utils/http";
|
import { httpProxy } from "utils/proxy/http";
|
||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
|
|
||||||
export default async function transmissionProxyHandler(req, res) {
|
export default async function transmissionProxyHandler(req, res) {
|
||||||
@ -23,8 +23,8 @@ export default async function transmissionProxyHandler(req, res) {
|
|||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
method: "torrent-get",
|
method: "torrent-get",
|
||||||
arguments: {
|
arguments: {
|
||||||
fields: ["percentDone", "status", "rateDownload", "rateUpload"]
|
fields: ["percentDone", "status", "rateDownload", "rateUpload"],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user