further restructuring

pull/302/head
Ben Phelps 3 years ago
parent 9b07f3eb90
commit 4386999c38

@ -20,7 +20,7 @@ export default function Item({ bookmark }) {
</div>
<div className="flex-1 flex items-center justify-between rounded-r-md ">
<div className="flex-1 grow pl-3 py-2 text-xs">{bookmark.name}</div>
<div className="px-2 py-2 truncate text-theme-500 dark:text-theme-400 text-xs">{hostname}</div>
<div className="px-2 py-2 truncate text-theme-500 dark:text-theme-300 text-xs">{hostname}</div>
</div>
</div>
</a>

@ -74,14 +74,14 @@ export default function Item({ service }) {
>
<div className="flex-1 px-2 py-2 text-sm text-left">
{service.name}
<p className="text-theme-500 dark:text-theme-400 text-xs font-light">{service.description}</p>
<p className="text-theme-500 dark:text-theme-300 text-xs font-light">{service.description}</p>
</div>
</a>
) : (
<div className="flex-1 flex items-center justify-between rounded-r-md ">
<div className="flex-1 px-2 py-2 text-sm text-left">
{service.name}
<p className="text-theme-500 dark:text-theme-400 text-xs font-light">{service.description}</p>
<p className="text-theme-500 dark:text-theme-300 text-xs font-light">{service.description}</p>
</div>
</div>
)}

