-
- Number
-
-
-
- {{option}}
-
-
-
+
+
+
Register forgotten activity
+
+
+
+
+
+
+
+
+
+
0 && !taskgroupSelected">
+
+
+
+
+
+
+
+
+
+
-
Automatic starttime based on last schedule
-
Automatic starttime based on planned schedule
-
- Minutes spent
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts b/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts
index a2d601b..ea68ba4 100644
--- a/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts
+++ b/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts
@@ -1,76 +1,181 @@
import {Component, OnInit} from '@angular/core';
-import {ForgottenActivityRequest, ScheduleService, TaskService, TaskShortInfo} from "../../../api";
+import {
+ ForgottenActivityRequest,
+ ScheduleService,
+ TaskgroupEntityInfo,
+ TaskOverviewInfo,
+ TaskService,
+ TaskShortInfo
+} from "../../../api";
import {MatSnackBar} from "@angular/material/snack-bar";
import {DialogRef} from "@angular/cdk/dialog";
import {MatDialogRef} from "@angular/material/dialog";
-import {filter, map, Observable, startWith} from "rxjs";
+import {filter, map, Observable, startWith, Subject} from "rxjs";
import {FormControl} from "@angular/forms";
+import {CalendarEvent, CalendarEventAction, CalendarEventTimesChangedEvent} from "angular-calendar";
+import * as moment from "moment/moment";
+import {EventColor} from "calendar-utils";
+import {TaskOverviewData} from "../taskgroup-overview/taskgroup-overview.component";
+import {Router} from "@angular/router";
+
+const colors: Record
= {
+ red: {
+ primary: '#ad2121',
+ secondary: '#FAE3E3',
+ },
+ blue: {
+ primary: '#1e90ff',
+ secondary: '#D1E8FF',
+ },
+ yellow: {
+ primary: '#e3bc08',
+ secondary: '#FDF1BA',
+ },
+};
@Component({
selector: 'app-forgotten-task-start-dialog',
templateUrl: './forgotten-task-start-dialog.component.html',
styleUrls: ['./forgotten-task-start-dialog.component.css']
})
export class ForgottenTaskStartDialogComponent implements OnInit{
-
- tasks: TaskShortInfo[] = []
myControl: FormControl = new FormControl('');
filteredOptions: Observable | undefined;
+ viewDate: Date = new Date();
+ events: CalendarEvent[] = [];
+ refresh = new Subject();
+
lastSchedule: boolean = false
plannedSchedule: boolean = false
minutesSpentControl: FormControl = new FormControl();
+ tasks: CalendarEvent[] = [];
+ taskgroupID: number | undefined
- constructor(private taskService: TaskService,
- private snackbar: MatSnackBar,
- private dialogRef: MatDialogRef,
+ taskgroupSelected: boolean = false;
+
+ actions: CalendarEventAction[] = [
+ {
+ label: '',
+ a11yLabel: 'Delete',
+ onClick: ({ event }: { event: CalendarEvent }): void => {
+ this.events = this.events.filter((iEvent) => iEvent !== event);
+ this.eventClicked('Deleted', event);
+ },
+ },
+ ];
+
+
+ constructor(private router: Router,
private scheduleService: ScheduleService) {
}
ngOnInit() {
- this.taskService.tasksAllScopeDetailedGet("UNFINISHED", false).subscribe({
+ this.scheduleService.schedulesDateStartableGet(moment().format("yyyy-MM-DD"), false).subscribe({
next: resp => {
- this.tasks = resp;
- this.filteredOptions = this.myControl.valueChanges.pipe(
- startWith(''),
- map(value => this._filter(value || '')),
- );
- },
- error: err => {
- this.snackbar.open("Unexpected error", "", {duration: 2000});
+ resp.forEach(schedule => {
+ this.events.push({
+ title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
+ color: colors['red'],
+ start: new Date(schedule.startTime),
+ end: new Date(schedule.finishedTime!),
+ draggable: false,
+ resizable: {
+ beforeStart: false,
+ afterEnd: false
+ },
+ meta: {
+ taskID: schedule.task.taskID,
+ scheduleID: schedule.scheduleID,
+ taskgroupID: schedule.taskgroupPath[schedule.taskgroupPath.length-1].taskgroupID
+ },
+ })
+ })
+ this.refresh.next()
}
+
})
}
- private _filter(value: string): string[] {
- const filterValue = value.toLowerCase();
- return this.tasks.map(x => x.taskName).filter(option => option.toLowerCase().includes(filterValue))
- }
-
- registerActivity() {
- const task = this.tasks.find(task => task.taskName === this.myControl.value);
- if(task != undefined) {
- /*this.scheduleService.schedulesTaskIDForgottenPost(task.taskID, {
- mode: this.determineRegisterMode(),
- minutesSpent: this.minutesSpentControl.value
- }).subscribe({
- next: resp => {
- this.dialogRef.close(resp);
- },
- error: err => {
- if(err.status == 400) {
- this.snackbar.open("Invalid Operation", "", {duration: 2000});
- } else if(err.status == 403) {
- this.snackbar.open("No permission", "", {duration: 2000});
- } else if(err.status == 404) {
- this.snackbar.open("Task not found", "", {duration: 2000});
- } else {
- this.snackbar.open("Unexpected error", "", {duration: 2000});
- }
- }
- })*/
+ externalDrop(event: CalendarEvent) {
+ if (this.events.indexOf(event) === -1) {
+ this.events = this.events.filter((iEvent) => iEvent !== event);
+ this.events.push(event);
}
}
+
+ eventDropped({
+ event,
+ newStart,
+ newEnd,
+ allDay,
+ }: CalendarEventTimesChangedEvent): void {
+ const externalIndex = this.tasks.indexOf(event);
+ if (typeof allDay !== 'undefined') {
+ event.allDay = allDay;
+ }
+ if (externalIndex > -1) {
+ this.tasks.splice(externalIndex, 1);
+ this.events.push(event);
+ this.taskgroupSelected = true;
+ }
+ event.start = newStart;
+ if (newEnd) {
+ event.end = newEnd;
+ }
+ this.events = [...this.events];
+ }
+
+ onSelectTaskgroup(taskgroup: TaskOverviewData) {
+ this.tasks = [];
+ taskgroup.tasks.forEach(task => {
+ this.tasks.push({
+ title: task.taskName,
+ color: colors['yellow'],
+ start: new Date(),
+ draggable: true,
+ cssClass: 'test',
+ resizable: {
+ beforeStart: true,
+ afterEnd: true
+ },
+ meta: {
+ taskID: task.taskID,
+ scheduleID: undefined,
+ taskgroupID: taskgroup.taskgroupID
+ },
+ actions: this.actions
+ })
+ })
+ this.taskgroupID = taskgroup.taskgroupID;
+ }
+
+ private computeTaskPath(taskgroupPath: Array, task: TaskShortInfo) {
+ let result = "";
+ taskgroupPath.forEach(taskgroupPathPart => {
+ result += taskgroupPathPart.taskgroupName + "/"
+ });
+ result += task!.taskName
+ return result;
+ }
+
+ eventClicked(click: string, event: CalendarEvent) {
+ if(click == 'Deleted') {
+ this.events = this.events.filter(se => se !== event);
+ this.taskgroupSelected = false;
+ }
+ }
+
+ register() {
+ this.scheduleService.schedulesTaskIDForgottenPost(this.events[0].meta.taskID, {
+ startTime: moment(this.events[0].start).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
+ endTime: moment(this.events[0].end).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
+ }).subscribe({
+ next: resp => {
+ this.router.navigateByUrl("/");
+ }
+ })
+ }
}