mirror of
https://github.com/gethomepage/homepage.git
synced 2026-10-15 15:09:56 -07:00
Chorehancement: add fileflows widget v2 for 26.10 breaking changes (#7239)
This commit is contained in:
@@ -5,10 +5,19 @@ description: Fileflows Widget Configuration
|
|||||||
|
|
||||||
Learn more about [FileFlows](https://github.com/revenz/FileFlows).
|
Learn more about [FileFlows](https://github.com/revenz/FileFlows).
|
||||||
|
|
||||||
Allowed fields: `["queue", "processing", "processed", "time"]`.
|
Allowed fields: `["queue", "processing", "processed", "time"]` (version 1) or `["queue", "processing", "processed", "failed"]` (version 2).
|
||||||
|
|
||||||
|
| FileFlows Version | Homepage Widget Version |
|
||||||
|
| ----------------- | ----------------------- |
|
||||||
|
| < 26.10 | 1 (default) |
|
||||||
|
| >= 26.10 | 2 |
|
||||||
|
|
||||||
|
Version 2 uses the ["Fenrus Dashboard Endpoint"](https://fileflows.com/docs/webconsole/config/settings/general#fenrus-dashboard-endpoint), which must be enabled. Use the token shown there as the `key`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
type: fileflows
|
type: fileflows
|
||||||
url: http://your.fileflows.host:port
|
url: http://your.fileflows.host:port
|
||||||
|
version: 2 # optional, defaults to 1
|
||||||
|
key: yourfenrustoken # required for version 2
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -790,7 +790,8 @@
|
|||||||
"queue": "Queue",
|
"queue": "Queue",
|
||||||
"processing": "Processing",
|
"processing": "Processing",
|
||||||
"processed": "Processed",
|
"processed": "Processed",
|
||||||
"time": "Time"
|
"time": "Time",
|
||||||
|
"failed": "Failed"
|
||||||
},
|
},
|
||||||
"firefly": {
|
"firefly": {
|
||||||
"networth": "Net Worth",
|
"networth": "Net Worth",
|
||||||
|
|||||||
@@ -619,6 +619,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
[
|
[
|
||||||
"authentik",
|
"authentik",
|
||||||
"beszel",
|
"beszel",
|
||||||
|
"fileflows",
|
||||||
"glances",
|
"glances",
|
||||||
"immich",
|
"immich",
|
||||||
"jellyfin",
|
"jellyfin",
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
headers.Authorization = widget.key;
|
headers.Authorization = widget.key;
|
||||||
} else if (widget.type === "gitlab") {
|
} else if (widget.type === "gitlab") {
|
||||||
headers["PRIVATE-TOKEN"] = widget.key;
|
headers["PRIVATE-TOKEN"] = widget.key;
|
||||||
|
} else if (widget.type === "fileflows") {
|
||||||
|
if (widget.key) {
|
||||||
|
headers["X-Webhook-Token"] = `${widget.key}`;
|
||||||
|
}
|
||||||
} else if (widget.type === "speedtest") {
|
} else if (widget.type === "speedtest") {
|
||||||
if (widget.key) {
|
if (widget.key) {
|
||||||
// v1 does not require a key
|
// v1 does not require a key
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ vi.mock("widgets/widgets", () => ({
|
|||||||
checkmk: { api: "{url}/{endpoint}" },
|
checkmk: { api: "{url}/{endpoint}" },
|
||||||
stocks: { api: "{url}/{endpoint}" },
|
stocks: { api: "{url}/{endpoint}" },
|
||||||
speedtest: { api: "{url}/{endpoint}" },
|
speedtest: { api: "{url}/{endpoint}" },
|
||||||
|
fileflows: { api: "{url}/{endpoint}" },
|
||||||
tubearchivist: { api: "{url}/{endpoint}" },
|
tubearchivist: { api: "{url}/{endpoint}" },
|
||||||
autobrr: { api: "{url}/{endpoint}" },
|
autobrr: { api: "{url}/{endpoint}" },
|
||||||
jellystat: { api: "{url}/{endpoint}" },
|
jellystat: { api: "{url}/{endpoint}" },
|
||||||
@@ -328,6 +329,7 @@ describe("utils/proxy/handlers/credentialed", () => {
|
|||||||
[{ type: "trilium", url: "http://x", key: "k" }, { Authorization: "k" }],
|
[{ type: "trilium", url: "http://x", key: "k" }, { Authorization: "k" }],
|
||||||
[{ type: "gitlab", url: "http://x", key: "k" }, { "PRIVATE-TOKEN": "k" }],
|
[{ type: "gitlab", url: "http://x", key: "k" }, { "PRIVATE-TOKEN": "k" }],
|
||||||
[{ type: "speedtest", url: "http://x", key: "k" }, { Authorization: "Bearer k" }],
|
[{ type: "speedtest", url: "http://x", key: "k" }, { Authorization: "Bearer k" }],
|
||||||
|
[{ type: "fileflows", url: "http://x", key: "k" }, { "X-Webhook-Token": "k" }],
|
||||||
[
|
[
|
||||||
{ type: "azuredevops", url: "http://x", key: "k" },
|
{ type: "azuredevops", url: "http://x", key: "k" },
|
||||||
{ Authorization: `Basic ${Buffer.from("$:k").toString("base64")}` },
|
{ Authorization: `Basic ${Buffer.from("$:k").toString("base64")}` },
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ export default function Component({ service }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
const version = widget.version ?? 1;
|
||||||
|
|
||||||
const { data: fileflowsData, error: fileflowsError } = useWidgetAPI(widget, "status");
|
const { data: fileflowsData, error: fileflowsError } = useWidgetAPI(widget, version === 2 ? "status_v2" : "status");
|
||||||
|
|
||||||
if (fileflowsError) {
|
if (fileflowsError) {
|
||||||
return <Container service={service} error={fileflowsError} />;
|
return <Container service={service} error={fileflowsError} />;
|
||||||
@@ -21,7 +22,18 @@ export default function Component({ service }) {
|
|||||||
<Block label="fileflows.queue" />
|
<Block label="fileflows.queue" />
|
||||||
<Block label="fileflows.processing" />
|
<Block label="fileflows.processing" />
|
||||||
<Block label="fileflows.processed" />
|
<Block label="fileflows.processed" />
|
||||||
<Block label="fileflows.time" />
|
{version === 2 ? <Block label="fileflows.failed" /> : <Block label="fileflows.time" />}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version === 2) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="fileflows.queue" value={t("common.number", { value: fileflowsData.Unprocessed })} />
|
||||||
|
<Block label="fileflows.processing" value={t("common.number", { value: fileflowsData.Processing })} />
|
||||||
|
<Block label="fileflows.processed" value={t("common.number", { value: fileflowsData.Processed })} />
|
||||||
|
<Block label="fileflows.failed" value={t("common.number", { value: fileflowsData.Failed })} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,23 @@ describe("widgets/fileflows/component", () => {
|
|||||||
expectBlockValue(container, "fileflows.processed", 3);
|
expectBlockValue(container, "fileflows.processed", 3);
|
||||||
expectBlockValue(container, "fileflows.time", "0:00");
|
expectBlockValue(container, "fileflows.time", "0:00");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses the webhook endpoint and fields for version 2", () => {
|
||||||
|
useWidgetAPI.mockReturnValue({
|
||||||
|
data: { Unprocessed: 4, Processing: 1, Processed: 10, Failed: 2 },
|
||||||
|
error: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const widget = { type: "fileflows", url: "http://x", version: 2 };
|
||||||
|
const { container } = renderWithProviders(<Component service={{ widget }} />, {
|
||||||
|
settings: { hideErrors: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(useWidgetAPI).toHaveBeenCalledWith(widget, "status_v2");
|
||||||
|
expectBlockValue(container, "fileflows.queue", 4);
|
||||||
|
expectBlockValue(container, "fileflows.processing", 1);
|
||||||
|
expectBlockValue(container, "fileflows.processed", 10);
|
||||||
|
expectBlockValue(container, "fileflows.failed", 2);
|
||||||
|
expect(screen.queryByText("fileflows.time")).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}",
|
api: "{url}/{endpoint}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
status: {
|
status: {
|
||||||
endpoint: "status",
|
endpoint: "api/status",
|
||||||
|
},
|
||||||
|
status_v2: {
|
||||||
|
endpoint: "webhook/fenrus",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user