fix-issue-81 #88
@ -3,10 +3,7 @@ package core.api.controller;
 | 
			
		||||
 | 
			
		||||
import core.api.models.auth.SimpleStatusResponse;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.*;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleFieldInfo;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleInfo;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.BasicScheduleFieldInfo;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.ScheduleFieldInfo;
 | 
			
		||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.*;
 | 
			
		||||
import core.entities.timemanager.AbstractSchedule;
 | 
			
		||||
import core.entities.timemanager.AdvancedTaskSchedule;
 | 
			
		||||
import core.entities.timemanager.BasicTaskSchedule;
 | 
			
		||||
@ -50,7 +47,14 @@ public class ScheduleController {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<AbstractSchedule> taskSchedules = permissionResult.getResult().getBasicTaskSchedules();
 | 
			
		||||
        return ResponseEntity.ok(taskSchedules.stream().map(AbstractSchedule::toScheduleInfo).toList());
 | 
			
		||||
        List<ScheduleInfo> scheduleInfos = new ArrayList<>();
 | 
			
		||||
        for(AbstractSchedule schedule : taskSchedules) {
 | 
			
		||||
            //Filter completed schedules out
 | 
			
		||||
            if(!schedule.isCompleted()) {
 | 
			
		||||
                scheduleInfos.add(schedule.toScheduleInfo());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return ResponseEntity.ok(scheduleInfos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PutMapping("/schedules/{taskID}/basic")
 | 
			
		||||
 | 
			
		||||
@ -207,4 +207,8 @@ public class Task {
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void increaseWorkTime(long minutes) {
 | 
			
		||||
        this.workTime += (int) minutes;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,7 @@ import core.repositories.timemanager.TaskRepository;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.time.Duration;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@ -164,6 +165,9 @@ public class TaskScheduleService {
 | 
			
		||||
        if(schedule.getStartTime() != null && schedule.getStopTime() == null) {
 | 
			
		||||
            schedule.setStopTime(LocalDateTime.now());
 | 
			
		||||
            scheduleRepository.save(schedule);
 | 
			
		||||
            Duration scheduleDuration = Duration.between(schedule.getStartTime(), schedule.getStopTime());
 | 
			
		||||
            schedule.getTask().increaseWorkTime(scheduleDuration.toMinutes());
 | 
			
		||||
            taskRepository.save(schedule.getTask());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(finish) {
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,14 @@
 | 
			
		||||
    </mat-card-header>
 | 
			
		||||
    <mat-card-content>
 | 
			
		||||
      <p>ETA: {{task!.eta}} Minuten - Deadline: {{task!.deadline}}</p>
 | 
			
		||||
      <mat-progress-bar [mode]="'determinate'" [value]="task!.workTime"></mat-progress-bar>
 | 
			
		||||
      <div class="progress-stacked" >
 | 
			
		||||
        <div class="progress" role="progressbar" aria-label="Segment one" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100" [style.width]=currentProgress>
 | 
			
		||||
          <div class="progress-bar">{{currentProgress}}</div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="progress" role="progressbar" aria-label="Segment two" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" [style.width]=futureProgress>
 | 
			
		||||
          <div class="progress-bar bg-success">{{futureProgress}}</div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </mat-card-content>
 | 
			
		||||
    <mat-card-actions *ngIf="taskgroup != undefined && task != undefined">
 | 
			
		||||
      <div style="width: 100%">
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
 | 
			
		||||
import {NavigationLink, NavigationLinkListComponent} from "../../navigation-link-list/navigation-link-list.component";
 | 
			
		||||
import {ActivatedRoute, Router} from "@angular/router";
 | 
			
		||||
import {
 | 
			
		||||
  AdvancedScheduleInfo,
 | 
			
		||||
  ScheduleInfo,
 | 
			
		||||
  ScheduleService,
 | 
			
		||||
  TaskEntityInfo,
 | 
			
		||||
@ -41,8 +42,11 @@ export class TaskDetailOverviewComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  task: TaskEntityInfo | undefined
 | 
			
		||||
  schedules: ScheduleInfo[] = []
 | 
			
		||||
  schedulesLoaded: boolean = false;
 | 
			
		||||
 | 
			
		||||
  taskStatus: string = "🟢"
 | 
			
		||||
  currentProgress: string = "0";
 | 
			
		||||
  futureProgress: string = "0";
 | 
			
		||||
 | 
			
		||||
  constructor(private activatedRoute: ActivatedRoute,
 | 
			
		||||
              private taskgroupService: TaskgroupService,
 | 
			
		||||
@ -83,11 +87,14 @@ export class TaskDetailOverviewComponent implements OnInit {
 | 
			
		||||
          next: resp => {
 | 
			
		||||
            this.task = resp;
 | 
			
		||||
            this.taskStatus = this.getStatusOfTask(resp)
 | 
			
		||||
            this.calcProgress();
 | 
			
		||||
          }
 | 
			
		||||
        });
 | 
			
		||||
        this.scheduleService.schedulesTaskIDGet(Number(params.get('taskID'))).subscribe({
 | 
			
		||||
          next: resp => {
 | 
			
		||||
            this.schedules = resp;
 | 
			
		||||
            this.schedulesLoaded = true;
 | 
			
		||||
            this.calcProgress();
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
@ -97,13 +104,35 @@ export class TaskDetailOverviewComponent implements OnInit {
 | 
			
		||||
  getStatusOfTask(task: TaskEntityInfo ) {
 | 
			
		||||
    if(moment(task.deadline, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isBefore(moment())) {
 | 
			
		||||
      return "🔴";
 | 
			
		||||
    } else if(this.schedules.length == 0){
 | 
			
		||||
    } else if(this.schedules.length == 0 && this.schedulesLoaded){
 | 
			
		||||
      return "🟠";
 | 
			
		||||
    } else {
 | 
			
		||||
      return "🟢";
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  calcProgress() {
 | 
			
		||||
    if(this.task != undefined && this.task!.eta > 0) {
 | 
			
		||||
      const currentProgress = this.task!.workTime / this.task!.eta * 100;
 | 
			
		||||
 | 
			
		||||
      let futureProgress = 0;
 | 
			
		||||
      this.schedules.forEach(schedule => {
 | 
			
		||||
        if(schedule.scheduleType == "ADVANCED" && schedule.startTime == null) {
 | 
			
		||||
          let advancedSchedule: AdvancedScheduleInfo = schedule as AdvancedScheduleInfo;
 | 
			
		||||
          if(moment(advancedSchedule.scheduleStartTime).isBefore(moment())) {
 | 
			
		||||
            const duration = moment.duration(moment(advancedSchedule.scheduleStopTime).diff(moment(advancedSchedule.scheduleStartTime)));
 | 
			
		||||
            const plannedMinutes = duration.asMinutes();
 | 
			
		||||
            futureProgress += plannedMinutes;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      this.futureProgress = (futureProgress) / this.task!.eta *100 + "%";
 | 
			
		||||
      this.currentProgress = currentProgress + "%";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  openTaskEditor() {
 | 
			
		||||
    if(this.task != undefined) {
 | 
			
		||||
      const taskEditorInfo: TaskEditorData = {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user