issue-23 #24
@ -5,13 +5,10 @@
 | 
			
		||||
  </component>
 | 
			
		||||
  <component name="ChangeListManager">
 | 
			
		||||
    <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/taskSchedule/BasicScheduleShortInfo.java" afterDir="false" />
 | 
			
		||||
      <change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/ScheduleInfo.java" afterDir="false" />
 | 
			
		||||
      <change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskShortInfo.java" 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/repositories/timemanager/BasicTaskScheduleRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" 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" />
 | 
			
		||||
      <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$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" afterDir="false" />
 | 
			
		||||
    </list>
 | 
			
		||||
    <option name="SHOW_DIALOG" value="false" />
 | 
			
		||||
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
 | 
			
		||||
@ -100,7 +97,8 @@
 | 
			
		||||
      <workItem from="1697969480767" duration="6407000" />
 | 
			
		||||
      <workItem from="1697989716016" duration="3814000" />
 | 
			
		||||
      <workItem from="1698067098771" duration="4770000" />
 | 
			
		||||
      <workItem from="1698127431684" duration="1530000" />
 | 
			
		||||
      <workItem from="1698127431684" duration="2039000" />
 | 
			
		||||
      <workItem from="1698164397550" duration="2329000" />
 | 
			
		||||
    </task>
 | 
			
		||||
    <task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
 | 
			
		||||
      <option name="closed" value="true" />
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,15 @@
 | 
			
		||||
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.ScheduleType;
 | 
			
		||||
import core.entities.timemanager.Taskgroup;
 | 
			
		||||
 | 
			
		||||
import java.time.Duration;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class ScheduleInfo {
 | 
			
		||||
 | 
			
		||||
@ -15,22 +19,29 @@ public class ScheduleInfo {
 | 
			
		||||
 | 
			
		||||
    private LocalDateTime finishTime;
 | 
			
		||||
    private int activeMinutes;
 | 
			
		||||
 | 
			
		||||
    private AbstractScheduleShortInfo schedule;
 | 
			
		||||
 | 
			
		||||
    private List<TaskgroupEntityInfo> taskgroupPath;
 | 
			
		||||
 | 
			
		||||
    private TaskShortInfo task;
 | 
			
		||||
 | 
			
		||||
    public ScheduleInfo(BasicTaskSchedule basicTaskSchedule) {
 | 
			
		||||
        this.scheduleID = basicTaskSchedule.getScheduleID();
 | 
			
		||||
        this.scheduleType = ScheduleType.BASIC;
 | 
			
		||||
        this.startTime = basicTaskSchedule.getStartTime();
 | 
			
		||||
        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();
 | 
			
		||||
        } else {
 | 
			
		||||
        } else if(this.startTime != null){
 | 
			
		||||
            this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), basicTaskSchedule.getFinishedTime()).toMinutes();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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() {
 | 
			
		||||
@ -80,4 +91,20 @@ public class ScheduleInfo {
 | 
			
		||||
    public void setSchedule(AbstractScheduleShortInfo 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -5,7 +5,7 @@ import {
 | 
			
		||||
  TaskEntityInfo,
 | 
			
		||||
  TaskgroupEntityInfo,
 | 
			
		||||
  TaskgroupService,
 | 
			
		||||
  TaskService
 | 
			
		||||
  TaskService, TaskShortInfo
 | 
			
		||||
} from "../../../api";
 | 
			
		||||
import {ActivatedRoute, Router} from "@angular/router";
 | 
			
		||||
import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar";
 | 
			
		||||
@ -49,6 +49,7 @@ export class SchedulerComponent implements OnInit{
 | 
			
		||||
  taskgroup: TaskgroupEntityInfo | undefined
 | 
			
		||||
  taskgroupPath: TaskgroupEntityInfo[] = []
 | 
			
		||||
  taskgroupID: number = -1;
 | 
			
		||||
  scheduleID: number = -1;
 | 
			
		||||
  @ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined
 | 
			
		||||
 | 
			
		||||
  task: TaskEntityInfo | undefined
 | 
			
		||||
@ -92,10 +93,14 @@ export class SchedulerComponent implements OnInit{
 | 
			
		||||
          next: resp => {
 | 
			
		||||
            this.task = resp;
 | 
			
		||||
            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();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  fetchBasicSchedules() {
 | 
			
		||||
    this.activatedRoute.paramMap.subscribe(params => {
 | 
			
		||||
      if(params.has('scheduleID')) {
 | 
			
		||||
        this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
 | 
			
		||||
            next: resp => {
 | 
			
		||||
              resp.forEach(basicSchedule => {
 | 
			
		||||
                if(basicSchedule.scheduleID === Number(params.get('scheduleID'))) {
 | 
			
		||||
                  this.events.push({
 | 
			
		||||
                    start: new Date(basicSchedule.scheduleDate),
 | 
			
		||||
                    title: this.computeTaskPath(),
 | 
			
		||||
                    color: colors['yellow'],
 | 
			
		||||
                    allDay: true,
 | 
			
		||||
                  })
 | 
			
		||||
                  this.basicScheduler?.setEditedBasicSchedule(basicSchedule);
 | 
			
		||||
                } else {
 | 
			
		||||
                  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,
 | 
			
		||||
              })
 | 
			
		||||
  fetschSchedules() {
 | 
			
		||||
    this.scheduleService.schedulesGet().subscribe({
 | 
			
		||||
      next: resp => {
 | 
			
		||||
        resp.forEach(schedule => {
 | 
			
		||||
          let color: EventColor = colors['red']
 | 
			
		||||
          if(schedule.scheduleID === this.scheduleID) {
 | 
			
		||||
            color = colors['yellow']
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          if(schedule.scheduleType === 'BASIC') {
 | 
			
		||||
            this.events.push({
 | 
			
		||||
              start: new Date(schedule.schedule.scheduleDate),
 | 
			
		||||
              title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
 | 
			
		||||
              color: color,
 | 
			
		||||
              allDay: true,
 | 
			
		||||
            })
 | 
			
		||||
            this.refresh.next();
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        this.refresh.next();
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  eventClicked({ event }: { event: CalendarEvent }): void {
 | 
			
		||||
    this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  computeTaskPath() {
 | 
			
		||||
  computeTaskPath(taskgroupPath: TaskgroupEntityInfo[], task: TaskShortInfo | TaskEntityInfo) {
 | 
			
		||||
    let result = "";
 | 
			
		||||
    this.taskgroupPath.forEach(taskgroupPathPart => {
 | 
			
		||||
    taskgroupPath.forEach(taskgroupPathPart => {
 | 
			
		||||
      result += taskgroupPathPart.taskgroupName + "/"
 | 
			
		||||
    });
 | 
			
		||||
    result += this.taskgroup!.taskgroupName + "/"
 | 
			
		||||
    result += this.task!.taskName
 | 
			
		||||
    result += task!.taskName
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user