mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Merge pull request #1026 from Oupsman/pterodactyl
Pterodactyl widget: initial commit
This commit is contained in:
commit
65c06adb5a
@ -517,5 +517,9 @@
|
|||||||
"active_workers": "Active Workers",
|
"active_workers": "Active Workers",
|
||||||
"total_workers": "Total Workers",
|
"total_workers": "Total Workers",
|
||||||
"records_total": "Queue Length"
|
"records_total": "Queue Length"
|
||||||
|
},
|
||||||
|
"pterodactyl": {
|
||||||
|
"servers": "Servers",
|
||||||
|
"nodes": "Nodes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else if (widget.type === "cloudflared") {
|
} else if (widget.type === "cloudflared") {
|
||||||
headers["X-Auth-Email"] = `${widget.email}`;
|
headers["X-Auth-Email"] = `${widget.email}`;
|
||||||
headers["X-Auth-Key"] = `${widget.key}`;
|
headers["X-Auth-Key"] = `${widget.key}`;
|
||||||
|
} else if (widget.type === "pterodactyl") {
|
||||||
|
headers.Authorization = `Bearer ${widget.key}`;
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ const components = {
|
|||||||
portainer: dynamic(() => import("./portainer/component")),
|
portainer: dynamic(() => import("./portainer/component")),
|
||||||
prowlarr: dynamic(() => import("./prowlarr/component")),
|
prowlarr: dynamic(() => import("./prowlarr/component")),
|
||||||
proxmox: dynamic(() => import("./proxmox/component")),
|
proxmox: dynamic(() => import("./proxmox/component")),
|
||||||
|
pterodactyl: dynamic(() => import("./pterodactyl/component")),
|
||||||
pyload: dynamic(() => import("./pyload/component")),
|
pyload: dynamic(() => import("./pyload/component")),
|
||||||
qbittorrent: dynamic(() => import("./qbittorrent/component")),
|
qbittorrent: dynamic(() => import("./qbittorrent/component")),
|
||||||
radarr: dynamic(() => import("./radarr/component")),
|
radarr: dynamic(() => import("./radarr/component")),
|
||||||
@ -76,4 +77,4 @@ const components = {
|
|||||||
uptimekuma: dynamic(() => import("./uptimekuma/component")),
|
uptimekuma: dynamic(() => import("./uptimekuma/component")),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default components;
|
export default components;
|
||||||
|
34
src/widgets/pterodactyl/component.jsx
Normal file
34
src/widgets/pterodactyl/component.jsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
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: nodesData, error: nodesError} = useWidgetAPI(widget, "nodes");
|
||||||
|
|
||||||
|
if (nodesError) {
|
||||||
|
return <Container error={ nodesError } />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nodesData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="pterodactyl.nodes" />
|
||||||
|
<Block label="pterodactyl.servers" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalServers = nodesData.data.reduce((total, node) =>
|
||||||
|
node.attributes?.relationships?.servers?.data?.length ?? 0 + total, 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="pterodactyl.nodes" value={nodesData.data.length} />
|
||||||
|
<Block label="pterodactyl.servers" value={totalServers} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
17
src/widgets/pterodactyl/widget.js
Normal file
17
src/widgets/pterodactyl/widget.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/application/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
nodes: {
|
||||||
|
endpoint: "nodes?include=servers",
|
||||||
|
validate: [
|
||||||
|
"data"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -46,6 +46,7 @@ import plex from "./plex/widget";
|
|||||||
import portainer from "./portainer/widget";
|
import portainer from "./portainer/widget";
|
||||||
import prowlarr from "./prowlarr/widget";
|
import prowlarr from "./prowlarr/widget";
|
||||||
import proxmox from "./proxmox/widget";
|
import proxmox from "./proxmox/widget";
|
||||||
|
import pterodactyl from "./pterodactyl/widget";
|
||||||
import pyload from "./pyload/widget";
|
import pyload from "./pyload/widget";
|
||||||
import qbittorrent from "./qbittorrent/widget";
|
import qbittorrent from "./qbittorrent/widget";
|
||||||
import radarr from "./radarr/widget";
|
import radarr from "./radarr/widget";
|
||||||
@ -119,6 +120,7 @@ const widgets = {
|
|||||||
portainer,
|
portainer,
|
||||||
prowlarr,
|
prowlarr,
|
||||||
proxmox,
|
proxmox,
|
||||||
|
pterodactyl,
|
||||||
pyload,
|
pyload,
|
||||||
qbittorrent,
|
qbittorrent,
|
||||||
radarr,
|
radarr,
|
||||||
@ -144,4 +146,4 @@ const widgets = {
|
|||||||
uptimekuma,
|
uptimekuma,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default widgets;
|
export default widgets;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user