src/app/tasks/task-execution/task-execution.component.ts
Component that display a Task Execution.
selector | app-task-execution |
styleUrls | ../task-definitions/styles.scss |
templateUrl | ./task-execution.component.html |
Properties |
Methods |
constructor(tasksService: TasksService, routingStateService: RoutingStateService, notificationService: NotificationService, router: Router, route: ActivatedRoute)
|
||||||||||||||||||||||||
Constructor
Parameters :
|
cancel |
cancel()
|
Back action Navigate to the previous URL or /tasks/executions
Returns :
void
|
detailsTask | ||||||||
detailsTask(taskDefinitionName: string)
|
||||||||
Route to TaskDefinition details page.
Parameters :
Returns :
void
|
getArguments | ||||||||
getArguments(args: Array
|
||||||||
Prepare args (split line into array)
Parameters :
Returns :
Array<any>
|
launch | ||||||||
launch(taskDefinitionName: string)
|
||||||||
Route to TaskDefinition launch page.
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Initialize component
Returns :
void
|
taskExecution$ |
taskExecution$:
|
Type : Observable<TaskExecution>
|
Observable of Task Execution |
import { Component, OnInit } from '@angular/core';
import { TaskExecution } from '../model/task-execution';
import { ActivatedRoute, Router } from '@angular/router';
import { TasksService } from '../tasks.service';
import { catchError, mergeMap } from 'rxjs/operators';
import { Observable, EMPTY } from 'rxjs';
import { RoutingStateService } from '../../shared/services/routing-state.service';
import { NotificationService } from '../../shared/services/notification.service';
import { AppError, HttpAppError } from '../../shared/model/error.model';
/**
* Component that display a Task Execution.
*
* @author Vitrac Damien
*/
@Component({
selector: 'app-task-execution',
templateUrl: './task-execution.component.html',
styleUrls: ['./../task-definitions/styles.scss']
})
export class TaskExecutionComponent implements OnInit {
/**
* Observable of Task Execution
*/
taskExecution$: Observable<TaskExecution>;
/**
* Constructor
*
* @param {TasksService} tasksService
* @param {RoutingStateService} routingStateService
* @param {NotificationService} notificationService
* @param {Router} router
* @param {ActivatedRoute} route
* @param {TasksService} tasksService
*/
constructor(private tasksService: TasksService,
private routingStateService: RoutingStateService,
private notificationService: NotificationService,
private router: Router,
private route: ActivatedRoute) {
}
/**
* Initialize component
*/
ngOnInit() {
this.taskExecution$ = this.route.params
.pipe(
mergeMap(
(val) => this.tasksService.getExecution(val.id)
),
catchError(error => {
if (HttpAppError.is404(error) || HttpAppError.is400(error)) {
this.cancel();
}
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
return EMPTY;
})
);
}
/**
* Back action
* Navigate to the previous URL or /tasks/executions
*/
cancel() {
this.routingStateService.back('/tasks/executions', /^(\/tasks\/executions\/)/);
}
/**
* Prepare args (split line into array)
* @param {Array<any>} args
* @returns {Array<any>}
*/
getArguments(args: Array<any>): Array<any> {
return args.map((arg) => arg.split('='));
}
/**
* Route to {@link TaskDefinition} launch page.
* @param {taskDefinitionName} taskDefinitionName
*/
launch(taskDefinitionName: string) {
this.router.navigate([`tasks/definitions/launch/${taskDefinitionName}`]);
}
/**
* Route to {@link TaskDefinition} details page.
* @param {taskDefinitionName} taskDefinitionName
*/
detailsTask(taskDefinitionName: string) {
this.router.navigate([`tasks/definitions/${taskDefinitionName}`]);
}
}
<app-page *ngIf="taskExecution$ | async as taskExecution; else loading">
<app-page-head>
<app-page-head-back [defaultUrl]="'/tasks/executions'"
[isNotRegex]="'^(\/tasks\/executions\/)'"></app-page-head-back>
<app-page-head-title>
Task Execution Details - <strong>Execution ID: {{ taskExecution.executionId }}</strong>
</app-page-head-title>
<app-page-head-actions>
<button name="task-view" type="button" id="task-view"
(click)="detailsTask(taskExecution.taskName)" class="btn btn-primary btn-fa" title="View details task">
<span class="fa fa-info-circle"></span>
View task details
</button>
<button name="task-launch" type="button" id="task-launch"
(click)="launch(taskExecution.taskName)" class="btn btn-primary btn-fa" title="Relaunch the task"
[dataflowAppRoles]="['ROLE_CREATE']">
<span class="fa fa-play"></span>
Relaunch task
</button>
</app-page-head-actions>
</app-page-head>
<div dataflowLayoutType type="large">
<table *ngIf="taskExecution" class="table table-hover">
<thead>
<tr>
<th style="width: 200px">Property</th>
<th style="width: 200px">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Execution Id</td>
<td>{{ taskExecution.executionId }}</td>
</tr>
<tr>
<td>Task Name</td>
<td>
<a [routerLink]="'/tasks/definitions/' + taskExecution.taskName">{{ taskExecution.taskName }}</a>
</td>
</tr>
<tr>
<td>Arguments</td>
<td>
<div *ngIf="taskExecution.arguments">
<div *ngFor="let arg of getArguments(taskExecution.arguments)">
{{ arg[0] }}:
<strong>{{ arg[1] }}</strong>
</div>
</div>
<div *ngIf="!taskExecution.arguments">
N/A
</div>
</td>
</tr>
<tr>
<td>External Execution Id</td>
<td>{{ taskExecution.externalExecutionId || 'N/A' }}</td>
</tr>
<tr>
<td>Batch Job</td>
<td>
<span *ngIf="taskExecution.jobExecutionIds.length > 0" class="glyphicon glyphicon-ok text-info"></span>
<span *ngIf="taskExecution.jobExecutionIds.length == 0" class="glyphicon glyphicon-remove text-danger"></span>
</td>
</tr>
<tr>
<td>Job Execution Ids</td>
<td *ngIf="taskExecution.jobExecutionIds.length > 0" id="jobExecutionIds">
<a [routerLink]="'/jobs/executions/' + jobExecutionId"
*ngFor="let jobExecutionId of taskExecution.jobExecutionIds">
{{ jobExecutionId }}
</a>
</td>
<td *ngIf="taskExecution.jobExecutionIds.length == 0">
N/A
</td>
</tr>
<tr>
<td>Start Time</td>
<td>{{ taskExecution.startTime | dataflowDateTime }}</td>
</tr>
<tr>
<td>End Time</td>
<td>{{ taskExecution.endTime | dataflowDateTime }}</td>
</tr>
<tr>
<td>Duration</td>
<td>{{ taskExecution.startTime | dataflowDuration: taskExecution.endTime }}</td>
</tr>
<tr>
<td>Exit Code</td>
<td>{{ taskExecution.exitCode }}</td>
</tr>
<tr>
<td>Exit Message</td>
<td>{{ taskExecution.exitMessage || 'N/A' }}</td>
</tr>
</tbody>
</table>
</div>
</app-page>
<ng-template #loading>
<app-loader></app-loader>
</ng-template>