src/app/jobs/jobs/jobs.component.ts
Main entry point to the Jobs Module. Provides a paginated list of JobExecutions and also provides operations to stop/restart JobExecutions
templateUrl | ./jobs.component.html |
Properties |
|
Methods |
constructor(jobsService: JobsService, notificationService: NotificationService, confirmService: ConfirmService, authService: AuthService, loggerService: LoggerService, router: Router)
|
||||||||||||||||||||||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:51
|
||||||||||||||||||||||||||||
Constructor
Parameters :
|
applyAction | ||||||||||||
applyAction(action: string, item: JobExecution)
|
||||||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:126
|
||||||||||||
Apply Action
Parameters :
Returns :
void
|
changePaginationPager | ||||||||
changePaginationPager(params: )
|
||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:171
|
||||||||
Update event from the Paginator Pager
Parameters :
Returns :
void
|
jobActions | ||||||||||||
jobActions(item: JobExecution, index: number)
|
||||||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:95
|
||||||||||||
Job Actions
Parameters :
Returns :
{}
|
Public loadJobExecutions |
loadJobExecutions()
|
Defined in src/app/jobs/jobs/jobs.component.ts:143
|
Load a paginated list of JobExecutions.
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Defined in src/app/jobs/jobs/jobs.component.ts:84
|
Will cleanup any {@link Subscription}s to prevent memory leaks.
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in src/app/jobs/jobs/jobs.component.ts:74
|
As soon as the page loads we retrieve a list of JobExecutions.
Returns :
void
|
refresh |
refresh()
|
Defined in src/app/jobs/jobs/jobs.component.ts:163
|
Refresh action
Returns :
void
|
restartJob | ||||||||
restartJob(item: JobExecution)
|
||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:192
|
||||||||
Restart a job
Parameters :
Returns :
void
|
stopJob | ||||||||
stopJob(item: JobExecution)
|
||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:212
|
||||||||
Stop a job
Parameters :
Returns :
void
|
updateContext |
updateContext()
|
Defined in src/app/jobs/jobs/jobs.component.ts:181
|
Write the context in the service.
Returns :
void
|
viewJob | ||||||||
viewJob(item: JobExecution)
|
||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:233
|
||||||||
Navigate to the job execution page
Parameters :
Returns :
void
|
viewTask | ||||||||
viewTask(item: JobExecution)
|
||||||||
Defined in src/app/jobs/jobs/jobs.component.ts:241
|
||||||||
Navigate to the task definition page
Parameters :
Returns :
void
|
context |
context:
|
Type : any
|
Defined in src/app/jobs/jobs/jobs.component.ts:51
|
Storage context |
Public jobExecutions |
jobExecutions:
|
Type : Page<JobExecution>
|
Defined in src/app/jobs/jobs/jobs.component.ts:35
|
Jobs |
Private ngUnsubscribe$ |
ngUnsubscribe$:
|
Type : Subject<any>
|
Defined in src/app/jobs/jobs/jobs.component.ts:30
|
Unsubscribe |
params |
params:
|
Type : ListParams
|
Defined in src/app/jobs/jobs/jobs.component.ts:41
|
State of Job List Params |
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Subscription, Subject } from 'rxjs';
import { Page } from '../../shared/model';
import { JobsService } from '../jobs.service';
import { JobExecution } from '../model/job-execution.model';
import { takeUntil } from 'rxjs/operators';
import { ListParams, OrderParams } from '../../shared/components/shared.interface';
import { ConfirmService } from '../../shared/components/confirm/confirm.service';
import { NotificationService } from '../../shared/services/notification.service';
import { LoggerService } from '../../shared/services/logger.service';
import { AuthService } from '../../auth/auth.service';
/**
* Main entry point to the Jobs Module. Provides
* a paginated list of {@link JobExecution}s and
* also provides operations to stop/restart {@link JobExecution}s
*
* @author Gunnar Hillert
* @author Damien Vitrac
*/
@Component({
templateUrl: './jobs.component.html',
})
export class JobsComponent implements OnInit, OnDestroy {
/**
* Unsubscribe
*/
private ngUnsubscribe$: Subject<any> = new Subject();
/**
* Jobs
*/
public jobExecutions: Page<JobExecution>;
/**
* State of Job List Params
* @type {SortParams}
*/
params: ListParams = {
sort: 'id',
order: OrderParams.ASC,
page: 0,
size: 30
};
/**
* Storage context
*/
context: any;
/**
* Constructor
*
* @param {JobsService} jobsService
* @param {NotificationService} notificationService
* @param {ConfirmService} confirmService
* @param {LoggerService} loggerService
* @param {Router} router
*/
constructor(private jobsService: JobsService,
private notificationService: NotificationService,
private confirmService: ConfirmService,
private authService: AuthService,
private loggerService: LoggerService,
private router: Router) {
}
/**
* As soon as the page loads we retrieve a list
* of {@link JobExecution}s.
*/
ngOnInit() {
this.context = this.jobsService.jobsContext;
this.params = { ...this.context };
this.loadJobExecutions();
}
/**
* Will cleanup any {@link Subscription}s to prevent
* memory leaks.
*/
ngOnDestroy() {
this.updateContext();
this.ngUnsubscribe$.next();
this.ngUnsubscribe$.complete();
}
/**
* Job Actions
* @param {JobExecution} item
* @param {number} index
*/
jobActions(item: JobExecution, index: number) {
return [
{
id: 'job-view' + index,
icon: 'info-circle',
action: 'view',
title: 'Show details',
isDefault: true
},
{
id: 'job-restart' + index,
icon: 'repeat',
action: 'restart',
title: 'Restart the job',
hidden: !this.authService.securityInfo.canAccess(['ROLE_DEPLOY'])
},
{
id: 'job-stop' + index,
icon: 'stop',
action: 'stop',
title: 'Stop the job',
disabled: !item.stoppable
}
];
}
/**
* Apply Action
* @param action
* @param item
*/
applyAction(action: string, item: JobExecution) {
switch (action) {
case 'view':
this.viewJob(item);
break;
case 'restart':
this.restartJob(item);
break;
case 'stop':
this.stopJob(item);
break;
}
}
/**
* Load a paginated list of {@link JobExecution}s.
*/
public loadJobExecutions() {
this.jobsService.getJobExecutions(this.params)
.pipe(takeUntil(this.ngUnsubscribe$))
.subscribe(page => {
if (page.items.length === 0 && this.params.page > 0) {
this.params.page = 0;
this.loadJobExecutions();
return;
}
this.jobExecutions = page;
// this.changeCheckboxes();
this.updateContext();
}, error => {
this.notificationService.error(error);
});
}
/**
* Refresh action
*/
refresh() {
this.loadJobExecutions();
}
/**
* Update event from the Paginator Pager
* @param params
*/
changePaginationPager(params) {
this.params.page = params.page;
this.params.size = params.size;
this.updateContext();
this.loadJobExecutions();
}
/**
* Write the context in the service.
*/
updateContext() {
this.context.sort = this.params.sort;
this.context.order = this.params.order;
this.context.page = this.params.page;
this.context.size = this.params.size;
}
/**
* Restart a job
* @param {JobExecution} item
*/
restartJob(item: JobExecution) {
const title = `Confirm restart the job execution`;
const description = `This action will restart the steps failed of the ` +
`<strong>job execution ${item.name} (${item.jobExecutionId})</strong>. Are you sure?`;
this.confirmService.open(title, description, { confirm: 'Restart' }).subscribe(() => {
this.loggerService.log('Restart Job ' + item.jobExecutionId);
this.jobsService.restartJob(item)
.pipe(takeUntil(this.ngUnsubscribe$))
.subscribe(data => {
this.notificationService.success('Successfully restarted job "' + item.name + '"');
}, error => {
this.notificationService.error(error);
});
});
}
/**
* Stop a job
* @param {JobExecution} item
*/
stopJob(item: JobExecution) {
const title = `Confirm stop job execution`;
const description = `This action will stop the ` +
`<strong>job execution ${item.name} (${item.jobExecutionId})</strong>. Are you sure?`;
this.confirmService.open(title, description, { confirm: 'Stop' }).subscribe(() => {
this.loggerService.log('Stop Job' + item.jobExecutionId);
this.jobsService.stopJob(item)
.pipe(takeUntil(this.ngUnsubscribe$))
.subscribe(data => {
this.notificationService.success('Successfully stopped job "' + item.name + '"');
}, error => {
this.notificationService.error(error);
}
);
});
}
/**
* Navigate to the job execution page
* @param {JobExecution} item
*/
viewJob(item: JobExecution) {
this.router.navigate(['jobs/executions/' + item.jobExecutionId]);
}
/**
* Navigate to the task definition page
* @param {JobExecution} item
*/
viewTask(item: JobExecution) {
this.router.navigate(['tasks/executions/' + item.taskExecutionId]);
}
}
<app-page *ngIf="jobExecutions">
<app-page-head>
<app-page-head-title><strong>Batch Job Executions</strong></app-page-head-title>
</app-page-head>
<div dataflowLayoutType type="full">
<p>
This section lists all available batch job executions and provides the control to restart a job execution (if
restartable).
</p>
<div class="list-bar" *ngIf="!(jobExecutions.totalPages < 2 && jobExecutions.items.length === 0)">
<button class="btn btn-default btn-fa" (click)="refresh()" title="Refresh" type="button">
<span class="fa fa-refresh"></span>
Refresh
</button>
</div>
<table id="tableJobs" *ngIf="jobExecutions?.items && jobExecutions.items.length > 0"
class="table table-hover table-actions">
<thead>
<tr>
<th style="width: 100px">Execution Id</th>
<th>Name</th>
<th style="width: 100px">Task Id</th>
<th style="width: 100px">Instance Id</th>
<th style="width: 200px">Job Start Time</th>
<th style="width: 150px" nowrap="">Step Execution Count</th>
<th style="width: 100px">Status</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of jobExecutions.items | paginate: jobExecutions.getPaginationInstance(); index as i">
<td>
{{ item.jobExecutionId }}
</td>
<td>
<a style="cursor: pointer" (click)="viewJob(item)">{{ item.name }}</a>
<app-definition-status [jobExecution]="item"></app-definition-status>
</td>
<td>
<a style="cursor: pointer" (click)="viewTask(item)">{{ item.taskExecutionId }}</a>
</td>
<td>{{ item.jobInstanceId }}</td>
<td>{{ item.startTimeFormatted }}</td>
<td>{{ item.stepExecutionCount }}</td>
<td>
<app-job-execution-status [status]="item.status"></app-job-execution-status>
</td>
<td class="table-actions" width="80px" nowrap="">
<app-list-row-actions [item]="item" (action)="applyAction($event.action, $event.args)"
[actions]="jobActions(item, i)"></app-list-row-actions>
</td>
</tr>
</tbody>
</table>
<app-list-pagination [page]="jobExecutions" [params]="params" (changed)="changePaginationPager($event)"
[item]="'job execution'" [items]="'job executions'">
</app-list-pagination>
<app-list-empty [page]="jobExecutions" [filters]="[]">
<p>There are <strong>no batch job executions</strong> currently available.</p>
<p>
You can <a (click)="refresh()">Refresh</a> the page.
</p>
</app-list-empty>
</div>
</app-page>