mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
adding cloudflare widget
This commit is contained in:
parent
01eea51555
commit
fa1792cd5f
@ -429,5 +429,9 @@
|
|||||||
"temp_tool": "Tool temp",
|
"temp_tool": "Tool temp",
|
||||||
"temp_bed": "Bed temp",
|
"temp_bed": "Bed temp",
|
||||||
"job_completion": "Completion"
|
"job_completion": "Completion"
|
||||||
|
},
|
||||||
|
"cloudflared" {
|
||||||
|
"origin_ip": "Origin IP",
|
||||||
|
"status": "Status"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,6 +40,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
headers.Authorization = `Token ${widget.key}`;
|
headers.Authorization = `Token ${widget.key}`;
|
||||||
} else if (widget.type === "miniflux") {
|
} else if (widget.type === "miniflux") {
|
||||||
headers["X-Auth-Token"] = `${widget.key}`;
|
headers["X-Auth-Token"] = `${widget.key}`;
|
||||||
|
} else if (widget.type === "cloudflared") {
|
||||||
|
headers["X-Auth-Email"] = `${widget.email}`;
|
||||||
|
headers["X-Auth-Key"] = `${widget.key}`;
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
30
src/widgets/cloudflared/component.jsx
Normal file
30
src/widgets/cloudflared/component.jsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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: 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="cloudflared.status" value={statsData.status} />
|
||||||
|
<Block label="cloudflared.origin_ip" value={statsData.origin_ip} />
|
||||||
|
</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: [
|
||||||
|
"origin_ip",
|
||||||
|
"status",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -6,6 +6,7 @@ const components = {
|
|||||||
autobrr: dynamic(() => import("./autobrr/component")),
|
autobrr: dynamic(() => import("./autobrr/component")),
|
||||||
bazarr: dynamic(() => import("./bazarr/component")),
|
bazarr: dynamic(() => import("./bazarr/component")),
|
||||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||||
|
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||||
deluge: dynamic(() => import("./deluge/component")),
|
deluge: dynamic(() => import("./deluge/component")),
|
||||||
downloadstation: dynamic(() => import("./downloadstation/component")),
|
downloadstation: dynamic(() => import("./downloadstation/component")),
|
||||||
|
@ -3,6 +3,7 @@ import authentik from "./authentik/widget";
|
|||||||
import autobrr from "./autobrr/widget";
|
import autobrr from "./autobrr/widget";
|
||||||
import bazarr from "./bazarr/widget";
|
import bazarr from "./bazarr/widget";
|
||||||
import changedetectionio from "./changedetectionio/widget";
|
import changedetectionio from "./changedetectionio/widget";
|
||||||
|
import cloudflared from "./cloudflared/widget";
|
||||||
import coinmarketcap from "./coinmarketcap/widget";
|
import coinmarketcap from "./coinmarketcap/widget";
|
||||||
import deluge from "./deluge/widget";
|
import deluge from "./deluge/widget";
|
||||||
import downloadstation from "./downloadstation/widget";
|
import downloadstation from "./downloadstation/widget";
|
||||||
@ -61,6 +62,7 @@ const widgets = {
|
|||||||
autobrr,
|
autobrr,
|
||||||
bazarr,
|
bazarr,
|
||||||
changedetectionio,
|
changedetectionio,
|
||||||
|
cloudflared,
|
||||||
coinmarketcap,
|
coinmarketcap,
|
||||||
deluge,
|
deluge,
|
||||||
diskstation: downloadstation,
|
diskstation: downloadstation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user