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).
|
||||
|
||||
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
|
||||
widget:
|
||||
type: fileflows
|
||||
url: http://your.fileflows.host:port
|
||||
version: 2 # optional, defaults to 1
|
||||
key: yourfenrustoken # required for version 2
|
||||
```
|
||||
|
||||
@@ -790,7 +790,8 @@
|
||||
"queue": "Queue",
|
||||
"processing": "Processing",
|
||||
"processed": "Processed",
|
||||
"time": "Time"
|
||||
"time": "Time",
|
||||
"failed": "Failed"
|
||||
},
|
||||
"firefly": {
|
||||
"networth": "Net Worth",
|
||||
|
||||
@@ -619,6 +619,7 @@ export function cleanServiceGroups(groups) {
|
||||
[
|
||||
"authentik",
|
||||
"beszel",
|
||||
"fileflows",
|
||||
"glances",
|
||||
"immich",
|
||||
"jellyfin",
|
||||
|
||||
@@ -130,6 +130,10 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
headers.Authorization = widget.key;
|
||||
} else if (widget.type === "gitlab") {
|
||||
headers["PRIVATE-TOKEN"] = widget.key;
|
||||
} else if (widget.type === "fileflows") {
|
||||
if (widget.key) {
|
||||
headers["X-Webhook-Token"] = `${widget.key}`;
|
||||
}
|
||||
} else if (widget.type === "speedtest") {
|
||||
if (widget.key) {
|
||||
// v1 does not require a key
|
||||
|
||||
@@ -40,6 +40,7 @@ vi.mock("widgets/widgets", () => ({
|
||||
checkmk: { api: "{url}/{endpoint}" },
|
||||
stocks: { api: "{url}/{endpoint}" },
|
||||
speedtest: { api: "{url}/{endpoint}" },
|
||||
fileflows: { api: "{url}/{endpoint}" },
|
||||
tubearchivist: { api: "{url}/{endpoint}" },
|
||||
autobrr: { 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: "gitlab", url: "http://x", key: "k" }, { "PRIVATE-TOKEN": "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" },
|
||||
{ Authorization: `Basic ${Buffer.from("$:k").toString("base64")}` },
|
||||
|
||||
@@ -8,8 +8,9 @@ export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
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) {
|
||||
return <Container service={service} error={fileflowsError} />;
|
||||
@@ -21,7 +22,18 @@ export default function Component({ service }) {
|
||||
<Block label="fileflows.queue" />
|
||||
<Block label="fileflows.processing" />
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,4 +62,23 @@ describe("widgets/fileflows/component", () => {
|
||||
expectBlockValue(container, "fileflows.processed", 3);
|
||||
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 = {
|
||||
api: "{url}/api/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
status: {
|
||||
endpoint: "status",
|
||||
endpoint: "api/status",
|
||||
},
|
||||
status_v2: {
|
||||
endpoint: "webhook/fenrus",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user