All checks were successful
Java CI with Maven / build (push) Successful in 48s
Co-authored-by: Sebastian Böckelmann <uqpko@student.kit.edu> Reviewed-on: Sebastian/TimeManager#45
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
import {
|
|
BasicScheduleEntityInfo,
|
|
ScheduleInfo,
|
|
ScheduleService,
|
|
TaskOverviewInfo,
|
|
TaskScheduleStopResponse
|
|
} from "../../api";
|
|
import {ActiveScheduleComponent} 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";
|
|
|
|
@Component({
|
|
selector: 'app-dashboard',
|
|
templateUrl: './dashboard.component.html',
|
|
styleUrls: ['./dashboard.component.css']
|
|
})
|
|
export class DashboardComponent implements OnInit{
|
|
|
|
missedSchedules: boolean = true
|
|
schedules: ScheduleInfo[] = []
|
|
workedMinutesToday: number = 0
|
|
|
|
tasks: TaskOverviewInfo[] = []
|
|
selectedTaskgroupID: number | undefined
|
|
|
|
@ViewChild('activeSchedule') activeScheduleComponent: ActiveScheduleComponent | undefined
|
|
constructor(private scheduleService: ScheduleService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.scheduleService.schedulesDateStartableGet(String(Date.now()), true).subscribe({
|
|
next: resp => {
|
|
this.schedules = resp;
|
|
}
|
|
})
|
|
|
|
this.scheduleService.schedulesStatusTodayGet().subscribe({
|
|
next: resp => {
|
|
this.workedMinutesToday = resp.activeMinutes;
|
|
this.missedSchedules = resp.missedSchedules;
|
|
}
|
|
})
|
|
}
|
|
|
|
startSchedule(schedule: ScheduleInfo) {
|
|
this.scheduleService.schedulesScheduleIDActivatePost(schedule.scheduleID).subscribe({
|
|
next: resp => {
|
|
schedule.startTime = resp.startTime;
|
|
if(this.activeScheduleComponent != undefined) {
|
|
this.activeScheduleComponent.activateSchedule(schedule);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
stopedTask(stopActiveScheduleInfo: StopActiveScheduleInfo) {
|
|
this.workedMinutesToday += stopActiveScheduleInfo.workedMinutes;
|
|
this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== stopActiveScheduleInfo.schedule.scheduleID);
|
|
}
|
|
|
|
|
|
protected readonly TaskOverviewComponent = TaskOverviewComponent;
|
|
|
|
onSelectTaskgroup(taskOverviewData: TaskOverviewData) {
|
|
this.tasks = taskOverviewData.tasks;
|
|
this.selectedTaskgroupID = taskOverviewData.taskgroupID;
|
|
}
|
|
|
|
onStartTaskNow(schedule: ScheduleInfo) {
|
|
this.activeScheduleComponent?.activateSchedule(schedule)
|
|
}
|
|
|
|
onFinishTask(task: TaskOverviewInfo) {
|
|
this.activeScheduleComponent?.finishTaskByOverview(task);
|
|
|
|
this.schedules = this.schedules.filter(schedule => schedule.task.taskID !== task.taskID)
|
|
}
|
|
|
|
registerForgotten(taskScheduleStopResponse: TaskScheduleStopResponse) {
|
|
this.workedMinutesToday += taskScheduleStopResponse.workTime
|
|
}
|
|
}
|