Deliver Schedule Path Info when fetching Schedules

This commit is contained in:
Sebastian 2023-10-24 19:22:56 +02:00
parent 7707831463
commit d4dd66073e
9 changed files with 148 additions and 57 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

@ -33,6 +33,7 @@ model/signUpRequest.ts
model/simpleStatusResponse.ts model/simpleStatusResponse.ts
model/taskEntityInfo.ts model/taskEntityInfo.ts
model/taskFieldInfo.ts model/taskFieldInfo.ts
model/taskShortInfo.ts
model/taskgroupDetailInfo.ts model/taskgroupDetailInfo.ts
model/taskgroupEntityInfo.ts model/taskgroupEntityInfo.ts
model/taskgroupFieldInfo.ts model/taskgroupFieldInfo.ts

View File

@ -17,6 +17,7 @@ export * from './signUpRequest';
export * from './simpleStatusResponse'; export * from './simpleStatusResponse';
export * from './taskEntityInfo'; export * from './taskEntityInfo';
export * from './taskFieldInfo'; export * from './taskFieldInfo';
export * from './taskShortInfo';
export * from './taskgroupDetailInfo'; export * from './taskgroupDetailInfo';
export * from './taskgroupEntityInfo'; export * from './taskgroupEntityInfo';
export * from './taskgroupFieldInfo'; export * from './taskgroupFieldInfo';

View File

@ -10,6 +10,8 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import { BasicScheduleFieldInfo } from './basicScheduleFieldInfo'; import { BasicScheduleFieldInfo } from './basicScheduleFieldInfo';
import { TaskgroupEntityInfo } from './taskgroupEntityInfo';
import { TaskShortInfo } from './taskShortInfo';
export interface ScheduleInfo { export interface ScheduleInfo {
@ -34,6 +36,8 @@ export interface ScheduleInfo {
*/ */
activeMinutes: number; activeMinutes: number;
schedule: BasicScheduleFieldInfo; schedule: BasicScheduleFieldInfo;
task: TaskShortInfo;
taskgroupPath: Array<TaskgroupEntityInfo>;
} }
export namespace ScheduleInfo { export namespace ScheduleInfo {
export type ScheduleTypeEnum = 'BASIC' | 'MODERATE' | 'ADVANCED'; export type ScheduleTypeEnum = 'BASIC' | 'MODERATE' | 'ADVANCED';

View File

@ -0,0 +1,24 @@
/**
* API Title
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface TaskShortInfo {
/**
* internal id of task
*/
taskID: number;
/**
* name of task
*/
taskName: string;
}

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,25 +133,20 @@ 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')) {
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
next: resp => { next: resp => {
resp.forEach(basicSchedule => { resp.forEach(schedule => {
if(basicSchedule.scheduleID === Number(params.get('scheduleID'))) { let color: EventColor = colors['red']
if(schedule.scheduleID === this.scheduleID) {
color = colors['yellow']
}
if(schedule.scheduleType === 'BASIC') {
this.events.push({ this.events.push({
start: new Date(basicSchedule.scheduleDate), start: new Date(schedule.schedule.scheduleDate),
title: this.computeTaskPath(), title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
color: colors['yellow'], color: color,
allDay: true,
})
this.basicScheduler?.setEditedBasicSchedule(basicSchedule);
} else {
this.events.push({
start: new Date(basicSchedule.scheduleDate),
title: this.computeTaskPath(),
color: colors['red'],
allDay: true, allDay: true,
}) })
} }
@ -154,37 +154,19 @@ export class SchedulerComponent implements OnInit{
this.refresh.next(); 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();
}
})
}
});
} }
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;
} }
} }

View File

@ -1734,6 +1734,8 @@ components:
- finishTime - finishTime
- activeMinutes - activeMinutes
- schedule - schedule
- task
- taskgroupPath
additionalProperties: false additionalProperties: false
properties: properties:
scheduleID: scheduleID:
@ -1764,3 +1766,25 @@ components:
type: object type: object
oneOf: oneOf:
- $ref: '#/components/schemas/BasicScheduleFieldInfo' - $ref: '#/components/schemas/BasicScheduleFieldInfo'
task:
type: object
$ref: '#/components/schemas/TaskShortInfo'
taskgroupPath:
type: array
items:
$ref: '#/components/schemas/TaskgroupEntityInfo'
TaskShortInfo:
required:
- taskID
- taskName
additionalProperties: false
properties:
taskID:
type: number
description: internal id of task
example: 1
taskName:
type: string
description: name of task
example: "Vorlesung zusammenfassen"