46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
import {ScheduleInfo, ScheduleService} from "../../api";
|
|
import {ActiveScheduleComponent} from "./active-schedule/active-schedule.component";
|
|
import {StopActiveScheduleInfo} from "./active-schedule/StopActiveScheduleInfo";
|
|
|
|
@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
|
|
|
|
@ViewChild('activeSchedule') activeScheduleComponent: ActiveScheduleComponent | undefined
|
|
constructor(private scheduleService: ScheduleService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.scheduleService.schedulesTodayActivateableGet(true).subscribe({
|
|
next: resp => {
|
|
this.schedules = resp;
|
|
}
|
|
})
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|