Deliver Schedule Path Info when fetching Schedules

This commit is contained in:
Sebastian 2023-10-24 19:22:56 +02:00
parent 7707831463
commit bd82fb9f81
4 changed files with 93 additions and 56 deletions

View File

@ -5,13 +5,10 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete Schedules"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete Schedules">
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/AbstractScheduleShortInfo.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskShortInfo.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/BasicScheduleShortInfo.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/ScheduleInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/ScheduleInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/ScheduleInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -100,7 +97,8 @@
<workItem from="1697969480767" duration="6407000" /> <workItem from="1697969480767" duration="6407000" />
<workItem from="1697989716016" duration="3814000" /> <workItem from="1697989716016" duration="3814000" />
<workItem from="1698067098771" duration="4770000" /> <workItem from="1698067098771" duration="4770000" />
<workItem from="1698127431684" duration="1530000" /> <workItem from="1698127431684" duration="2039000" />
<workItem from="1698164397550" duration="2329000" />
</task> </task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies"> <task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" /> <option name="closed" value="true" />

View File

@ -1,11 +1,15 @@
package core.api.models.timemanager.taskSchedule; package core.api.models.timemanager.taskSchedule;
import core.api.models.timemanager.taskgroup.TaskgroupEntityInfo;
import core.api.models.timemanager.tasks.TaskShortInfo;
import core.entities.timemanager.BasicTaskSchedule; import core.entities.timemanager.BasicTaskSchedule;
import core.entities.timemanager.ScheduleType; import core.entities.timemanager.ScheduleType;
import core.entities.timemanager.Taskgroup;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
public class ScheduleInfo { public class ScheduleInfo {
@ -15,22 +19,29 @@ public class ScheduleInfo {
private LocalDateTime finishTime; private LocalDateTime finishTime;
private int activeMinutes; private int activeMinutes;
private AbstractScheduleShortInfo schedule; private AbstractScheduleShortInfo schedule;
private List<TaskgroupEntityInfo> taskgroupPath;
private TaskShortInfo task;
public ScheduleInfo(BasicTaskSchedule basicTaskSchedule) { public ScheduleInfo(BasicTaskSchedule basicTaskSchedule) {
this.scheduleID = basicTaskSchedule.getScheduleID(); this.scheduleID = basicTaskSchedule.getScheduleID();
this.scheduleType = ScheduleType.BASIC; this.scheduleType = ScheduleType.BASIC;
this.startTime = basicTaskSchedule.getStartTime(); this.startTime = basicTaskSchedule.getStartTime();
this.finishTime = basicTaskSchedule.getFinishedTime(); this.finishTime = basicTaskSchedule.getFinishedTime();
if(this.finishTime == null) { if(this.finishTime == null && this.startTime != null) {
this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), LocalDate.now()).toMinutes(); this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), LocalDate.now()).toMinutes();
} else { } else if(this.startTime != null){
this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), basicTaskSchedule.getFinishedTime()).toMinutes(); this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), basicTaskSchedule.getFinishedTime()).toMinutes();
} }
this.schedule = new BasicScheduleShortInfo(basicTaskSchedule); this.schedule = new BasicScheduleShortInfo(basicTaskSchedule);
this.task = new TaskShortInfo(basicTaskSchedule.getTask());
List<Taskgroup> taskgroupPath = Taskgroup.getAncestorList(basicTaskSchedule.getTask().getTaskgroup());
taskgroupPath.add(basicTaskSchedule.getTask().getTaskgroup());
this.taskgroupPath = taskgroupPath.stream().map(TaskgroupEntityInfo::new).toList();
} }
public long getScheduleID() { public long getScheduleID() {
@ -80,4 +91,20 @@ public class ScheduleInfo {
public void setSchedule(AbstractScheduleShortInfo schedule) { public void setSchedule(AbstractScheduleShortInfo schedule) {
this.schedule = schedule; this.schedule = schedule;
} }
public List<TaskgroupEntityInfo> getTaskgroupPath() {
return taskgroupPath;
}
public void setTaskgroupPath(List<TaskgroupEntityInfo> taskgroupPath) {
this.taskgroupPath = taskgroupPath;
}
public TaskShortInfo getTask() {
return task;
}
public void setTask(TaskShortInfo task) {
this.task = task;
}
} }

View File

@ -0,0 +1,30 @@
package core.api.models.timemanager.tasks;
import core.entities.timemanager.Task;
public class TaskShortInfo {
private long taskID;
private String taskName;
public TaskShortInfo(Task task) {
this.taskID = task.getTaskID();
this.taskName = task.getTaskName();
}
public long getTaskID() {
return taskID;
}
public void setTaskID(long taskID) {
this.taskID = taskID;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
}

View File

@ -5,7 +5,7 @@ import {
TaskEntityInfo, TaskEntityInfo,
TaskgroupEntityInfo, TaskgroupEntityInfo,
TaskgroupService, TaskgroupService,
TaskService TaskService, TaskShortInfo
} from "../../../api"; } from "../../../api";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar"; import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar";
@ -49,6 +49,7 @@ export class SchedulerComponent implements OnInit{
taskgroup: TaskgroupEntityInfo | undefined taskgroup: TaskgroupEntityInfo | undefined
taskgroupPath: TaskgroupEntityInfo[] = [] taskgroupPath: TaskgroupEntityInfo[] = []
taskgroupID: number = -1; taskgroupID: number = -1;
scheduleID: number = -1;
@ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined @ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined
task: TaskEntityInfo | undefined task: TaskEntityInfo | undefined
@ -92,10 +93,14 @@ export class SchedulerComponent implements OnInit{
next: resp => { next: resp => {
this.task = resp; this.task = resp;
this.initializeNavigationLinkList() this.initializeNavigationLinkList()
this.fetchBasicSchedules(); this.fetschSchedules();
} }
}) })
} }
if(params.has('scheduleID')) {
this.scheduleID = Number(params.get('scheduleID'));
}
}); });
} }
@ -128,63 +133,40 @@ export class SchedulerComponent implements OnInit{
this.refresh.next(); this.refresh.next();
} }
fetchBasicSchedules() { fetschSchedules() {
this.activatedRoute.paramMap.subscribe(params => { this.scheduleService.schedulesGet().subscribe({
if(params.has('scheduleID')) { next: resp => {
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({ resp.forEach(schedule => {
next: resp => { let color: EventColor = colors['red']
resp.forEach(basicSchedule => { if(schedule.scheduleID === this.scheduleID) {
if(basicSchedule.scheduleID === Number(params.get('scheduleID'))) { color = colors['yellow']
this.events.push({ }
start: new Date(basicSchedule.scheduleDate),
title: this.computeTaskPath(), if(schedule.scheduleType === 'BASIC') {
color: colors['yellow'], this.events.push({
allDay: true, start: new Date(schedule.schedule.scheduleDate),
}) title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
this.basicScheduler?.setEditedBasicSchedule(basicSchedule); color: color,
} else { allDay: true,
this.events.push({
start: new Date(basicSchedule.scheduleDate),
title: this.computeTaskPath(),
color: colors['red'],
allDay: true,
})
}
})
this.refresh.next();
}
})
} else {
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
next: resp => {
resp.forEach(basicSchedule => {
this.events.push({
start: new Date(basicSchedule.scheduleDate),
title: this.computeTaskPath(),
color: colors['red'],
allDay: true,
})
}) })
this.refresh.next();
} }
}) })
this.refresh.next();
} }
}); })
} }
eventClicked({ event }: { event: CalendarEvent }): void { eventClicked({ event }: { event: CalendarEvent }): void {
this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID ) this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
} }
computeTaskPath() { computeTaskPath(taskgroupPath: TaskgroupEntityInfo[], task: TaskShortInfo | TaskEntityInfo) {
let result = ""; let result = "";
this.taskgroupPath.forEach(taskgroupPathPart => { taskgroupPath.forEach(taskgroupPathPart => {
result += taskgroupPathPart.taskgroupName + "/" result += taskgroupPathPart.taskgroupName + "/"
}); });
result += this.taskgroup!.taskgroupName + "/" result += task!.taskName
result += this.task!.taskName
return result; return result;
} }
} }