mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Feature: Add tandoor widget (#3060)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
8e9920a9d8
commit
b05b9b1420
15
docs/widgets/services/tandoor.md
Normal file
15
docs/widgets/services/tandoor.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: Tandoor
|
||||||
|
description: Tandoor Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Generate a user API key under `Settings > API > Generate`. For the token's scope, use `read`.
|
||||||
|
|
||||||
|
Allowed fields: `["users", "recipes", "keywords"]`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: tandoor
|
||||||
|
url: http://tandoor-frontend.host.or.ip
|
||||||
|
key: tandoor-api-token
|
||||||
|
```
|
@ -858,5 +858,10 @@
|
|||||||
"movies": "Movies",
|
"movies": "Movies",
|
||||||
"tags": "Tags",
|
"tags": "Tags",
|
||||||
"oCount": "O Count"
|
"oCount": "O Count"
|
||||||
|
},
|
||||||
|
"tandoor": {
|
||||||
|
"users": "Users",
|
||||||
|
"recipes": "Recipes",
|
||||||
|
"keywords": "Keywords"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else if (widget.type === "gotify") {
|
} else if (widget.type === "gotify") {
|
||||||
headers["X-gotify-Key"] = `${widget.key}`;
|
headers["X-gotify-Key"] = `${widget.key}`;
|
||||||
} else if (
|
} else if (
|
||||||
["authentik", "cloudflared", "ghostfolio", "mealie", "tailscale", "pterodactyl"].includes(widget.type)
|
["authentik", "cloudflared", "ghostfolio", "mealie", "tailscale", "tandoor", "pterodactyl"].includes(
|
||||||
|
widget.type,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
headers.Authorization = `Bearer ${widget.key}`;
|
headers.Authorization = `Bearer ${widget.key}`;
|
||||||
} else if (widget.type === "truenas") {
|
} else if (widget.type === "truenas") {
|
||||||
|
@ -101,6 +101,7 @@ const components = {
|
|||||||
stash: dynamic(() => import("./stash/component")),
|
stash: dynamic(() => import("./stash/component")),
|
||||||
strelaysrv: dynamic(() => import("./strelaysrv/component")),
|
strelaysrv: dynamic(() => import("./strelaysrv/component")),
|
||||||
tailscale: dynamic(() => import("./tailscale/component")),
|
tailscale: dynamic(() => import("./tailscale/component")),
|
||||||
|
tandoor: dynamic(() => import("./tandoor/component")),
|
||||||
tautulli: dynamic(() => import("./tautulli/component")),
|
tautulli: dynamic(() => import("./tautulli/component")),
|
||||||
tdarr: dynamic(() => import("./tdarr/component")),
|
tdarr: dynamic(() => import("./tdarr/component")),
|
||||||
traefik: dynamic(() => import("./traefik/component")),
|
traefik: dynamic(() => import("./traefik/component")),
|
||||||
|
32
src/widgets/tandoor/component.jsx
Normal file
32
src/widgets/tandoor/component.jsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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: spaceData, error: spaceError } = useWidgetAPI(widget, "space");
|
||||||
|
const { data: keywordData, error: keywordError } = useWidgetAPI(widget, "keyword");
|
||||||
|
|
||||||
|
if (spaceError || keywordError) {
|
||||||
|
const finalError = spaceError ?? keywordError;
|
||||||
|
return <Container service={service} error={finalError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spaceData || !keywordData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="tandoor.users" />
|
||||||
|
<Block label="tandoor.recipes" />
|
||||||
|
<Block label="tandoor.keywords" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="tandoor.users" value={spaceData[0]?.user_count} />
|
||||||
|
<Block label="tandoor.recipes" value={spaceData[0]?.recipe_count} />
|
||||||
|
<Block label="tandoor.keywords" value={keywordData.count} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
17
src/widgets/tandoor/widget.js
Normal file
17
src/widgets/tandoor/widget.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/{endpoint}/",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
space: {
|
||||||
|
endpoint: "space",
|
||||||
|
},
|
||||||
|
keyword: {
|
||||||
|
endpoint: "keyword",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -93,6 +93,7 @@ import speedtest from "./speedtest/widget";
|
|||||||
import stash from "./stash/widget";
|
import stash from "./stash/widget";
|
||||||
import strelaysrv from "./strelaysrv/widget";
|
import strelaysrv from "./strelaysrv/widget";
|
||||||
import tailscale from "./tailscale/widget";
|
import tailscale from "./tailscale/widget";
|
||||||
|
import tandoor from "./tandoor/widget";
|
||||||
import tautulli from "./tautulli/widget";
|
import tautulli from "./tautulli/widget";
|
||||||
import tdarr from "./tdarr/widget";
|
import tdarr from "./tdarr/widget";
|
||||||
import traefik from "./traefik/widget";
|
import traefik from "./traefik/widget";
|
||||||
@ -207,6 +208,7 @@ const widgets = {
|
|||||||
stash,
|
stash,
|
||||||
strelaysrv,
|
strelaysrv,
|
||||||
tailscale,
|
tailscale,
|
||||||
|
tandoor,
|
||||||
tautulli,
|
tautulli,
|
||||||
tdarr,
|
tdarr,
|
||||||
traefik,
|
traefik,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user