mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-11 23:58:46 +00:00
Merge main
This commit is contained in:
commit
893b3f0986
53 changed files with 1068 additions and 383 deletions
31
src/widgets/cloudflared/component.jsx
Normal file
31
src/widgets/cloudflared/component.jsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
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: statsData, error: statsError } = useWidgetAPI(widget, "cfd_tunnel");
|
||||
|
||||
if (statsError) {
|
||||
return <Container error={statsError} />;
|
||||
}
|
||||
|
||||
if (!statsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="cloudflared.status" />
|
||||
<Block label="cloudflared.origin_ip" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const originIP = statsData.result.connections?.origin_ip ?? statsData.result.connections[0]?.origin_ip;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="cloudflared.status" value={statsData.result.status.charAt(0).toUpperCase() + statsData.result.status.slice(1)} />
|
||||
<Block label="cloudflared.origin_ip" value={originIP} />
|
||||
</Container>
|
||||
);
|
||||
}
|
18
src/widgets/cloudflared/widget.js
Normal file
18
src/widgets/cloudflared/widget.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "https://api.cloudflare.com/client/v4/accounts/{accountid}/{endpoint}/{tunnelid}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"cfd_tunnel": {
|
||||
endpoint: "cfd_tunnel",
|
||||
validate: [
|
||||
"success",
|
||||
"result"
|
||||
]
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -6,6 +6,7 @@ const components = {
|
|||
autobrr: dynamic(() => import("./autobrr/component")),
|
||||
bazarr: dynamic(() => import("./bazarr/component")),
|
||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||
deluge: dynamic(() => import("./deluge/component")),
|
||||
diskstation: dynamic(() => import("./diskstation/component")),
|
||||
|
@ -37,6 +38,7 @@ const components = {
|
|||
opnsense: dynamic(() => import("./opnsense/component")),
|
||||
overseerr: dynamic(() => import("./overseerr/component")),
|
||||
paperlessngx: dynamic(() => import("./paperlessngx/component")),
|
||||
proxmoxbackupserver: dynamic(() => import("./proxmoxbackupserver/component")),
|
||||
pihole: dynamic(() => import("./pihole/component")),
|
||||
plex: dynamic(() => import("./plex/component")),
|
||||
portainer: dynamic(() => import("./portainer/component")),
|
||||
|
@ -61,6 +63,7 @@ const components = {
|
|||
unifi: dynamic(() => import("./unifi/component")),
|
||||
watchtower: dynamic(() => import("./watchtower/component")),
|
||||
xteve: dynamic(() => import("./xteve/component")),
|
||||
immich: dynamic(() => import("./immich/component")),
|
||||
};
|
||||
|
||||
export default components;
|
||||
|
|
33
src/widgets/immich/component.jsx
Normal file
33
src/widgets/immich/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: immichData, error: immichError } = useWidgetAPI(widget);
|
||||
|
||||
if (immichError || immichData?.statusCode === 401) {
|
||||
return <Container error={immichError ?? immichData} />;
|
||||
}
|
||||
|
||||
if (!immichData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="immich.users" />
|
||||
<Block label="immich.photos" />
|
||||
<Block label="immich.videos" />
|
||||
<Block label="immich.storage" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="immich.users" value={immichData.usageByUser.length} />
|
||||
<Block label="immich.photos" value={immichData.photos} />
|
||||
<Block label="immich.videos" value={immichData.videos} />
|
||||
<Block label="immich.storage" value={immichData.usage} />
|
||||
</Container>
|
||||
);
|
||||
}
|
8
src/widgets/immich/widget.js
Normal file
8
src/widgets/immich/widget.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/server-info/stats",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -27,7 +27,7 @@ export default function Component({ service }) {
|
|||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="nzbget.rate" value={t("common.bitrate", { value: statusData.DownloadRate })} />
|
||||
<Block label="nzbget.rate" value={t("common.byterate", { value: statusData.DownloadRate })} />
|
||||
<Block
|
||||
label="nzbget.remaining"
|
||||
value={t("common.bytes", { value: statusData.RemainingSizeMB * 1024 * 1024 })}
|
||||
|
|
|
@ -33,16 +33,14 @@ export default function Component({ service }) {
|
|||
const cpu = 100 - parseFloat(cpuIdle);
|
||||
const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1];
|
||||
|
||||
const wanUpload = interfaceData.interfaces.wan['bytes transmitted'];
|
||||
const wanDownload = interfaceData.interfaces.wan['bytes received'];
|
||||
const wan = widget.wan ? interfaceData.interfaces[widget.wan] : interfaceData.interfaces.wan;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="opnsense.cpu" value={t("common.percent", { value: cpu.toFixed(2) })} />
|
||||
<Block label="opnsense.memory" value={memory} />
|
||||
<Block label="opnsense.wanUpload" value={t("common.bytes", { value: wanUpload })} />
|
||||
<Block label="opnsense.wanDownload" value={t("common.bytes", { value: wanDownload })} />
|
||||
|
||||
{wan && <Block label="opnsense.wanUpload" value={t("common.bytes", { value: wan['bytes transmitted'] })} />}
|
||||
{wan && <Block label="opnsense.wanDownload" value={t("common.bytes", { value: wan['bytes received'] })} />}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ export default function Component({ service }) {
|
|||
}
|
||||
|
||||
const { data } = clusterData ;
|
||||
const vms = data.filter(item => item.type === "qemu") || [];
|
||||
const lxc = data.filter(item => item.type === "lxc") || [];
|
||||
const vms = data.filter(item => item.type === "qemu" && item.template === 0) || [];
|
||||
const lxc = data.filter(item => item.type === "lxc" && item.template === 0) || [];
|
||||
const nodes = data.filter(item => item.type === "node") || [];
|
||||
|
||||
const runningVMs = vms.reduce(calcRunning, 0);
|
||||
|
|
45
src/widgets/proxmoxbackupserver/component.jsx
Normal file
45
src/widgets/proxmoxbackupserver/component.jsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
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: datastoreData, error: datastoreError } = useWidgetAPI(widget, "status/datastore-usage");
|
||||
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "nodes/localhost/tasks");
|
||||
const { data: hostData, error: hostError } = useWidgetAPI(widget, "nodes/localhost/status");
|
||||
|
||||
if (datastoreError || tasksError || hostError) {
|
||||
const finalError = tasksError ?? datastoreError ?? hostError;
|
||||
return <Container error={finalError} />;
|
||||
}
|
||||
|
||||
if (!datastoreData || !tasksData || !hostData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="proxmoxbackupserver.datastore_usage" />
|
||||
<Block label="proxmoxbackupserver.failed_tasks" />
|
||||
<Block label="proxmoxbackupserver.cpu_usage" />
|
||||
<Block label="proxmoxbackupserver.memory_usage" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const datastoreUsage = datastoreData.data[0].used / datastoreData.data[0].total * 100;
|
||||
const cpuUsage = hostData.data.cpu * 100;
|
||||
const memoryUsage = hostData.data.memory.used / hostData.data.memory.total * 100;
|
||||
const failedTasks = tasksData.total >= 100 ? "99+" : tasksData.total;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="proxmoxbackupserver.datastore_usage" value={t("common.percent", { value: datastoreUsage })} />
|
||||
<Block label="proxmoxbackupserver.failed_tasks_24h" value={failedTasks} />
|
||||
<Block label="proxmoxbackupserver.cpu_usage" value={t("common.percent", { value: cpuUsage })} />
|
||||
<Block label="proxmoxbackupserver.memory_usage" value={t("common.percent", { value: memoryUsage })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
22
src/widgets/proxmoxbackupserver/widget.js
Normal file
22
src/widgets/proxmoxbackupserver/widget.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const since = Date.now() - (24 * 60 * 60 * 1000);
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api2/json/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"status/datastore-usage": {
|
||||
endpoint: "status/datastore-usage",
|
||||
},
|
||||
"nodes/localhost/tasks": {
|
||||
endpoint: `nodes/localhost/tasks?errors=true&limit=100&since=${since}`,
|
||||
},
|
||||
"nodes/localhost/status": {
|
||||
endpoint: "nodes/localhost/status",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -3,6 +3,7 @@ import authentik from "./authentik/widget";
|
|||
import autobrr from "./autobrr/widget";
|
||||
import bazarr from "./bazarr/widget";
|
||||
import changedetectionio from "./changedetectionio/widget";
|
||||
import cloudflared from "./cloudflared/widget";
|
||||
import coinmarketcap from "./coinmarketcap/widget";
|
||||
import deluge from "./deluge/widget";
|
||||
import diskstation from "./diskstation/widget";
|
||||
|
@ -31,6 +32,7 @@ import ombi from "./ombi/widget";
|
|||
import opnsense from "./opnsense/widget";
|
||||
import overseerr from "./overseerr/widget";
|
||||
import paperlessngx from "./paperlessngx/widget";
|
||||
import proxmoxbackupserver from "./proxmoxbackupserver/widget";
|
||||
import pihole from "./pihole/widget";
|
||||
import plex from "./plex/widget";
|
||||
import portainer from "./portainer/widget";
|
||||
|
@ -55,6 +57,7 @@ import truenas from "./truenas/widget";
|
|||
import unifi from "./unifi/widget";
|
||||
import watchtower from "./watchtower/widget";
|
||||
import xteve from "./xteve/widget";
|
||||
import immich from "./immich/widget";
|
||||
|
||||
const widgets = {
|
||||
adguard,
|
||||
|
@ -62,6 +65,7 @@ const widgets = {
|
|||
autobrr,
|
||||
bazarr,
|
||||
changedetectionio,
|
||||
cloudflared,
|
||||
coinmarketcap,
|
||||
deluge,
|
||||
diskstation,
|
||||
|
@ -91,6 +95,7 @@ const widgets = {
|
|||
opnsense,
|
||||
overseerr,
|
||||
paperlessngx,
|
||||
proxmoxbackupserver,
|
||||
pihole,
|
||||
plex,
|
||||
portainer,
|
||||
|
@ -116,6 +121,7 @@ const widgets = {
|
|||
unifi_console: unifi,
|
||||
watchtower,
|
||||
xteve,
|
||||
immich,
|
||||
};
|
||||
|
||||
export default widgets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue