Reschedule Tasks (Basicschedules)

This commit is contained in:
Sebastian 2023-10-24 08:20:42 +02:00
parent d6d267c645
commit e2d871f7fb
8 changed files with 136 additions and 42 deletions

View File

@ -4,11 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Define Entity BasicTaskSchedule and Taskcontroller"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete Schedules">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html" 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$/../frontend/src/app/schedules/scheduler/scheduler.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.html" 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$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" 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" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -96,7 +95,7 @@
<workItem from="1697958118995" duration="5749000" /> <workItem from="1697958118995" duration="5749000" />
<workItem from="1697969480767" duration="6407000" /> <workItem from="1697969480767" duration="6407000" />
<workItem from="1697989716016" duration="3814000" /> <workItem from="1697989716016" duration="3814000" />
<workItem from="1698067098771" duration="4010000" /> <workItem from="1698067098771" duration="4770000" />
</task> </task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies"> <task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -146,7 +145,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1697976314517</updated> <updated>1697976314517</updated>
</task> </task>
<option name="localTasksCounter" value="7" /> <task id="LOCAL-00007" summary="Delete Schedules">
<option name="closed" value="true" />
<created>1698089745245</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1698089745245</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -160,7 +167,8 @@
<MESSAGE value="Delete and clear Tasks" /> <MESSAGE value="Delete and clear Tasks" />
<MESSAGE value="Delete and clear Tasks (Frontend)" /> <MESSAGE value="Delete and clear Tasks (Frontend)" />
<MESSAGE value="Define Entity BasicTaskSchedule and Taskcontroller" /> <MESSAGE value="Define Entity BasicTaskSchedule and Taskcontroller" />
<option name="LAST_COMMIT_MESSAGE" value="Define Entity BasicTaskSchedule and Taskcontroller" /> <MESSAGE value="Delete Schedules" />
<option name="LAST_COMMIT_MESSAGE" value="Delete Schedules" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@ -15,7 +15,8 @@ const routes: Routes = [
{path: 'taskgroups', component: TaskgroupDashboardComponent}, {path: 'taskgroups', component: TaskgroupDashboardComponent},
{path: 'taskgroups/:taskgroupID', component: TaskgroupDashboardComponent}, {path: 'taskgroups/:taskgroupID', component: TaskgroupDashboardComponent},
{path: 'taskgroups/:taskgroupID/tasks/:taskID', component: TaskDetailOverviewComponent}, {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({ @NgModule({

View File

@ -1,3 +1,15 @@
mat-form-field { .scheduleContainer {
width: 100%; display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
mat-form-field {
width: 80%;
}
.scheduleBtn {
float: right;
margin-top: 10px;
} }

View File

@ -1,8 +1,11 @@
<mat-form-field> <div class="scheduler-container">
<mat-form-field>
<input matInput [matDatepicker]="picker" [formControl]="dateCtrl"> <input matInput [matDatepicker]="picker" [formControl]="dateCtrl">
<mat-hint>MM/DD/YYYY</mat-hint> <mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle> <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker> <mat-datepicker #picker></mat-datepicker>
</mat-form-field> </mat-form-field>
<button class="scheduleBtn" mat-raised-button color="primary" (click)="schedule()">Schedule</button>
</div>
<button mat-raised-button color="primary" (click)="schedule()">Schedule</button>

View File

@ -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 {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 {MatSnackBar} from "@angular/material/snack-bar";
import {Router} from "@angular/router";
@Component({ @Component({
selector: 'app-basic-scheduler', selector: 'app-basic-scheduler',
templateUrl: './basic-scheduler.component.html', templateUrl: './basic-scheduler.component.html',
styleUrls: ['./basic-scheduler.component.css'] styleUrls: ['./basic-scheduler.component.css']
}) })
export class BasicSchedulerComponent { export class BasicSchedulerComponent implements OnChanges{
dateCtrl: FormControl = new FormControl('', [Validators.required]) dateCtrl: FormControl = new FormControl('', [Validators.required])
@Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined
@Input('task') task: TaskEntityInfo | undefined @Input('task') task: TaskEntityInfo | undefined
@Input('scheduleInfo') scheduleEntityInfo: BasicScheduleEntityInfo | undefined
@Output('onSchedule') scheduleEmitter: EventEmitter<BasicScheduleEntityInfo> = new EventEmitter<BasicScheduleEntityInfo>(); @Output('onSchedule') scheduleEmitter: EventEmitter<BasicScheduleEntityInfo> = new EventEmitter<BasicScheduleEntityInfo>();
constructor(private scheduleService: ScheduleService, constructor(private scheduleService: ScheduleService,
private snackbar: MatSnackBar) { private snackbar: MatSnackBar,
private router: Router) {
} }
setDate(date: Date) { setDate(date: Date) {
@ -24,6 +28,7 @@ export class BasicSchedulerComponent {
schedule() { schedule() {
if(this.task != undefined) { if(this.task != undefined) {
if(this.scheduleEntityInfo == undefined) {
this.scheduleService.schedulesTaskIDBasicPut(this.task.taskID, { this.scheduleService.schedulesTaskIDBasicPut(this.task.taskID, {
scheduleDate: this.dateCtrl.value scheduleDate: this.dateCtrl.value
}).subscribe({ }).subscribe({
@ -31,7 +36,43 @@ export class BasicSchedulerComponent {
this.scheduleEmitter.emit(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)
}
} }

View File

@ -3,7 +3,7 @@
<div class="basicScheduleContainer"> <div class="basicScheduleContainer">
<p class="basicScheduleContent">{{schedule.scheduleDate | date:'EEEE, d MMM. y'}}</p> <p class="basicScheduleContent">{{schedule.scheduleDate | date:'EEEE, d MMM. y'}}</p>
<div class="basicScheduleContent"> <div class="basicScheduleContent">
<button mat-icon-button color="primary"><mat-icon>edit</mat-icon></button> <button mat-icon-button color="primary" [routerLink]="['/taskgroups', taskgroup!.taskgroupID, 'tasks', task!.taskID, 'schedule', schedule.scheduleID]"><mat-icon>edit</mat-icon></button>
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button> <button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
</div> </div>
</div> </div>

View File

@ -19,6 +19,6 @@
> >
</mwl-calendar-week-view> </mwl-calendar-week-view>
<app-basic-scheduler *ngIf="scheduleStrategy === 1" #basicScheduler [task]="task" (onSchedule)="onBasicSchedule($event)"></app-basic-scheduler> <app-basic-scheduler *ngIf="scheduleStrategy === 1" #basicScheduler [task]="task" [taskgroup]="taskgroup" (onSchedule)="onBasicSchedule($event)"></app-basic-scheduler>
</div> </div>

View File

@ -129,6 +129,32 @@ export class SchedulerComponent implements OnInit{
} }
fetchBasicSchedules() { 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({ this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
next: resp => { next: resp => {
resp.forEach(basicSchedule => { resp.forEach(basicSchedule => {
@ -142,6 +168,9 @@ export class SchedulerComponent implements OnInit{
this.refresh.next(); this.refresh.next();
} }
}) })
}
});
} }