mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 15:01:17 -07:00
Fix: use seconds for PBS since (#6583)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
This commit is contained in:
@@ -8,9 +8,14 @@ export default function Component({ service }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
const taskQueryParams = {
|
||||||
|
errors: true,
|
||||||
|
limit: 100,
|
||||||
|
since: Math.floor(Date.now() / 1000) - 24 * 60 * 60,
|
||||||
|
};
|
||||||
|
|
||||||
const { data: datastoreData, error: datastoreError } = useWidgetAPI(widget, "status/datastore-usage");
|
const { data: datastoreData, error: datastoreError } = useWidgetAPI(widget, "status/datastore-usage");
|
||||||
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "nodes/localhost/tasks");
|
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "nodes/localhost/tasks", taskQueryParams);
|
||||||
const { data: hostData, error: hostError } = useWidgetAPI(widget, "nodes/localhost/status");
|
const { data: hostData, error: hostError } = useWidgetAPI(widget, "nodes/localhost/status");
|
||||||
|
|
||||||
if (datastoreError || tasksError || hostError) {
|
if (datastoreError || tasksError || hostError) {
|
||||||
|
|||||||
@@ -74,4 +74,23 @@ describe("widgets/proxmoxbackupserver/component", () => {
|
|||||||
expect(screen.getByText("25")).toBeInTheDocument(); // memory usage
|
expect(screen.getByText("25")).toBeInTheDocument(); // memory usage
|
||||||
expect(screen.getByText("99+")).toBeInTheDocument();
|
expect(screen.getByText("99+")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("requests failed tasks with a 24 hour since filter in epoch seconds", () => {
|
||||||
|
vi.spyOn(Date, "now").mockReturnValue(1_776_519_498_000);
|
||||||
|
|
||||||
|
useWidgetAPI
|
||||||
|
.mockReturnValueOnce({ data: undefined, error: undefined })
|
||||||
|
.mockReturnValueOnce({ data: undefined, error: undefined })
|
||||||
|
.mockReturnValueOnce({ data: undefined, error: undefined });
|
||||||
|
|
||||||
|
renderWithProviders(<Component service={{ widget: { type: "proxmoxbackupserver" } }} />, {
|
||||||
|
settings: { hideErrors: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, { type: "proxmoxbackupserver" }, "nodes/localhost/tasks", {
|
||||||
|
errors: true,
|
||||||
|
limit: 100,
|
||||||
|
since: 1_776_433_098,
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const since = Date.now() - 24 * 60 * 60 * 1000;
|
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api2/json/{endpoint}",
|
api: "{url}/api2/json/{endpoint}",
|
||||||
proxyHandler: credentialedProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
@@ -11,7 +9,7 @@ const widget = {
|
|||||||
endpoint: "status/datastore-usage",
|
endpoint: "status/datastore-usage",
|
||||||
},
|
},
|
||||||
"nodes/localhost/tasks": {
|
"nodes/localhost/tasks": {
|
||||||
endpoint: `nodes/localhost/tasks?errors=true&limit=100&since=${since}`,
|
endpoint: "nodes/localhost/tasks",
|
||||||
},
|
},
|
||||||
"nodes/localhost/status": {
|
"nodes/localhost/status": {
|
||||||
endpoint: "nodes/localhost/status",
|
endpoint: "nodes/localhost/status",
|
||||||
|
|||||||
Reference in New Issue
Block a user