import {Component, OnInit} from '@angular/core'; import {HistoryService, ScheduleInfo, TaskgroupEntityInfo} from "../../../api"; import * as moment from "moment"; import {NavigationLink} from "../../navigation-link-list/navigation-link-list.component"; @Component({ selector: 'app-schedule-history', templateUrl: './schedule-history.component.html', styleUrls: ['./schedule-history.component.css'] }) export class ScheduleHistoryComponent implements OnInit{ defaultNavigationLinkPath: NavigationLink[] = [ { linkText: 'Dashboard', routerLink: ['/'] }, { linkText: 'Statistics', routerLink: [] }, { linkText: 'Taskgroup Activity', routerLink: ['/statistics/taskgroup-activity'] } ]; selectedDate: Date = new Date(); schedules: ScheduleInfo[] = [] displayedColumns: string[] = ['taskgroup', 'task', 'start', 'end', 'duration']; ngOnInit() { this.historyService.historySchedulesDateGet(moment(this.selectedDate).format("YYYY-MM-DD")).subscribe({ next: resp => { this.schedules = resp; } }) } constructor(private historyService: HistoryService) { } computeTaskgroupPath(taskgroupPath: TaskgroupEntityInfo[]) { let result = ""; taskgroupPath.forEach(taskgroup => { result += taskgroup.taskgroupName + "/"; }) return result; } formatDate(date: string) { return moment(date).format('dd, DD. MMM YYYY'); } calcDuration(startDate: string, endDate: string) { const start = moment(new Date(startDate)); const end = moment(new Date(endDate)); const duration = moment.duration(end.diff(start)); return duration.asMinutes() + " Minutes"; } }