mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-06 11:41:50 +00:00
Enhancement: handle Vikunja v1rc4 breaking changes (#6234)
This commit is contained in:
parent
6c945d6573
commit
1aec61811f
@ -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.
|
||||
|
||||
| Vikunja Version | Homepage Widget Version |
|
||||
| --------------- | ----------------------- |
|
||||
| < v1.0.0-rc4 | 1 (default) |
|
||||
| >= v1.0.0-rc4 | 2 |
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: vikunja
|
||||
url: http[s]://vikunja.host.or.ip[:port]
|
||||
key: vikunjaapikey
|
||||
enableTaskList: true # optional, defaults to false
|
||||
version: 2 # optional, defaults to 1
|
||||
```
|
||||
|
||||
@ -569,6 +569,7 @@ export function cleanServiceGroups(groups) {
|
||||
"wgeasy",
|
||||
"grafana",
|
||||
"gluetun",
|
||||
"vikunja",
|
||||
].includes(type)
|
||||
) {
|
||||
if (version) widget.version = parseInt(version, 10);
|
||||
|
||||
@ -8,11 +8,15 @@ export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
|
||||
const version = widget.version ?? 1;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
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 = {
|
||||
api: `{url}/api/v1/{endpoint}`,
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
@ -11,15 +20,11 @@ const widget = {
|
||||
},
|
||||
tasks: {
|
||||
endpoint: "tasks/all?filter=done%3Dfalse&sort_by=due_date",
|
||||
map: (data) =>
|
||||
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,
|
||||
})),
|
||||
map: map,
|
||||
},
|
||||
tasks_v2: {
|
||||
endpoint: "tasks?filter=done%3Dfalse&sort_by=due_date",
|
||||
map: map,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user