42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
import {BasicScheduleEntityInfo, ScheduleInfo, ScheduleService, TaskOverviewInfo} from "../../../api";
|
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
|
|
|
@Component({
|
|
selector: 'app-task-overview',
|
|
templateUrl: './task-overview.component.html',
|
|
styleUrls: ['./task-overview.component.css']
|
|
})
|
|
export class TaskOverviewComponent {
|
|
|
|
@Input() tasks: TaskOverviewInfo[] = []
|
|
@Output('onStartNow') startNowEmitter: EventEmitter<ScheduleInfo> = new EventEmitter<ScheduleInfo>();
|
|
|
|
constructor(private scheduleService: ScheduleService,
|
|
private snackbar: MatSnackBar) {
|
|
|
|
}
|
|
startTaskNow(task: TaskOverviewInfo) {
|
|
this.scheduleService.schedulesTaskIDNowPost(task.taskID).subscribe({
|
|
next: resp => {
|
|
this.startNowEmitter.emit(resp);
|
|
},
|
|
error: err => {
|
|
if(err.status == 403) {
|
|
this.snackbar.open("No permission", "", {duration: 2000});
|
|
} else if(err.status == 404) {
|
|
this.snackbar.open("Task not found", "", {duration: 2000});
|
|
} else if(err.status == 409) {
|
|
this.snackbar.open("Task is already running", "", {duration: 2000});
|
|
} else {
|
|
this.snackbar.open("Unexpected error", "", {duration: 2000});
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
finishTask(task: TaskOverviewInfo) {
|
|
|
|
}
|
|
}
|