From cf7e2c53771f9806e4d8fffe5708249709e11f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 18 Nov 2023 10:14:17 +0100 Subject: [PATCH] Include Statusfarbe of Tasks in TaskDetailOverview and fix wrong task date undefined error --- .../schedule-dashboard.component.ts | 9 ++---- .../task-detail-overview.component.html | 4 +-- .../task-detail-overview.component.ts | 31 ++++++++++++++++--- .../task-editor/task-editor.component.ts | 19 ++++++++---- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts index 1e825f0..b9bd4a4 100644 --- a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts +++ b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts @@ -19,8 +19,9 @@ export class ScheduleDashboardComponent implements OnInit{ @Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined @Input('task') task: TaskEntityInfo | undefined + @Input('schedules') schedules: ScheduleInfo[] = [] + - schedules: ScheduleInfo[] = [] constructor(private scheduleService: ScheduleService, private snackbar: MatSnackBar) { @@ -28,11 +29,7 @@ export class ScheduleDashboardComponent implements OnInit{ } ngOnInit() { - this.scheduleService.schedulesTaskIDGet(this.task!.taskID).subscribe({ - next: resp => { - this.schedules = resp; - } - }) + } reschedule() { diff --git a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html index 223e99c..43cae92 100644 --- a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html +++ b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html @@ -5,7 +5,7 @@
-
🟢 {{task!.taskName}}
+
{{taskStatus + " " + task!.taskName}}
@@ -39,7 +39,7 @@ Schedules
- +
diff --git a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.ts b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.ts index d9460b0..3309a1a 100644 --- a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.ts +++ b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.ts @@ -1,11 +1,20 @@ 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 {ScheduleService, TaskEntityInfo, TaskgroupEntityInfo, TaskgroupService, TaskService} from "../../../api"; +import { + ScheduleInfo, + ScheduleService, + TaskEntityInfo, + TaskgroupEntityInfo, + TaskgroupService, + TaskService +} from "../../../api"; import {TaskDashboardComponent} from "../task-dashboard/task-dashboard.component"; import {MatDialog} from "@angular/material/dialog"; import {TaskEditorComponent} from "../task-editor/task-editor.component"; import {TaskEditorData} from "../task-editor/TaskEditorData"; +import * as moment from "moment"; +import {ScheduleDashboardComponent} from "../../schedules/schedule-dashboard/schedule-dashboard.component"; @Component({ selector: 'app-task-detail-overview', @@ -31,6 +40,9 @@ export class TaskDetailOverviewComponent implements OnInit { @ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined task: TaskEntityInfo | undefined + schedules: ScheduleInfo[] = [] + + taskStatus: string = "🟢" constructor(private activatedRoute: ActivatedRoute, private taskgroupService: TaskgroupService, @@ -70,15 +82,26 @@ export class TaskDetailOverviewComponent implements OnInit { this.taskService.tasksTaskIDGet(Number(params.get('taskID'))).subscribe({ next: resp => { this.task = resp; + this.taskStatus = this.getStatusOfTask(resp) + } + }); + this.scheduleService.schedulesTaskIDGet(Number(params.get('taskID'))).subscribe({ + next: resp => { + this.schedules = resp; } }) } }); } - getStatusOfTask(task: TaskEntityInfo | undefined) { - return "green"; - + getStatusOfTask(task: TaskEntityInfo ) { + if(moment(task.deadline, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isBefore(moment())) { + return "🔴"; + } else if(this.schedules.length == 0){ + return "🟠"; + } else { + return "🟢"; + } } openTaskEditor() { diff --git a/frontend/src/app/tasks/task-editor/task-editor.component.ts b/frontend/src/app/tasks/task-editor/task-editor.component.ts index 954b88e..a79efe4 100644 --- a/frontend/src/app/tasks/task-editor/task-editor.component.ts +++ b/frontend/src/app/tasks/task-editor/task-editor.component.ts @@ -53,11 +53,11 @@ export class TaskEditorComponent implements OnInit { createTask() { let endDate_formatted: string|undefined = undefined; let startDate_formatted: string|undefined = undefined; - if(this.endDate.value.length > 0) { + if(this.endDate.value !== "") { endDate_formatted = moment(this.endDate.value).format('YYYY-MM-DDTHH:mm:ss.SSSZ'); } - if(this.startDate.value.length > 0) { + if(this.startDate.value !== "") { startDate_formatted = moment(this.startDate.value).format('YYYY-MM-DDTHH:mm:ss.SSSZ'); } this.taskService.tasksTaskgroupIDPut(this.editorData.taskgroupID, { @@ -85,13 +85,20 @@ export class TaskEditorComponent implements OnInit { } editTask() { - const startingDate = this.startDate.value.length == 0? null:this.startDate.value - const deadline = this.endDate.value.length == 0? null:this.endDate.value + let endDate_formatted: string|undefined = undefined; + let startDate_formatted: string|undefined = undefined; + if(this.endDate.value !== "") { + endDate_formatted = moment(this.endDate.value).format('YYYY-MM-DDTHH:mm:ss.SSSZ'); + } + + if(this.startDate.value !== "") { + startDate_formatted = moment(this.startDate.value).format('YYYY-MM-DDTHH:mm:ss.SSSZ'); + } this.taskService.tasksTaskIDPost(this.editorData.task!.taskID, { taskName: this.nameCtrl.value, eta: this.etaCtrl.value, - startDate: startingDate, - deadline: deadline, + startDate: startDate_formatted, + deadline: endDate_formatted, finishable: this.finishable }).subscribe({ next: resp => {