72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
import {BasicScheduleEntityInfo, ScheduleInfo, ScheduleService, TaskOverviewInfo} from "../../api";
|
|
import {ActiveScheduleComponent} from "./active-schedule/active-schedule.component";
|
|
import {StopActiveScheduleInfo} from "./active-schedule/StopActiveScheduleInfo";
|
|
import {TaskOverviewComponent} from "./task-overview/task-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[] = []
|
|
|
|
@ViewChild('activeSchedule') activeScheduleComponent: ActiveScheduleComponent | undefined
|
|
constructor(private scheduleService: ScheduleService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.scheduleService.schedulesTodayActivateableGet(true).subscribe({
|
|
next: resp => {
|
|
this.schedules = resp;
|
|
}
|
|
})
|
|
|
|
this.scheduleService.schedulesWorkedMinutesTodayGet().subscribe({
|
|
next: resp => {
|
|
this.workedMinutesToday = resp.activeMinutes;
|
|
}
|
|
})
|
|
}
|
|
|
|
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(tasks: TaskOverviewInfo[]) {
|
|
this.tasks = tasks;
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|