Fix not working progress bar in task-detail-overview
All checks were successful
Java CI with Maven / test (push) Successful in 37s
Java CI with Maven / build-and-push-frontend (push) Successful in 7s
Java CI with Maven / build-and-push-backend (push) Successful in 8s

This commit is contained in:
Sebastian 2023-12-20 10:28:35 +01:00
parent 64e1a5c12f
commit be5af2bfe3
2 changed files with 35 additions and 1 deletions

View File

@ -14,7 +14,14 @@
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<p>ETA: {{task!.eta}} Minuten - Deadline: {{task!.deadline}}</p> <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-content>
<mat-card-actions *ngIf="taskgroup != undefined && task != undefined"> <mat-card-actions *ngIf="taskgroup != undefined && task != undefined">
<div style="width: 100%"> <div style="width: 100%">

View File

@ -2,6 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
import {NavigationLink, NavigationLinkListComponent} from "../../navigation-link-list/navigation-link-list.component"; import {NavigationLink, NavigationLinkListComponent} from "../../navigation-link-list/navigation-link-list.component";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import { import {
AdvancedScheduleInfo,
ScheduleInfo, ScheduleInfo,
ScheduleService, ScheduleService,
TaskEntityInfo, TaskEntityInfo,
@ -44,6 +45,8 @@ export class TaskDetailOverviewComponent implements OnInit {
schedulesLoaded: boolean = false; schedulesLoaded: boolean = false;
taskStatus: string = "🟢" taskStatus: string = "🟢"
currentProgress: string = "0";
futureProgress: string = "0";
constructor(private activatedRoute: ActivatedRoute, constructor(private activatedRoute: ActivatedRoute,
private taskgroupService: TaskgroupService, private taskgroupService: TaskgroupService,
@ -84,12 +87,14 @@ export class TaskDetailOverviewComponent implements OnInit {
next: resp => { next: resp => {
this.task = resp; this.task = resp;
this.taskStatus = this.getStatusOfTask(resp) this.taskStatus = this.getStatusOfTask(resp)
this.calcProgress();
} }
}); });
this.scheduleService.schedulesTaskIDGet(Number(params.get('taskID'))).subscribe({ this.scheduleService.schedulesTaskIDGet(Number(params.get('taskID'))).subscribe({
next: resp => { next: resp => {
this.schedules = resp; this.schedules = resp;
this.schedulesLoaded = true; this.schedulesLoaded = true;
this.calcProgress();
} }
}) })
} }
@ -106,6 +111,28 @@ export class TaskDetailOverviewComponent implements OnInit {
} }
} }
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() { openTaskEditor() {
if(this.task != undefined) { if(this.task != undefined) {
const taskEditorInfo: TaskEditorData = { const taskEditorInfo: TaskEditorData = {