feat: adding a widget n8n

This commit is contained in:
Julien Froidefond 2023-11-25 14:02:54 +01:00
parent c9991bc2a2
commit b66b1ad91e
53 changed files with 258 additions and 0 deletions

View File

@ -0,0 +1,15 @@
---
title: n8n
description: n8n Widget Configuration
---
Grab your API key in n8n : Settings -> n8n API.
Allowed fields: `["workflows", "executions"]`.
```yaml
widget:
type: n8n
url: http://n8n.host.or.ip:port
key: key
```

View File

@ -82,6 +82,7 @@ nav:
- widgets/services/mjpeg.md
- widgets/services/moonraker.md
- widgets/services/mylar.md
- widgets/services/n8n.md
- widgets/services/navidrome.md
- widgets/services/nextcloud.md
- widgets/services/nextdns.md

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Fysisk udgivelse",
"digitalRelease": "Digitale udgivelser",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physische Version",
"digitalRelease": "Digitale Version",
"noEventsToday": "Heute keine Ereignisse!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Lanzamiento en físico",
"digitalRelease": "Lanzamiento en digital",
"noEventsToday": "Sin eventos para hoy"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Sortie physique",
"digitalRelease": "Sortie numérique",
"noEventsToday": "Rien pour aujourd'hui !"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Release fisici",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "物理的なリリース",
"digitalRelease": "デジタル・リリース",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -746,5 +746,9 @@
"physicalRelease": "Physical release",
"inCinemas": "In cinemas",
"digitalRelease": "Digital release"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Fysieke versie",
"digitalRelease": "Digitale versie",
"noEventsToday": "Geen gebeurtenissen voor vandaag!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -746,5 +746,9 @@
"physicalRelease": "Physical release",
"inCinemas": "In cinemas",
"digitalRelease": "Digital release"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Lançamento físico",
"digitalRelease": "Lançamento digital",
"noEventsToday": "Não existem eventos hoje!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -746,5 +746,9 @@
"physicalRelease": "Physical release",
"inCinemas": "In cinemas",
"digitalRelease": "Digital release"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Fyzické vydanie",
"digitalRelease": "Digitálne vydanie",
"noEventsToday": "Žiadne udalosti na dnešný deň!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -746,5 +746,9 @@
"physicalRelease": "Physical release",
"inCinemas": "In cinemas",
"digitalRelease": "Digital release"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "实体发行",
"digitalRelease": "数字发行",
"noEventsToday": "今天没有活动!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -766,5 +766,9 @@
"physicalRelease": "Physical release",
"digitalRelease": "Digital release",
"noEventsToday": "No events for today!"
},
"n8n":{
"workflows": "Workflows",
"executions": "Executions"
}
}

View File

@ -61,6 +61,8 @@ export default async function credentialedProxyHandler(req, res, map) {
headers.Authorization = `Basic ${Buffer.from(`$:${widget.key}`).toString("base64")}`;
} else if (widget.type === "glances") {
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
} else if (widget.type === "n8n") {
headers["X-N8N-API-KEY"] = `${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

View File

@ -58,6 +58,7 @@ const components = {
navidrome: dynamic(() => import("./navidrome/component")),
nextcloud: dynamic(() => import("./nextcloud/component")),
nextdns: dynamic(() => import("./nextdns/component")),
n8n: dynamic(() => import("./n8n/component")),
npm: dynamic(() => import("./npm/component")),
nzbget: dynamic(() => import("./nzbget/component")),
octoprint: dynamic(() => import("./octoprint/component")),

View File

@ -0,0 +1,33 @@
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: workflowsData, error: workflowsError } = useWidgetAPI(widget, "workflows");
const { data: executionsData, error: executionsError } = useWidgetAPI(widget, "executions");
if (workflowsError || executionsError) {
const finalError = workflowsError ?? executionsError;
return <Container service={service} error={finalError} />;
}
if (!workflowsData || !executionsData) {
return (
<Container service={service}>
<Block label="n8n.workflows" />
<Block label="n8n.executions" />
</Container>
);
}
return (
<Container service={service}>
<Block label="n8n.workflows" value={t("common.number", { value: workflowsData.data.length })} />
<Block label="n8n.executions" value={t("common.number", { value: executionsData.data.length })} />
</Container>
);
}

20
src/widgets/n8n/widget.js Normal file
View File

@ -0,0 +1,20 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
// import { jsonArrayFilter } from "utils/proxy/api-helpers";
const widget = {
api: "{url}/api/v1/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
workflows: {
endpoint: "workflows?active=true",
validate: ["data"],
},
executions: {
endpoint: "executions?includeData=false&status=success",
validate: ["data"],
},
},
};
export default widget;

View File

@ -50,6 +50,7 @@ import mylar from "./mylar/widget";
import navidrome from "./navidrome/widget";
import nextcloud from "./nextcloud/widget";
import nextdns from "./nextdns/widget";
import n8n from "./n8n/widget";
import npm from "./npm/widget";
import nzbget from "./nzbget/widget";
import octoprint from "./octoprint/widget";
@ -152,6 +153,7 @@ const widgets = {
navidrome,
nextcloud,
nextdns,
n8n,
npm,
nzbget,
octoprint,