mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-07 08:20:53 +08:00
Enhancement: handle Vikunja v1rc4 breaking changes (#6234)
Some checks failed
Crowdin Action / Crowdin Sync (push) Has been cancelled
Docker CI / Linting Checks (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Repository Maintenance / Close Answered Discussions (push) Has been cancelled
Repository Maintenance / Stale (push) Has been cancelled
Repository Maintenance / Lock Old Threads (push) Has been cancelled
Repository Maintenance / Close Outdated Discussions (push) Has been cancelled
Repository Maintenance / Close Unsupported Feature Requests (push) Has been cancelled
Some checks failed
Crowdin Action / Crowdin Sync (push) Has been cancelled
Docker CI / Linting Checks (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Repository Maintenance / Close Answered Discussions (push) Has been cancelled
Repository Maintenance / Stale (push) Has been cancelled
Repository Maintenance / Lock Old Threads (push) Has been cancelled
Repository Maintenance / Close Outdated Discussions (push) Has been cancelled
Repository Maintenance / Close Unsupported Feature Requests (push) Has been cancelled
This commit is contained in:
@@ -9,10 +9,16 @@ Allowed fields: `["projects", "tasks7d", "tasksOverdue", "tasksInProgress"]`.
|
|||||||
|
|
||||||
A list of the next 5 tasks ordered by due date is disabled by default, but can be enabled with the `enableTaskList` option.
|
A list of the next 5 tasks ordered by due date is disabled by default, but can be enabled with the `enableTaskList` option.
|
||||||
|
|
||||||
|
| Vikunja Version | Homepage Widget Version |
|
||||||
|
| --------------- | ----------------------- |
|
||||||
|
| < v1.0.0-rc4 | 1 (default) |
|
||||||
|
| >= v1.0.0-rc4 | 2 |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
type: vikunja
|
type: vikunja
|
||||||
url: http[s]://vikunja.host.or.ip[:port]
|
url: http[s]://vikunja.host.or.ip[:port]
|
||||||
key: vikunjaapikey
|
key: vikunjaapikey
|
||||||
enableTaskList: true # optional, defaults to false
|
enableTaskList: true # optional, defaults to false
|
||||||
|
version: 2 # optional, defaults to 1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -569,6 +569,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
"wgeasy",
|
"wgeasy",
|
||||||
"grafana",
|
"grafana",
|
||||||
"gluetun",
|
"gluetun",
|
||||||
|
"vikunja",
|
||||||
].includes(type)
|
].includes(type)
|
||||||
) {
|
) {
|
||||||
if (version) widget.version = parseInt(version, 10);
|
if (version) widget.version = parseInt(version, 10);
|
||||||
|
|||||||
@@ -8,11 +8,15 @@ export default function Component({ service }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
|
const version = widget.version ?? 1;
|
||||||
|
|
||||||
const { data: projectsData, error: projectsError } = useWidgetAPI(widget, "projects");
|
const { data: projectsData, error: projectsError } = useWidgetAPI(widget, "projects");
|
||||||
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "tasks");
|
const { data: tasksData, error: tasksError } = useWidgetAPI(widget, version === 2 ? "tasks_v2" : "tasks");
|
||||||
|
|
||||||
if (projectsError || tasksError) {
|
if (projectsError || tasksError) {
|
||||||
return <Container service={service} error={projectsError ?? tasksError} />;
|
return <Container service={service} error={projectsError ?? tasksError} />;
|
||||||
|
} else if (projectsData?.message || tasksData?.message) {
|
||||||
|
return <Container service={service} error={projectsData?.message ?? tasksData?.message} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!projectsData || !tasksData) {
|
if (!projectsData || !tasksData) {
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { asJson } from "utils/proxy/api-helpers";
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const map = asJson(data).map((task) => ({
|
||||||
|
id: task.id,
|
||||||
|
title: task.title,
|
||||||
|
priority: task.priority,
|
||||||
|
dueDate: task.due_date,
|
||||||
|
dueDateIsDefault: task.due_date === "0001-01-01T00:00:00Z",
|
||||||
|
inProgress: task.percent_done > 0 && task.percent_done < 1,
|
||||||
|
}));
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: `{url}/api/v1/{endpoint}`,
|
api: `{url}/api/v1/{endpoint}`,
|
||||||
proxyHandler: credentialedProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
@@ -11,15 +20,11 @@ const widget = {
|
|||||||
},
|
},
|
||||||
tasks: {
|
tasks: {
|
||||||
endpoint: "tasks/all?filter=done%3Dfalse&sort_by=due_date",
|
endpoint: "tasks/all?filter=done%3Dfalse&sort_by=due_date",
|
||||||
map: (data) =>
|
map: map,
|
||||||
asJson(data).map((task) => ({
|
},
|
||||||
id: task.id,
|
tasks_v2: {
|
||||||
title: task.title,
|
endpoint: "tasks?filter=done%3Dfalse&sort_by=due_date",
|
||||||
priority: task.priority,
|
map: map,
|
||||||
dueDate: task.due_date,
|
|
||||||
dueDateIsDefault: task.due_date === "0001-01-01T00:00:00Z",
|
|
||||||
inProgress: task.percent_done > 0 && task.percent_done < 1,
|
|
||||||
})),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user