Merge pull request #1026 from Oupsman/pterodactyl

Pterodactyl widget: initial commit
pull/1051/head
shamoon 2 years ago committed by GitHub
commit 65c06adb5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -517,5 +517,9 @@
"active_workers": "Active Workers",
"total_workers": "Total Workers",
"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") {
headers["X-Auth-Email"] = `${widget.email}`;
headers["X-Auth-Key"] = `${widget.key}`;
} else if (widget.type === "pterodactyl") {
headers.Authorization = `Bearer ${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

@ -52,6 +52,7 @@ const components = {
portainer: dynamic(() => import("./portainer/component")),
prowlarr: dynamic(() => import("./prowlarr/component")),
proxmox: dynamic(() => import("./proxmox/component")),
pterodactyl: dynamic(() => import("./pterodactyl/component")),
pyload: dynamic(() => import("./pyload/component")),
qbittorrent: dynamic(() => import("./qbittorrent/component")),
radarr: dynamic(() => import("./radarr/component")),

@ -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>
);
}

@ -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 prowlarr from "./prowlarr/widget";
import proxmox from "./proxmox/widget";
import pterodactyl from "./pterodactyl/widget";
import pyload from "./pyload/widget";
import qbittorrent from "./qbittorrent/widget";
import radarr from "./radarr/widget";
@ -119,6 +120,7 @@ const widgets = {
portainer,
prowlarr,
proxmox,
pterodactyl,
pyload,
qbittorrent,
radarr,

Loading…
Cancel
Save