@ -1,4 +1,4 @@
export default function Widget({ error = false, children }) {
export default function Container({ error = false, children }) {
if (error) {
return (
<div className="bg-theme-200/50 dark:bg-theme-900/20 rounded m-1 flex-1 flex flex-col items-center justify-center p-1">

@ -26,7 +26,7 @@ export default function Version() {
return (
<div className="flex flex-row items-center">
<span className="text-xs text-theme-500">
<span className="text-xs text-theme-500 dark:text-theme-400">
{version} ({revision.substring(0, 7)}, {formatDate(buildTime)})
</span>
{version === "main" || version === "dev" || version === "nightly"
@ -37,7 +37,7 @@ export default function Version() {
href={latestRelease.html_url}
target="_blank"
rel="noopener noreferrer"
className="ml-2 text-xs text-theme-500 flex flex-row items-center"
className="ml-2 text-xs text-theme-500 dark:text-theme-400 flex flex-row items-center"
>
<MdNewReleases className="mr-1" /> {t("Update Available")}
</a>

@ -1,6 +1,6 @@
import Docker from "dockerode";
import getDockerArguments from "utils/docker";
import getDockerArguments from "utils/config/docker";
export default async function handler(req, res) {
const { service } = req.query;

@ -1,6 +1,6 @@
import Docker from "dockerode";
import getDockerArguments from "utils/docker";
import getDockerArguments from "utils/config/docker";
export default async function handler(req, res) {
const { service } = req.query;

@ -1,4 +1,4 @@
import checkAndCopyConfig from "utils/config";
import checkAndCopyConfig from "utils/config/config";
const configs = ["docker.yaml", "settings.yaml", "services.yaml", "bookmarks.yaml"];

@ -1,5 +1,5 @@
import cachedFetch from "utils/proxy/cached-fetch";
import { getSettings } from "utils/config";
import { getSettings } from "utils/config/config";
export default async function handler(req, res) {
const { latitude, longitude, units, provider, cache, lang } = req.query;

@ -1,5 +1,5 @@
import cachedFetch from "utils/proxy/cached-fetch";
import { getSettings } from "utils/config";
import { getSettings } from "utils/config/config";
export default async function handler(req, res) {
const { latitude, longitude, provider, cache, lang } = req.query;

@ -9,20 +9,20 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import ServicesGroup from "components/services/group";
import BookmarksGroup from "components/bookmarks/group";
import Widget from "components/widget";
import Revalidate from "components/revalidate";
import Widget from "components/widgets/widget";
import Revalidate from "components/toggles/revalidate";
import createLogger from "utils/logger";
import { getSettings } from "utils/config";
import { getSettings } from "utils/config/config";
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"), {
const ThemeToggle = dynamic(() => import("components/toggles/theme"), {
ssr: false,
});
const ColorToggle = dynamic(() => import("components/color-toggle"), {
const ColorToggle = dynamic(() => import("components/toggles/color"), {
ssr: false,
});

@ -4,8 +4,8 @@ import path from "path";
import yaml from "js-yaml";
import checkAndCopyConfig from "utils/config";
import { servicesFromConfig, servicesFromDocker, cleanServiceGroups } from "utils/service-helpers";
import checkAndCopyConfig from "utils/config/config";
import { servicesFromConfig, servicesFromDocker, cleanServiceGroups } from "utils/config/service-helpers";
export async function bookmarksResponse() {
checkAndCopyConfig("bookmarks.yaml");

@ -3,7 +3,7 @@ import { readFileSync } from "fs";
import yaml from "js-yaml";
import checkAndCopyConfig from "utils/config";
import checkAndCopyConfig from "utils/config/config";
export default function getDockerArguments(server) {
checkAndCopyConfig("docker.yaml");

@ -5,8 +5,8 @@ import yaml from "js-yaml";
import Docker from "dockerode";
import * as shvl from "shvl";
import checkAndCopyConfig from "utils/config";
import getDockerArguments from "utils/docker";
import checkAndCopyConfig from "utils/config/config";
import getDockerArguments from "utils/config/docker";
export async function servicesFromConfig() {
checkAndCopyConfig("services.yaml");

@ -1,4 +1,4 @@
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
import { formatApiCall } from "utils/proxy/api-helpers";
import { httpProxy } from "utils/proxy/http";
import createLogger from "utils/logger";

@ -1,4 +1,4 @@
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
import { formatApiCall } from "utils/proxy/api-helpers";
import { httpProxy } from "utils/proxy/http";
import createLogger from "utils/logger";

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,17 +13,17 @@ export default function Component({ service }) {
const { data: adguardData, error: adguardError } = useSWR(formatProxyUrl(config, "stats"));
if (adguardError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!adguardData) {
return (
<Widget>
<Container>
<Block label={t("adguard.queries")} />
<Block label={t("adguard.blocked")} />
<Block label={t("adguard.filtered")} />
<Block label={t("adguard.latency")} />
</Widget>
</Container>
);
}
@ -31,7 +31,7 @@ export default function Component({ service }) {
adguardData.num_replaced_safebrowsing + adguardData.num_replaced_safesearch + adguardData.num_replaced_parental;
return (
<Widget>
<Container>
<Block label={t("adguard.queries")} value={t("common.number", { value: adguardData.num_dns_queries })} />
<Block label={t("adguard.blocked")} value={t("common.number", { value: adguardData.num_blocked_filtering })} />
<Block label={t("adguard.filtered")} value={t("common.number", { value: filtered })} />
@ -39,6 +39,6 @@ export default function Component({ service }) {
label={t("adguard.latency")}
value={t("common.ms", { value: adguardData.avg_processing_time * 1000, style: "unit", unit: "millisecond" })}
/>
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -15,16 +15,16 @@ export default function Component({ service }) {
const { data: failedLoginsData, error: failedLoginsError } = useSWR(formatProxyUrl(config, "login_failed"));
if (usersError || loginsError || failedLoginsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!usersData || !loginsData || !failedLoginsData) {
return (
<Widget>
<Container>
<Block label={t("authentik.users")} />
<Block label={t("authentik.loginsLast24H")} />
<Block label={t("authentik.failedLoginsLast24H")} />
</Widget>
</Container>
);
}
@ -39,10 +39,10 @@ export default function Component({ service }) {
);
return (
<Widget>
<Container>
<Block label={t("authentik.users")} value={t("common.number", { value: usersData.pagination.count })} />
<Block label={t("authentik.loginsLast24H")} value={t("common.number", { value: loginsLast24H })} />
<Block label={t("authentik.failedLoginsLast24H")} value={t("common.number", { value: failedLoginsLast24H })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -14,22 +14,22 @@ export default function Component({ service }) {
const { data: moviesData, error: moviesError } = useSWR(formatProxyUrl(config, "movies"));
if (episodesError || moviesError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!episodesData || !moviesData) {
return (
<Widget>
<Container>
<Block label={t("bazarr.missingEpisodes")} />
<Block label={t("bazarr.missingMovies")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("bazarr.missingEpisodes")} value={t("common.number", { value: episodesData.total })} />
<Block label={t("bazarr.missingMovies")} value={t("common.number", { value: moviesData.total })} />
</Widget>
</Container>
);
}

@ -3,8 +3,8 @@ import { useState } from "react";
import { useTranslation } from "next-i18next";
import classNames from "classnames";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import Dropdown from "components/services/dropdown";
import { formatProxyUrl } from "utils/proxy/api-helpers";
@ -33,28 +33,28 @@ export default function Component({ service }) {
if (!symbols || symbols.length === 0) {
return (
<Widget>
<Container>
<Block value={t("coinmarketcap.configure")} />
</Widget>
</Container>
);
}
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData || !dateRange) {
return (
<Widget>
<Container>
<Block value={t("coinmarketcap.configure")} />
</Widget>
</Container>
);
}
const { data } = statsData;
return (
<Widget>
<Container>
<div className={classNames(service.description ? "-top-10" : "-top-8", "absolute right-1")}>
<Dropdown options={dateRangeOptions} value={dateRange} setValue={setDateRange} />
</div>
@ -87,6 +87,6 @@ export default function Component({ service }) {
</div>
))}
</div>
</Widget>
</Container>
);
}

@ -3,8 +3,8 @@ import { useTranslation } from "next-i18next";
import calculateCPUPercent from "./stats-helpers";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
export default function Component({ service }) {
const { t } = useTranslation();
@ -18,30 +18,30 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(`/api/docker/stats/${config.container}/${config.server || ""}`);
if (statsError || statusError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (statusData && statusData.status !== "running") {
return (
<Widget>
<Container>
<Block label={t("widget.status")} value={t("docker.offline")} />
</Widget>
</Container>
);
}
if (!statsData || !statusData) {
return (
<Widget>
<Container>
<Block label={t("docker.cpu")} />
<Block label={t("docker.mem")} />
<Block label={t("docker.rx")} />
<Block label={t("docker.tx")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("docker.cpu")} value={t("common.percent", { value: calculateCPUPercent(statsData.stats) })} />
<Block label={t("docker.mem")} value={t("common.bytes", { value: statsData.stats.memory_stats.usage })} />
{statsData.stats.networks && (
@ -50,6 +50,6 @@ export default function Component({ service }) {
<Block label={t("docker.tx")} value={t("common.bytes", { value: statsData.stats.networks.eth0.tx_bytes })} />
</>
)}
</Widget>
</Container>
);
}

@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next";
import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs";
import { MdOutlineSmartDisplay } from "react-icons/md";
import Widget from "components/services/widgets/widget";
import Container from "components/services/widget/container";
import { formatProxyUrl, formatProxyUrlWithSegments } from "utils/proxy/api-helpers";
function ticksToTime(ticks) {
@ -172,7 +172,7 @@ export default function Component({ service }) {
}
if (sessionsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!sessionsData) {

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -15,14 +15,14 @@ export default function Component({ service }) {
const { data: clientsData, error: clientsError } = useSWR(formatProxyUrl(config, `client`));
if (appsError || messagesError || clientsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
return (
<Widget>
<Container>
<Block label={t("gotify.apps")} value={appsData?.length} />
<Block label={t("gotify.clients")} value={clientsData?.length} />
<Block label={t("gotify.messages")} value={messagesData?.messages?.length} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: indexersData, error: indexersError } = useSWR(formatProxyUrl(config, "indexers"));
if (indexersError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!indexersData) {
return (
<Widget>
<Container>
<Block label={t("jackett.configured")} />
<Block label={t("jackett.errored")} />
</Widget>
</Container>
);
}
const errored = indexersData.filter((indexer) => indexer.last_error);
return (
<Widget>
<Container>
<Block label={t("jackett.configured")} value={t("common.number", { value: indexersData.length })} />
<Block label={t("jackett.errored")} value={t("common.number", { value: errored.length })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `request/count`));
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData) {
return (
<Widget>
<Container>
<Block label={t("jellyseerr.pending")} />
<Block label={t("jellyseerr.approved")} />
<Block label={t("jellyseerr.available")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("jellyseerr.pending")} value={statsData.pending} />
<Block label={t("jellyseerr.approved")} value={statsData.approved} />
<Block label={t("jellyseerr.available")} value={statsData.available} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -15,24 +15,24 @@ export default function Component({ service }) {
const { data: queueData, error: queueError } = useSWR(formatProxyUrl(config, "queue/status"));
if (albumsError || wantedError || queueError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!albumsData || !wantedData || !queueData) {
return (
<Widget>
<Container>
<Block label={t("lidarr.wanted")} />
<Block label={t("lidarr.queued")} />
<Block label={t("lidarr.albums")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("lidarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
<Block label={t("lidarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
<Block label={t("lidarr.albums")} value={t("common.number", { value: albumsData.have })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `instance`));
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData) {
return (
<Widget>
<Container>
<Block label={t("mastodon.user_count")} />
<Block label={t("mastodon.status_count")} />
<Block label={t("mastodon.domain_count")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("mastodon.user_count")} value={t("common.number", { value: statsData.stats.user_count })} />
<Block label={t("mastodon.status_count")} value={t("common.number", { value: statsData.stats.status_count })} />
<Block label={t("mastodon.domain_count")} value={t("common.number", { value: statsData.stats.domain_count })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,16 +13,16 @@ export default function Component({ service }) {
const { data: infoData, error: infoError } = useSWR(formatProxyUrl(config, "nginx/proxy-hosts"));
if (infoError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!infoData) {
return (
<Widget>
<Container>
<Block label={t("npm.enabled")} />
<Block label={t("npm.disabled")} />
<Block label={t("npm.total")} />
</Widget>
</Container>
);
}
@ -31,10 +31,10 @@ export default function Component({ service }) {
const total = infoData.length;
return (
<Widget>
<Container>
<Block label={t("npm.enabled")} value={enabled} />
<Block label={t("npm.disabled")} value={disabled} />
<Block label={t("npm.total")} value={total} />
</Widget>
</Container>
);
}

@ -1,4 +1,4 @@
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
import { formatApiCall } from "utils/proxy/api-helpers";
import widgets from "widgets/widgets";

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,21 +13,21 @@ export default function Component({ service }) {
const { data: statusData, error: statusError } = useSWR(formatProxyUrl(config, "status"));
if (statusError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statusData) {
return (
<Widget>
<Container>
<Block label={t("nzbget.rate")} />
<Block label={t("nzbget.remaining")} />
<Block label={t("nzbget.downloaded")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("nzbget.rate")} value={t("common.bitrate", { value: statusData.DownloadRate })} />
<Block
label={t("nzbget.remaining")}
@ -37,6 +37,6 @@ export default function Component({ service }) {
label={t("nzbget.downloaded")}
value={t("common.bytes", { value: statusData.DownloadedSizeMB * 1024 * 1024 })}
/>
</Widget>
</Container>
);
}

@ -1,6 +1,6 @@
import { JSONRPCClient } from "json-rpc-2.0";
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
export default async function nzbgetProxyHandler(req, res) {
const { group, service, endpoint } = req.query;

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `Request/count`));
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData) {
return (
<Widget>
<Container>
<Block label={t("ombi.pending")} />
<Block label={t("ombi.approved")} />
<Block label={t("ombi.available")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("ombi.pending")} value={statsData.pending} />
<Block label={t("ombi.approved")} value={statsData.approved} />
<Block label={t("ombi.available")} value={statsData.available} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, "request/count"));
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData) {
return (
<Widget>
<Container>
<Block label={t("overseerr.pending")} />
<Block label={t("overseerr.approved")} />
<Block label={t("overseerr.available")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("overseerr.pending")} value={statsData.pending} />
<Block label={t("overseerr.approved")} value={statsData.approved} />
<Block label={t("overseerr.available")} value={statsData.available} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: piholeData, error: piholeError } = useSWR(formatProxyUrl(config, "api.php"));
if (piholeError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!piholeData) {
return (
<Widget>
<Container>
<Block label={t("pihole.queries")} />
<Block label={t("pihole.blocked")} />
<Block label={t("pihole.gravity")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("pihole.queries")} value={t("common.number", { value: piholeData.dns_queries_today })} />
<Block label={t("pihole.blocked")} value={t("common.number", { value: piholeData.ads_blocked_today })} />
<Block label={t("pihole.gravity")} value={t("common.number", { value: piholeData.domains_being_blocked })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -17,21 +17,21 @@ export default function Component({ service }) {
);
if (containersError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!containersData) {
return (
<Widget>
<Container>
<Block label={t("portainer.running")} />
<Block label={t("portainer.stopped")} />
<Block label={t("portainer.total")} />
</Widget>
</Container>
);
}
if (containersData.error) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
const running = containersData.filter((c) => c.State === "running").length;
@ -39,10 +39,10 @@ export default function Component({ service }) {
const total = containersData.length;
return (
<Widget>
<Container>
<Block label={t("portainer.running")} value={running} />
<Block label={t("portainer.stopped")} value={stopped} />
<Block label={t("portainer.total")} value={total} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -14,18 +14,18 @@ export default function Component({ service }) {
const { data: grabsData, error: grabsError } = useSWR(formatProxyUrl(config, "indexerstats"));
if (indexersError || grabsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!indexersData || !grabsData) {
return (
<Widget>
<Container>
<Block label={t("prowlarr.enableIndexers")} />
<Block label={t("prowlarr.numberOfGrabs")} />
<Block label={t("prowlarr.numberOfQueries")} />
<Block label={t("prowlarr.numberOfFailGrabs")} />
<Block label={t("prowlarr.numberOfFailQueries")} />
</Widget>
</Container>
);
}
@ -43,12 +43,12 @@ export default function Component({ service }) {
});
return (
<Widget>
<Container>
<Block label={t("prowlarr.enableIndexers")} value={indexers.length} />
<Block label={t("prowlarr.numberOfGrabs")} value={numberOfGrabs} />
<Block label={t("prowlarr.numberOfQueries")} value={numberOfQueries} />
<Block label={t("prowlarr.numberOfFailGrabs")} value={numberOfFailedGrabs} />
<Block label={t("prowlarr.numberOfFailQueries")} value={numberOfFailedQueries} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,17 +13,17 @@ export default function Component({ service }) {
const { data: torrentData, error: torrentError } = useSWR(formatProxyUrl(config, "torrents/info"));
if (torrentError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!torrentData) {
return (
<Widget>
<Container>
<Block label={t("qbittorrent.leech")} />
<Block label={t("qbittorrent.download")} />
<Block label={t("qbittorrent.seed")} />
<Block label={t("qbittorrent.upload")} />
</Widget>
</Container>
);
}
@ -58,11 +58,11 @@ export default function Component({ service }) {
}
return (
<Widget>
<Container>
<Block label={t("qbittorrent.leech")} value={t("common.number", { value: leech })} />
<Block label={t("qbittorrent.download")} value={`${rateDl.toFixed(2)} ${unitsDl}`} />
<Block label={t("qbittorrent.seed")} value={t("common.number", { value: completed })} />
<Block label={t("qbittorrent.upload")} value={`${rateUl.toFixed(2)} ${unitsUl}`} />
</Widget>
</Container>
);
}

@ -1,7 +1,7 @@
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";
import getServiceWidget from "utils/config/service-helpers";
async function login(widget, params) {
const loginUrl = new URL(`${widget.url}/api/v2/auth/login`);

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -14,24 +14,24 @@ export default function Component({ service }) {
const { data: queuedData, error: queuedError } = useSWR(formatProxyUrl(config, "queue/status"));
if (moviesError || queuedError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!moviesData || !queuedData) {
return (
<Widget>
<Container>
<Block label={t("radarr.wanted")} />
<Block label={t("radarr.queued")} />
<Block label={t("radarr.movies")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("radarr.wanted")} value={moviesData.wanted} />
<Block label={t("radarr.queued")} value={queuedData.totalCount} />
<Block label={t("radarr.movies")} value={moviesData.have} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -15,24 +15,24 @@ export default function Component({ service }) {
const { data: queueData, error: queueError } = useSWR(formatProxyUrl(config, "queue/status"));
if (booksError || wantedError || queueError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!booksData || !wantedData || !queueData) {
return (
<Widget>
<Container>
<Block label={t("readarr.wanted")} />
<Block label={t("readarr.queued")} />
<Block label={t("readarr.books")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("readarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
<Block label={t("readarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
<Block label={t("readarr.books")} value={t("common.number", { value: booksData.have })} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,16 +13,16 @@ export default function Component({ service }) {
const { data: statusData, error: statusError } = useSWR(formatProxyUrl(config));
if (statusError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statusData) {
return (
<Widget>
<Container>
<Block label={t("rutorrent.active")} />
<Block label={t("rutorrent.upload")} />
<Block label={t("rutorrent.download")} />
</Widget>
</Container>
);
}
@ -33,10 +33,10 @@ export default function Component({ service }) {
const active = statusData.filter((torrent) => torrent["d.get_state"] === "1");
return (
<Widget>
<Container>
<Block label={t("rutorrent.active")} value={active.length} />
<Block label={t("rutorrent.upload")} value={t("common.bitrate", { value: upload })} />
<Block label={t("rutorrent.download")} value={t("common.bitrate", { value: download })} />
</Widget>
</Container>
);
}

@ -1,6 +1,6 @@
import RuTorrent from "rutorrent-promise";
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
export default async function rutorrentProxyHandler(req, res) {
const { group, service } = req.query;

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: queueData, error: queueError } = useSWR(formatProxyUrl(config, "queue"));
if (queueError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!queueData) {
return (
<Widget>
<Container>
<Block label={t("sabnzbd.rate")} />
<Block label={t("sabnzbd.queue")} />
<Block label={t("sabnzbd.timeleft")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("sabnzbd.rate")} value={`${queueData.queue.speed}B/s`} />
<Block label={t("sabnzbd.queue")} value={t("common.number", { value: queueData.queue.noofslots })} />
<Block label={t("sabnzbd.timeleft")} value={queueData.queue.timeleft} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -15,24 +15,24 @@ export default function Component({ service }) {
const { data: seriesData, error: seriesError } = useSWR(formatProxyUrl(config, "series"));
if (wantedError || queuedError || seriesError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!wantedData || !queuedData || !seriesData) {
return (
<Widget>
<Container>
<Block label={t("sonarr.wanted")} />
<Block label={t("sonarr.queued")} />
<Block label={t("sonarr.series")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("sonarr.wanted")} value={wantedData.totalRecords} />
<Block label={t("sonarr.queued")} value={queuedData.totalRecords} />
<Block label={t("sonarr.series")} value={seriesData.total} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,21 +13,21 @@ export default function Component({ service }) {
const { data: speedtestData, error: speedtestError } = useSWR(formatProxyUrl(config, "speedtest/latest"));
if (speedtestError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!speedtestData) {
return (
<Widget>
<Container>
<Block label={t("speedtest.download")} />
<Block label={t("speedtest.upload")} />
<Block label={t("speedtest.ping")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block
label={t("speedtest.download")}
value={t("common.bitrate", { value: speedtestData.data.download * 1024 * 1024 })}
@ -40,6 +40,6 @@ export default function Component({ service }) {
label={t("speedtest.ping")}
value={t("common.ms", { value: speedtestData.data.ping, style: "unit", unit: "millisecond" })}
/>
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,21 +13,21 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `status`));
if (statsError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!statsData) {
return (
<Widget>
<Container>
<Block label={t("strelaysrv.numActiveSessions")} />
<Block label={t("strelaysrv.numConnections")} />
<Block label={t("strelaysrv.bytesProxied")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block
label={t("strelaysrv.numActiveSessions")}
value={t("common.number", { value: statsData.numActiveSessions })}
@ -38,6 +38,6 @@ export default function Component({ service }) {
label={t("strelaysrv.transferRate")}
value={t("common.bitrate", { value: statsData.kbps10s1m5m15m30m60m[5] })}
/>
</Widget>
</Container>
);
}

@ -4,7 +4,7 @@ import { useTranslation } from "next-i18next";
import { BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs";
import { MdOutlineSmartDisplay, MdSmartDisplay } from "react-icons/md";
import Widget from "components/services/widgets/widget";
import Container from "components/services/widget/container";
import { formatProxyUrl } from "utils/proxy/api-helpers";
function millisecondsToTime(milliseconds) {
@ -124,7 +124,7 @@ export default function Component({ service }) {
});
if (activityError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!activityData) {

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,24 +13,24 @@ export default function Component({ service }) {
const { data: traefikData, error: traefikError } = useSWR(formatProxyUrl(config, "overview"));
if (traefikError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!traefikData) {
return (
<Widget>
<Container>
<Block label={t("traefik.routers")} />
<Block label={t("traefik.services")} />
<Block label={t("traefik.middleware")} />
</Widget>
</Container>
);
}
return (
<Widget>
<Container>
<Block label={t("traefik.routers")} value={traefikData.http.routers.total} />
<Block label={t("traefik.services")} value={traefikData.http.services.total} />
<Block label={t("traefik.middleware")} value={traefikData.http.middlewares.total} />
</Widget>
</Container>
);
}

@ -1,8 +1,8 @@
import useSWR from "swr";
import { useTranslation } from "next-i18next";
import Widget from "components/services/widgets/widget";
import Block from "components/services/widgets/block";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import { formatProxyUrl } from "utils/proxy/api-helpers";
export default function Component({ service }) {
@ -13,17 +13,17 @@ export default function Component({ service }) {
const { data: torrentData, error: torrentError } = useSWR(formatProxyUrl(config));
if (torrentError) {
return <Widget error={t("widget.api_error")} />;
return <Container error={t("widget.api_error")} />;
}
if (!torrentData) {
return (
<Widget>
<Container>
<Block label={t("transmission.leech")} />
<Block label={t("transmission.download")} />
<Block label={t("transmission.seed")} />
<Block label={t("transmission.upload")} />
</Widget>
</Container>
);
}
@ -59,11 +59,11 @@ export default function Component({ service }) {
}
return (
<Widget>
<Container>
<Block label={t("transmission.leech")} value={t("common.number", { value: leech })} />
<Block label={t("transmission.download")} value={`${rateDl.toFixed(2)} ${unitsDl}`} />
<Block label={t("transmission.seed")} value={t("common.number", { value: completed })} />
<Block label={t("transmission.upload")} value={`${rateUl.toFixed(2)} ${unitsUl}`} />
</Widget>
</Container>
);
}

@ -1,6 +1,6 @@
import { httpProxy } from "utils/proxy/http";
import { formatApiCall } from "utils/proxy/api-helpers";
import getServiceWidget from "utils/service-helpers";
import getServiceWidget from "utils/config/service-helpers";
export default async function transmissionProxyHandler(req, res) {
const { group, service, endpoint } = req.query;

Loading…
Cancel
Save