issue-57 #71
@ -5,6 +5,12 @@ import {TaskOverviewComponent} from "../task-overview/task-overview.component";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {ForgottenTaskStartDialogComponent} from "../forgotten-task-start-dialog/forgotten-task-start-dialog.component";
|
||||
|
||||
export interface StopActiveScheduleEmitterInfo {
|
||||
stopactiveScheduleResponse: StopActiveScheduleInfo,
|
||||
finish: boolean,
|
||||
taskID: number
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-active-schedule',
|
||||
templateUrl: './active-schedule.component.html',
|
||||
@ -17,7 +23,7 @@ export class ActiveScheduleComponent implements OnInit{
|
||||
currentTime: number = 0;
|
||||
displayTime: string = "00:00:00"
|
||||
|
||||
@Output('onStopTask') scheduleStopEmitter = new EventEmitter<StopActiveScheduleInfo>;
|
||||
@Output('onStopTask') scheduleStopEmitter = new EventEmitter<StopActiveScheduleEmitterInfo>;
|
||||
@Output('registerForgotten') registerForgottenEmitter = new EventEmitter<TaskScheduleStopResponse>
|
||||
|
||||
constructor(private scheduleService: ScheduleService,
|
||||
@ -60,8 +66,12 @@ export class ActiveScheduleComponent implements OnInit{
|
||||
this.scheduleService.schedulesScheduleIDStopFinishPost(this.activeSchedule!.scheduleID, finish).subscribe({
|
||||
next: resp => {
|
||||
this.scheduleStopEmitter.emit({
|
||||
stopactiveScheduleResponse: {
|
||||
schedule: this.activeSchedule!,
|
||||
workedMinutes: resp.workTime
|
||||
},
|
||||
finish: finish,
|
||||
taskID: this.activeSchedule!.task.taskID
|
||||
})
|
||||
console.log(resp.workTime)
|
||||
this.activeSchedule = undefined
|
||||
|
@ -39,12 +39,12 @@
|
||||
|
||||
</div>
|
||||
<div class="taskgroup-overview">
|
||||
<app-task-overview [tasks]="tasks" (onStartNow)="onStartTaskNow($event)" [taskgroupID]="selectedTaskgroupID" (onFinished)="onFinishTask($event)"></app-task-overview>
|
||||
<app-task-overview [tasks]="tasks" (onStartNow)="onStartTaskNow($event)" [taskgroupID]="selectedTaskgroupID" (onFinished)="onFinishTask($event)" (onCreated)="onCreatedTask($event)"></app-task-overview>
|
||||
</div>
|
||||
|
||||
<div class="taskgroup-overview">
|
||||
|
||||
<app-taskgroup-overview (taskgroupSelected)="onSelectTaskgroup($event)"></app-taskgroup-overview>
|
||||
<app-taskgroup-overview #taskgroupOverview (taskgroupSelected)="onSelectTaskgroup($event)"></app-taskgroup-overview>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@ import {
|
||||
TaskOverviewInfo,
|
||||
TaskScheduleStopResponse
|
||||
} from "../../api";
|
||||
import {ActiveScheduleComponent} from "./active-schedule/active-schedule.component";
|
||||
import {ActiveScheduleComponent, StopActiveScheduleEmitterInfo} from "./active-schedule/active-schedule.component";
|
||||
import {StopActiveScheduleInfo} from "./active-schedule/StopActiveScheduleInfo";
|
||||
import {TaskOverviewComponent} from "./task-overview/task-overview.component";
|
||||
import {TaskOverviewData} from "./taskgroup-overview/taskgroup-overview.component";
|
||||
import {TaskCreationEmitterInfo, TaskOverviewComponent} from "./task-overview/task-overview.component";
|
||||
import {TaskgroupOverviewComponent, TaskOverviewData} from "./taskgroup-overview/taskgroup-overview.component";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -26,6 +26,7 @@ export class DashboardComponent implements OnInit{
|
||||
selectedTaskgroupID: number | undefined
|
||||
|
||||
@ViewChild('activeSchedule') activeScheduleComponent: ActiveScheduleComponent | undefined
|
||||
@ViewChild('taskgroupOverview') taskroupOverviewComponent: TaskgroupOverviewComponent | undefined
|
||||
constructor(private scheduleService: ScheduleService,
|
||||
private historyService: HistoryService) {
|
||||
}
|
||||
@ -59,9 +60,13 @@ export class DashboardComponent implements OnInit{
|
||||
}
|
||||
|
||||
|
||||
stopedTask(stopActiveScheduleInfo: StopActiveScheduleInfo) {
|
||||
this.workedMinutesToday += stopActiveScheduleInfo.workedMinutes;
|
||||
this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== stopActiveScheduleInfo.schedule.scheduleID);
|
||||
stopedTask(stopActiveScheduleInfo: StopActiveScheduleEmitterInfo) {
|
||||
this.workedMinutesToday += stopActiveScheduleInfo.stopactiveScheduleResponse.workedMinutes;
|
||||
this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== stopActiveScheduleInfo.stopactiveScheduleResponse.schedule.scheduleID);
|
||||
|
||||
if(stopActiveScheduleInfo.finish) {
|
||||
this.taskroupOverviewComponent!.finishTask(stopActiveScheduleInfo.taskID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,16 +78,24 @@ export class DashboardComponent implements OnInit{
|
||||
}
|
||||
|
||||
onStartTaskNow(schedule: ScheduleInfo) {
|
||||
this.activeScheduleComponent?.activateSchedule(schedule)
|
||||
this.activeScheduleComponent?.activateSchedule(schedule);
|
||||
this.selectedTaskgroupID = undefined
|
||||
}
|
||||
|
||||
onFinishTask(task: TaskOverviewInfo) {
|
||||
this.activeScheduleComponent?.finishTaskByOverview(task);
|
||||
|
||||
this.schedules = this.schedules.filter(schedule => schedule.task.taskID !== task.taskID)
|
||||
this.taskroupOverviewComponent!.finishTask(task.taskID);
|
||||
this.tasks = [];
|
||||
this.selectedTaskgroupID = undefined;
|
||||
}
|
||||
|
||||
registerForgotten(taskScheduleStopResponse: TaskScheduleStopResponse) {
|
||||
this.workedMinutesToday += taskScheduleStopResponse.workTime
|
||||
}
|
||||
|
||||
onCreatedTask(taskCreationInfo: TaskCreationEmitterInfo) {
|
||||
this.taskroupOverviewComponent!.onCreateTask(taskCreationInfo);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<button mat-raised-button class="greenBtn long-btn" *ngIf="taskgroupID != undefined" (click)="openTaskCreation()">Add</button>
|
||||
<div *ngIf="taskgroupID != undefined" >
|
||||
<button mat-raised-button class="greenBtn long-btn"(click)="openTaskCreation()">Add</button>
|
||||
<mat-card *ngFor="let task of tasks">
|
||||
<mat-card-content>
|
||||
<h3><a class="task-link" [routerLink]="['/taskgroups', taskgroupID!, 'tasks', task.taskID]">{{task.taskName}}</a></h3>
|
||||
@ -12,3 +13,5 @@
|
||||
<button mat-raised-button class="greenBtn btn-without-radius" (click)="finishTask(task)">Finish</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
|
@ -1,10 +1,21 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {BasicScheduleEntityInfo, ScheduleInfo, ScheduleService, TaskOverviewInfo, TaskService} from "../../../api";
|
||||
import {
|
||||
BasicScheduleEntityInfo,
|
||||
ScheduleInfo,
|
||||
ScheduleService,
|
||||
TaskOverviewInfo,
|
||||
TaskService,
|
||||
TaskShortInfo
|
||||
} from "../../../api";
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
import {TaskEditorData} from "../../tasks/task-editor/TaskEditorData";
|
||||
import {TaskEditorComponent} from "../../tasks/task-editor/task-editor.component";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
|
||||
export interface TaskCreationEmitterInfo {
|
||||
taskgroupID: number,
|
||||
task: TaskOverviewInfo
|
||||
}
|
||||
@Component({
|
||||
selector: 'app-task-overview',
|
||||
templateUrl: './task-overview.component.html',
|
||||
@ -16,6 +27,7 @@ export class TaskOverviewComponent {
|
||||
@Input() taskgroupID: number | undefined
|
||||
@Output('onStartNow') startNowEmitter: EventEmitter<ScheduleInfo> = new EventEmitter<ScheduleInfo>();
|
||||
@Output('onFinished') finishedEmitter: EventEmitter<TaskOverviewInfo> = new EventEmitter<TaskOverviewInfo>();
|
||||
@Output('onCreated') creationEmitter: EventEmitter<TaskCreationEmitterInfo> = new EventEmitter<TaskCreationEmitterInfo>();
|
||||
|
||||
constructor(private scheduleService: ScheduleService,
|
||||
private snackbar: MatSnackBar,
|
||||
@ -68,14 +80,19 @@ export class TaskOverviewComponent {
|
||||
const dialogRef = this.dialog.open(TaskEditorComponent, {data: editorData, width: "600px"})
|
||||
dialogRef.afterClosed().subscribe(res => {
|
||||
if(res != undefined) {
|
||||
this.tasks.push({
|
||||
const taskOverviewInfo = {
|
||||
taskID: res.taskID,
|
||||
eta: res.eta,
|
||||
limit: res.deadline,
|
||||
taskName: res.taskName,
|
||||
activeTime: 0,
|
||||
overdue: res.overdue
|
||||
}
|
||||
this.creationEmitter.emit({
|
||||
task: taskOverviewInfo,
|
||||
taskgroupID: this.taskgroupID!
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ import {MatIconModule} from "@angular/material/icon";
|
||||
import {MatButtonModule} from "@angular/material/button";
|
||||
import {MatTreeFlatDataSource, MatTreeFlattener, MatTreeModule} from "@angular/material/tree";
|
||||
import {FlatTreeControl} from "@angular/cdk/tree";
|
||||
import {RecursiveTaskgroupInfo, TaskgroupService, TaskOverviewInfo} from "../../../api";
|
||||
import {TaskOverviewComponent} from "../task-overview/task-overview.component";
|
||||
|
||||
|
||||
import {RecursiveTaskgroupInfo, TaskgroupService, TaskOverviewInfo, TaskShortInfo} from "../../../api";
|
||||
import {TaskCreationEmitterInfo, TaskOverviewComponent} from "../task-overview/task-overview.component";
|
||||
|
||||
|
||||
/** Flat node with expandable and level information */
|
||||
@ -24,6 +22,7 @@ export interface TaskOverviewData {
|
||||
tasks: TaskOverviewInfo[],
|
||||
taskgroupID: number
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-taskgroup-overview',
|
||||
templateUrl: './taskgroup-overview.component.html',
|
||||
@ -78,4 +77,39 @@ export class TaskgroupOverviewComponent {
|
||||
taskgroupID: taskgroupID
|
||||
})
|
||||
}
|
||||
|
||||
finishTask(taskID: number) {
|
||||
let taskgroupQueue : RecursiveTaskgroupInfo[] = this.dataSource.data.slice();
|
||||
while(taskgroupQueue.length > 0) {
|
||||
const currentTaskgroup = taskgroupQueue.pop()!;
|
||||
const searchedTask = currentTaskgroup.activeTasks.find(searchedTask => searchedTask.taskID === taskID);
|
||||
if(searchedTask == undefined) {
|
||||
currentTaskgroup.childTaskgroups.forEach(childTask => {
|
||||
taskgroupQueue.push(childTask);
|
||||
})
|
||||
} else {
|
||||
currentTaskgroup.activeTasks = currentTaskgroup.activeTasks.filter(taskFilter => taskFilter.taskID !== searchedTask.taskID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private findTaskgroup(taskgroupID: number) {
|
||||
let taskgroupQueue : RecursiveTaskgroupInfo[] = this.dataSource.data.slice();
|
||||
while(taskgroupQueue.length > 0) {
|
||||
const currentTaskgroup = taskgroupQueue.pop()!;
|
||||
if(currentTaskgroup.taskgroupID === taskgroupID) {
|
||||
return currentTaskgroup;
|
||||
} else {
|
||||
currentTaskgroup.childTaskgroups.forEach(childgroup => taskgroupQueue.push(childgroup));
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
onCreateTask(taskCreationInfo: TaskCreationEmitterInfo) {
|
||||
const taskgroup: RecursiveTaskgroupInfo | undefined = this.findTaskgroup(taskCreationInfo.taskgroupID);
|
||||
if(taskgroup != undefined) {
|
||||
taskgroup.activeTasks.push(taskCreationInfo.task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user