mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
Merge branch 'main' into glances-fs
This commit is contained in:
commit
108ca23212
75 changed files with 2336 additions and 528 deletions
36
src/widgets/atsumeru/component.jsx
Normal file
36
src/widgets/atsumeru/component.jsx
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
|
||||
const { data: infoData, error: infoError } = useWidgetAPI(widget, "info");
|
||||
|
||||
if (infoError) {
|
||||
return <Container service={service} error={infoError} />;
|
||||
}
|
||||
|
||||
if (!infoData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="atsumeru.series" />
|
||||
<Block label="atsumeru.archives" />
|
||||
<Block label="atsumeru.chapters" />
|
||||
<Block label="atsumeru.categories" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="atsumeru.series" value={t("common.number", { value: infoData.stats.total_series })} />
|
||||
<Block label="atsumeru.archives" value={t("common.number", { value: infoData.stats.total_archives })} />
|
||||
<Block label="atsumeru.chapters" value={t("common.number", { value: infoData.stats.total_chapters })} />
|
||||
<Block label="atsumeru.categories" value={t("common.number", { value: infoData.stats.total_categories })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
14
src/widgets/atsumeru/widget.js
Normal file
14
src/widgets/atsumeru/widget.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/server/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
info: {
|
||||
endpoint: "info"
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
36
src/widgets/calibreweb/component.jsx
Normal file
36
src/widgets/calibreweb/component.jsx
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
const { data, error } = useWidgetAPI(widget, "stats");
|
||||
|
||||
if (error) {
|
||||
return <Container service={service} error={error} />;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" />
|
||||
<Block label="calibreweb.authors" />
|
||||
<Block label="calibreweb.categories" />
|
||||
<Block label="calibreweb.series" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" value={t("common.number", { value: data.books })} />
|
||||
<Block label="calibreweb.authors" value={t("common.number", { value: data.authors })} />
|
||||
<Block label="calibreweb.categories" value={t("common.number", { value: data.categories })} />
|
||||
<Block label="calibreweb.series" value={t("common.number", { value: data.series })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
14
src/widgets/calibreweb/widget.js
Normal file
14
src/widgets/calibreweb/widget.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import genericProxyHandler from "../../utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
stats: {
|
||||
endpoint: "opds/stats",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -2,16 +2,19 @@ import dynamic from "next/dynamic";
|
|||
|
||||
const components = {
|
||||
adguard: dynamic(() => import("./adguard/component")),
|
||||
atsumeru: dynamic(() => import("./atsumeru/component")),
|
||||
audiobookshelf: dynamic(() => import("./audiobookshelf/component")),
|
||||
authentik: dynamic(() => import("./authentik/component")),
|
||||
autobrr: dynamic(() => import("./autobrr/component")),
|
||||
azuredevops: dynamic(() => import("./azuredevops/component")),
|
||||
bazarr: dynamic(() => import("./bazarr/component")),
|
||||
caddy: dynamic(() => import("./caddy/component")),
|
||||
calibreweb: dynamic(() => import("./calibreweb/component")),
|
||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||
channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")),
|
||||
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||
customapi: dynamic(() => import("./customapi/component")),
|
||||
deluge: dynamic(() => import("./deluge/component")),
|
||||
diskstation: dynamic(() => import("./diskstation/component")),
|
||||
downloadstation: dynamic(() => import("./downloadstation/component")),
|
||||
|
@ -42,6 +45,7 @@ const components = {
|
|||
kopia: dynamic(() => import("./kopia/component")),
|
||||
lidarr: dynamic(() => import("./lidarr/component")),
|
||||
mastodon: dynamic(() => import("./mastodon/component")),
|
||||
mealie: dynamic(() => import("./mealie/component")),
|
||||
medusa: dynamic(() => import("./medusa/component")),
|
||||
minecraft: dynamic(() => import("./minecraft/component")),
|
||||
miniflux: dynamic(() => import("./miniflux/component")),
|
||||
|
@ -93,6 +97,7 @@ const components = {
|
|||
unifi: dynamic(() => import("./unifi/component")),
|
||||
unmanic: dynamic(() => import("./unmanic/component")),
|
||||
uptimekuma: dynamic(() => import("./uptimekuma/component")),
|
||||
uptimerobot: dynamic(() => import("./uptimerobot/component")),
|
||||
urbackup: dynamic(() => import("./urbackup/component")),
|
||||
watchtower: dynamic(() => import("./watchtower/component")),
|
||||
whatsupdocker: dynamic(() => import("./whatsupdocker/component")),
|
||||
|
|
75
src/widgets/customapi/component.jsx
Normal file
75
src/widgets/customapi/component.jsx
Normal file
|
@ -0,0 +1,75 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
function getValue(field, data) {
|
||||
let value = data;
|
||||
let lastField = field;
|
||||
let key = '';
|
||||
|
||||
while (typeof lastField === "object") {
|
||||
key = Object.keys(lastField)[0] ?? null;
|
||||
|
||||
if (key === null) {
|
||||
break;
|
||||
}
|
||||
|
||||
value = value[key];
|
||||
lastField = lastField[key];
|
||||
}
|
||||
|
||||
if (typeof value === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return value[lastField] ?? null;
|
||||
}
|
||||
|
||||
function formatValue(t, mapping, value) {
|
||||
switch (mapping?.format) {
|
||||
case 'number':
|
||||
return t("common.number", { value: parseInt(value, 10) });
|
||||
case 'float':
|
||||
return t("common.number", { value });
|
||||
case 'percent':
|
||||
return t("common.percent", { value });
|
||||
case 'text':
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { mappings = [], refreshInterval = 10000 } = widget;
|
||||
const { data: customData, error: customError } = useWidgetAPI(widget, null, {
|
||||
refreshInterval: Math.max(1000, refreshInterval),
|
||||
});
|
||||
|
||||
if (customError) {
|
||||
return <Container service={service} error={customError} />;
|
||||
}
|
||||
|
||||
if (!customData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
{ mappings.slice(0,4).map(item => <Block label={item.label} key={item.field} />) }
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
{ mappings.slice(0,4).map(mapping => <Block
|
||||
label={mapping.label}
|
||||
key={mapping.field}
|
||||
value={formatValue(t, mapping, getValue(mapping.field, customData))}
|
||||
/>) }
|
||||
</Container>
|
||||
);
|
||||
}
|
8
src/widgets/customapi/widget.js
Normal file
8
src/widgets/customapi/widget.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -29,17 +29,19 @@ function ticksToString(ticks) {
|
|||
|
||||
function SingleSessionEntry({ playCommand, session }) {
|
||||
const {
|
||||
NowPlayingItem: { Name, SeriesName, RunTimeTicks },
|
||||
NowPlayingItem: { Name, SeriesName },
|
||||
PlayState: { PositionTicks, IsPaused, IsMuted },
|
||||
} = session;
|
||||
|
||||
const RunTimeTicks = session.NowPlayingItem?.RunTimeTicks ?? session.NowPlayingItem?.CurrentProgram?.RunTimeTicks ?? 0;
|
||||
|
||||
const { IsVideoDirect, VideoDecoderIsHardware, VideoEncoderIsHardware } = session?.TranscodingInfo || {
|
||||
IsVideoDirect: true,
|
||||
VideoDecoderIsHardware: true,
|
||||
VideoEncoderIsHardware: true,
|
||||
};
|
||||
|
||||
const percent = (PositionTicks / RunTimeTicks) * 100;
|
||||
const percent = Math.min(1, PositionTicks / RunTimeTicks) * 100;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -98,13 +100,15 @@ function SingleSessionEntry({ playCommand, session }) {
|
|||
|
||||
function SessionEntry({ playCommand, session }) {
|
||||
const {
|
||||
NowPlayingItem: { Name, SeriesName, RunTimeTicks },
|
||||
NowPlayingItem: { Name, SeriesName },
|
||||
PlayState: { PositionTicks, IsPaused, IsMuted },
|
||||
} = session;
|
||||
|
||||
const RunTimeTicks = session.NowPlayingItem?.RunTimeTicks ?? session.NowPlayingItem?.CurrentProgram?.RunTimeTicks ?? 0;
|
||||
|
||||
const { IsVideoDirect, VideoDecoderIsHardware, VideoEncoderIsHardware } = session?.TranscodingInfo || {};
|
||||
|
||||
const percent = (PositionTicks / RunTimeTicks) * 100;
|
||||
const percent = Math.min(1, PositionTicks / RunTimeTicks) * 100;
|
||||
|
||||
return (
|
||||
<div className="text-theme-700 dark:text-theme-200 relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1 flex">
|
||||
|
|
33
src/widgets/mealie/component.jsx
Normal file
33
src/widgets/mealie/component.jsx
Normal file
|
@ -0,0 +1,33 @@
|
|||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: mealieData, error: mealieError } = useWidgetAPI(widget);
|
||||
|
||||
if (mealieError || mealieData?.statusCode === 401) {
|
||||
return <Container service={service} error={mealieError ?? mealieData} />;
|
||||
}
|
||||
|
||||
if (!mealieData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="mealie.recipes" />
|
||||
<Block label="mealie.users" />
|
||||
<Block label="mealie.categories" />
|
||||
<Block label="mealie.tags" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="mealie.recipes" value={mealieData.totalRecipes} />
|
||||
<Block label="mealie.users" value={mealieData.totalUsers} />
|
||||
<Block label="mealie.categories" value={mealieData.totalCategories} />
|
||||
<Block label="mealie.tags" value={mealieData.totalTags} />
|
||||
</Container>
|
||||
);
|
||||
}
|
8
src/widgets/mealie/widget.js
Normal file
8
src/widgets/mealie/widget.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/groups/statistics",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
};
|
||||
|
||||
export default widget;
|
97
src/widgets/uptimerobot/component.jsx
Normal file
97
src/widgets/uptimerobot/component.jsx
Normal file
|
@ -0,0 +1,97 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
function secondsToDhms(seconds) {
|
||||
const d = Math.floor(seconds / (3600*24));
|
||||
const h = Math.floor(seconds % (3600*24) / 3600);
|
||||
const m = Math.floor(seconds % 3600 / 60);
|
||||
const s = Math.floor(seconds % 60);
|
||||
|
||||
const dDisplay = d > 0 ? d + (d === 1 ? " day, " : " days, ") : "";
|
||||
const hDisplay = h > 0 ? h + (h === 1 ? " hr, " : " hrs, ") : "";
|
||||
let mDisplay = m > 0 && d === 0 ? m + (m === 1 ? " min" : " mins") : "";
|
||||
let sDisplay = "";
|
||||
|
||||
if (d === 0 && h === 0) {
|
||||
mDisplay = m > 0 ? m + (m === 1 ? " min, " : " mins, ") : "";
|
||||
sDisplay = s > 0 ? s + (s === 1 ? " sec" : " secs") : "";
|
||||
}
|
||||
return (dDisplay + hDisplay + mDisplay + sDisplay).replace(/,\s*$/, "");
|
||||
}
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data: uptimerobotData, error: uptimerobotError } = useWidgetAPI(widget, "getmonitors");
|
||||
|
||||
if (uptimerobotError) {
|
||||
return <Container service={service} error={uptimerobotError} />;
|
||||
}
|
||||
|
||||
if (!uptimerobotData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="uptimerobot.status" />
|
||||
<Block label="uptimerobot.uptime" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
// multiple monitors
|
||||
if (uptimerobotData.pagination?.total > 1) {
|
||||
const sitesUp = uptimerobotData.monitors.filter(m => m.status === 2).length;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="uptimerobot.sitesUp" value={sitesUp} />
|
||||
<Block label="uptimerobot.sitesDown" value={uptimerobotData.pagination.total - sitesUp} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
// single monitor
|
||||
const monitor = uptimerobotData.monitors[0];
|
||||
let status;
|
||||
let uptime = 0;
|
||||
let logIndex = 0;
|
||||
|
||||
switch (monitor.status) {
|
||||
case 0:
|
||||
status = t("uptimerobot.paused");
|
||||
break;
|
||||
case 1:
|
||||
status = t("uptimerobot.notyetchecked");
|
||||
break;
|
||||
case 2:
|
||||
status = t("uptimerobot.up");
|
||||
uptime = secondsToDhms(monitor.logs[0].duration);
|
||||
logIndex = 1;
|
||||
break;
|
||||
case 8:
|
||||
status = t("uptimerobot.seemsdown");
|
||||
break;
|
||||
case 9:
|
||||
status = t("uptimerobot.down");
|
||||
break;
|
||||
default:
|
||||
status = t("uptimerobot.unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
const lastDown = new Date(monitor.logs[logIndex].datetime * 1000).toLocaleString();
|
||||
const downDuration = secondsToDhms(monitor.logs[logIndex].duration);
|
||||
const hideDown = logIndex === 1 && monitor.logs[logIndex].type !== 1;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="uptimerobot.status" value={status} />
|
||||
<Block label="uptimerobot.uptime" value={uptime} />
|
||||
{!hideDown && <Block label="uptimerobot.lastDown" value={lastDown} />}
|
||||
{!hideDown && <Block label="uptimerobot.downDuration" value={downDuration} />}
|
||||
</Container>
|
||||
);
|
||||
}
|
20
src/widgets/uptimerobot/widget.js
Normal file
20
src/widgets/uptimerobot/widget.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/v2/{endpoint}?api_key={key}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
getmonitors: {
|
||||
method: "POST",
|
||||
endpoint: "getMonitors",
|
||||
body: 'format=json&logs=1',
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
"cache-control": "no-cache"
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -1,14 +1,17 @@
|
|||
import adguard from "./adguard/widget";
|
||||
import atsumeru from "./atsumeru/widget";
|
||||
import audiobookshelf from "./audiobookshelf/widget";
|
||||
import authentik from "./authentik/widget";
|
||||
import autobrr from "./autobrr/widget";
|
||||
import azuredevops from "./azuredevops/widget";
|
||||
import bazarr from "./bazarr/widget";
|
||||
import caddy from "./caddy/widget";
|
||||
import calibreweb from "./calibreweb/widget";
|
||||
import changedetectionio from "./changedetectionio/widget";
|
||||
import channelsdvrserver from "./channelsdvrserver/widget";
|
||||
import cloudflared from "./cloudflared/widget";
|
||||
import coinmarketcap from "./coinmarketcap/widget";
|
||||
import customapi from "./customapi/widget";
|
||||
import deluge from "./deluge/widget";
|
||||
import diskstation from "./diskstation/widget";
|
||||
import downloadstation from "./downloadstation/widget";
|
||||
|
@ -36,6 +39,7 @@ import komga from "./komga/widget";
|
|||
import kopia from "./kopia/widget";
|
||||
import lidarr from "./lidarr/widget";
|
||||
import mastodon from "./mastodon/widget";
|
||||
import mealie from "./mealie/widget";
|
||||
import medusa from "./medusa/widget";
|
||||
import minecraft from "./minecraft/widget";
|
||||
import miniflux from "./miniflux/widget";
|
||||
|
@ -87,6 +91,7 @@ import truenas from "./truenas/widget";
|
|||
import unifi from "./unifi/widget";
|
||||
import unmanic from "./unmanic/widget";
|
||||
import uptimekuma from "./uptimekuma/widget";
|
||||
import uptimerobot from "./uptimerobot/widget";
|
||||
import watchtower from "./watchtower/widget";
|
||||
import whatsupdocker from "./whatsupdocker/widget";
|
||||
import xteve from "./xteve/widget";
|
||||
|
@ -94,16 +99,19 @@ import urbackup from "./urbackup/widget";
|
|||
|
||||
const widgets = {
|
||||
adguard,
|
||||
atsumeru,
|
||||
audiobookshelf,
|
||||
authentik,
|
||||
autobrr,
|
||||
azuredevops,
|
||||
bazarr,
|
||||
caddy,
|
||||
calibreweb,
|
||||
changedetectionio,
|
||||
channelsdvrserver,
|
||||
cloudflared,
|
||||
coinmarketcap,
|
||||
customapi,
|
||||
deluge,
|
||||
diskstation,
|
||||
downloadstation,
|
||||
|
@ -132,6 +140,7 @@ const widgets = {
|
|||
kopia,
|
||||
lidarr,
|
||||
mastodon,
|
||||
mealie,
|
||||
medusa,
|
||||
minecraft,
|
||||
miniflux,
|
||||
|
@ -184,6 +193,7 @@ const widgets = {
|
|||
unifi_console: unifi,
|
||||
unmanic,
|
||||
uptimekuma,
|
||||
uptimerobot,
|
||||
urbackup,
|
||||
watchtower,
|
||||
whatsupdocker,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue