diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml index aa00851..6aad4ea 100644 --- a/backend/.idea/workspace.xml +++ b/backend/.idea/workspace.xml @@ -4,11 +4,10 @@ - - - - - + + + + @@ -96,7 +95,7 @@ - + @@ -146,7 +145,15 @@ 1697976314517 - + + + 1698089745245 + + + + 1698089745245 + + @@ -160,7 +167,8 @@ - + + diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index a3778b1..076bea8 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -15,7 +15,8 @@ const routes: Routes = [ {path: 'taskgroups', component: TaskgroupDashboardComponent}, {path: 'taskgroups/:taskgroupID', component: TaskgroupDashboardComponent}, {path: 'taskgroups/:taskgroupID/tasks/:taskID', component: TaskDetailOverviewComponent}, - {path: 'taskgroups/:taskgroupID/tasks/:taskID/schedule', component: SchedulerComponent} + {path: 'taskgroups/:taskgroupID/tasks/:taskID/schedule', component: SchedulerComponent}, + {path: 'taskgroups/:taskgroupID/tasks/:taskID/schedule/:scheduleID', component: SchedulerComponent} ]; @NgModule({ diff --git a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.css b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.css index c7acb4b..344ec8b 100644 --- a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.css +++ b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.css @@ -1,3 +1,15 @@ -mat-form-field { - width: 100%; +.scheduleContainer { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +mat-form-field { + width: 80%; +} + +.scheduleBtn { + float: right; + margin-top: 10px; } diff --git a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.html b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.html index 45f414c..0a25912 100644 --- a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.html +++ b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.html @@ -1,8 +1,11 @@ - - - MM/DD/YYYY - - - + + + + MM/DD/YYYY + + + + + Schedule + -Schedule diff --git a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.ts b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.ts index c53d01d..b5dd17c 100644 --- a/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.ts +++ b/frontend/src/app/schedules/basic-scheduler/basic-scheduler.component.ts @@ -1,21 +1,25 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core'; import {FormControl, Validators} from "@angular/forms"; -import {BasicScheduleEntityInfo, ScheduleService, TaskEntityInfo} from "../../../api"; +import {BasicScheduleEntityInfo, ScheduleService, TaskEntityInfo, TaskgroupEntityInfo} from "../../../api"; import {MatSnackBar} from "@angular/material/snack-bar"; +import {Router} from "@angular/router"; @Component({ selector: 'app-basic-scheduler', templateUrl: './basic-scheduler.component.html', styleUrls: ['./basic-scheduler.component.css'] }) -export class BasicSchedulerComponent { +export class BasicSchedulerComponent implements OnChanges{ dateCtrl: FormControl = new FormControl('', [Validators.required]) + @Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined @Input('task') task: TaskEntityInfo | undefined + @Input('scheduleInfo') scheduleEntityInfo: BasicScheduleEntityInfo | undefined @Output('onSchedule') scheduleEmitter: EventEmitter = new EventEmitter(); constructor(private scheduleService: ScheduleService, - private snackbar: MatSnackBar) { + private snackbar: MatSnackBar, + private router: Router) { } setDate(date: Date) { @@ -24,14 +28,51 @@ export class BasicSchedulerComponent { schedule() { if(this.task != undefined) { - this.scheduleService.schedulesTaskIDBasicPut(this.task.taskID, { - scheduleDate: this.dateCtrl.value - }).subscribe({ - next: resp => { - this.scheduleEmitter.emit(resp); - } - }) - } + if(this.scheduleEntityInfo == undefined) { + this.scheduleService.schedulesTaskIDBasicPut(this.task.taskID, { + scheduleDate: this.dateCtrl.value + }).subscribe({ + next: resp => { + this.scheduleEmitter.emit(resp); + } + }) + } else { + this.scheduleService.schedulesScheduleIDBasicPost(this.scheduleEntityInfo!.scheduleID, { + scheduleDate: this.dateCtrl.value + }).subscribe({ + next: resp => { + this.router.navigateByUrl("/taskgroups/" + this.taskgroup!.taskgroupID + "/tasks/" + this.task!.taskID); + }, + error: err => { + if(err.status == 403) { + this.snackbar.open("No permission", "",{duration: 2000}); + } else if(err.status == 404) { + this.snackbar.open("Not found", "", {duration: 2000}); + } else { + this.snackbar.open("Unexpected error", "",{duration: 2000}); + } + } + }) + } + } + } + + ngOnInit(): void { + if(this.scheduleEntityInfo != undefined) { + this.dateCtrl.setValue(this.scheduleEntityInfo!.scheduleID) + } + } + + ngOnChanges(): void { + if(this.scheduleEntityInfo != undefined) { + this.dateCtrl.setValue(this.scheduleEntityInfo!.scheduleID) + } + } + + setEditedBasicSchedule(basicSchedule: BasicScheduleEntityInfo) { + this.dateCtrl.setValue(basicSchedule.scheduleDate) + this.scheduleEntityInfo = basicSchedule; + console.log(this.dateCtrl.value) } } diff --git a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html index 2118056..1eb8a54 100644 --- a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html +++ b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html @@ -3,7 +3,7 @@ {{schedule.scheduleDate | date:'EEEE, d MMM. y'}} - edit + edit delete diff --git a/frontend/src/app/schedules/scheduler/scheduler.component.html b/frontend/src/app/schedules/scheduler/scheduler.component.html index ae24991..73e2dc4 100644 --- a/frontend/src/app/schedules/scheduler/scheduler.component.html +++ b/frontend/src/app/schedules/scheduler/scheduler.component.html @@ -19,6 +19,6 @@ > - + diff --git a/frontend/src/app/schedules/scheduler/scheduler.component.ts b/frontend/src/app/schedules/scheduler/scheduler.component.ts index 0f274fd..aaa61e2 100644 --- a/frontend/src/app/schedules/scheduler/scheduler.component.ts +++ b/frontend/src/app/schedules/scheduler/scheduler.component.ts @@ -129,19 +129,48 @@ export class SchedulerComponent implements OnInit{ } fetchBasicSchedules() { - 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.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, + }) + }) + this.refresh.next(); + } }) - this.refresh.next(); } - }) + }); + }
{{schedule.scheduleDate | date:'EEEE, d MMM. y'}}