File

src/app/tasks/task-executions/task-executions.component.ts

Description

Component that display the Task Executions.

Implements

OnInit OnDestroy

Example

Metadata

selector app-task-executions
styleUrls ../task-definitions/styles.scss
templateUrl ./task-executions.component.html

Index

Properties
Methods

Constructor

constructor(tasksService: TasksService, notificationService: NotificationService, authService: AuthService, loggerService: LoggerService, router: Router)

Constructor

Parameters :
Name Type Optional Description
tasksService TasksService
notificationService NotificationService
authService AuthService
loggerService LoggerService
router Router

Methods

applyAction
applyAction(action: string, item: TaskExecution)

Apply Action

Parameters :
Name Type Optional Description
action string
item TaskExecution
Returns : void
applySort
applySort(sort: SortParams)

Apply sort Triggered on column header click

Parameters :
Name Type Optional Description
sort SortParams
Returns : void
changePaginationPager
changePaginationPager(params: )

Change pagination / Pager

Parameters :
Name Type Optional Description
params
Returns : void
details
details(taskExecution: TaskExecution)

Route to TaskExecution details page.

Parameters :
Name Type Optional Description
taskExecution TaskExecution
Returns : void
detailsTask
detailsTask(taskDefinitionName: string)

Route to TaskDefinition details page.

Parameters :
Name Type Optional Description
taskDefinitionName string
Returns : void
executionActions
executionActions(item: TaskExecution, index: number)

Execution actions

Parameters :
Name Type Optional Description
item TaskExecution
index number
Returns : {}
getPage
getPage(page: number)

Used for requesting a new page. The past is page number is 1-index-based. It will be converted to a zero-index-based page number under the hood.

Parameters :
Name Type Optional Description
page number

1-index-based

Returns : void
launch
launch(taskDefinitionName: string)

Route to TaskDefinition launch page.

Parameters :
Name Type Optional Description
taskDefinitionName string
Returns : void
ngOnDestroy
ngOnDestroy()

Close subscription

Returns : void
ngOnInit
ngOnInit()

Retrieves the TaskDefinitions to be displayed on the page.

Returns : void
refresh
refresh()

Initializes the taskDefinitions attribute with the results from Spring Cloud Data Flow server.

Returns : void
updateContext
updateContext()

Write the context in the service.

Returns : void

Properties

context
context: any
Type : any

Storage context

Public loggerService
loggerService: LoggerService
Type : LoggerService
Private ngUnsubscribe$
ngUnsubscribe$: Subject<any>
Type : Subject<any>

Unsubscribe

Public notificationService
notificationService: NotificationService
Type : NotificationService
params
params: TaskListParams
Type : TaskListParams

State of App List Params

taskExecutions
taskExecutions: Page<TaskExecution>
Type : Page<TaskExecution>

Current page of Tasks definitions

Public tasksService
tasksService: TasksService
Type : TasksService
tasksTabulation
tasksTabulation: TasksTabulationComponent
Type : TasksTabulationComponent
Decorators : ViewChild

Tabulation

import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { Page } from '../../shared/model/page';
import { TaskExecution } from '../model/task-execution';
import { TasksService } from '../tasks.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { TaskListParams } from '../components/tasks.interface';
import { OrderParams, SortParams } from '../../shared/components/shared.interface';
import { NotificationService } from '../../shared/services/notification.service';
import { LoggerService } from '../../shared/services/logger.service';
import { AppError } from '../../shared/model/error.model';
import { AuthService } from '../../auth/auth.service';
import { TaskDefinition } from '../model/task-definition';
import { TasksTabulationComponent } from '../components/tasks-tabulation/tasks-tabulation.component';

/**
 * Component that display the Task Executions.
 *
 * @author Janne Valkealahti
 * @author Gunnar Hillert
 * @author Damien Vitrac
 */
@Component({
  selector: 'app-task-executions',
  templateUrl: './task-executions.component.html',
  styleUrls: ['./../task-definitions/styles.scss']
})
export class TaskExecutionsComponent implements OnInit, OnDestroy {

  /**
   * Current page of Tasks definitions
   */
  taskExecutions: Page<TaskExecution>;

  /**
   * Unsubscribe
   */
  private ngUnsubscribe$: Subject<any> = new Subject();

  /**
   * Tabulation
   */
  @ViewChild('tasksTabulation', { static: false })
  tasksTabulation: TasksTabulationComponent;

  /**
   * State of App List Params
   */
  params: TaskListParams = {
    sort: 'TASK_EXECUTION_ID',
    order: OrderParams.ASC,
    page: 0,
    size: 30,
    q: ''
  };

  /**
   * Storage context
   */
  context: any;

  /**
   * Constructor
   *
   * @param {TasksService} tasksService
   * @param {NotificationService} notificationService
   * @param {AuthService} authService
   * @param {LoggerService} loggerService
   * @param {Router} router
   */
  constructor(public tasksService: TasksService,
              public notificationService: NotificationService,
              private authService: AuthService,
              public loggerService: LoggerService,
              private router: Router) {
  }

  /**
   * Retrieves the {@link TaskDefinition}s to be displayed on the page.
   */
  ngOnInit() {
    this.context = this.tasksService.executionsContext;
    this.params = { ...this.context };
    this.refresh();
  }


  /**
   * Execution actions
   * @param {TaskExecution} item
   * @param {number} index
   */
  executionActions(item: TaskExecution, index: number) {
    return [
      {
        id: 'details-execution' + index,
        icon: 'info-circle',
        action: 'details',
        title: 'Show details',
        isDefault: true
      },
      {
        divider: true
      },
      {
        id: 'details-task' + index,
        icon: 'info-circle',
        action: 'detailstask',
        title: 'Show task details',
        isDefault: false
      },
      {
        id: 'launch-task' + index,
        icon: 'play',
        action: 'launch',
        title: 'Relaunch task',
        isDefault: false,
        hidden: !this.authService.securityInfo.canAccess(['ROLE_DEPLOY'])
      },
    ];
  }

  /**
   * Apply Action
   * @param action
   * @param item
   */
  applyAction(action: string, item: TaskExecution) {
    switch (action) {
      case 'details':
        this.details(item);
        break;
      case 'detailstask':
        this.detailsTask(item.taskName);
        break;
      case 'launch':
        this.launch(item.taskName);
        break;
    }
  }

  /**
   * Close subscription
   */
  ngOnDestroy() {
    this.ngUnsubscribe$.next();
    this.ngUnsubscribe$.complete();
  }

  /**
   * Initializes the taskDefinitions attribute with the results from Spring Cloud Data Flow server.
   */
  refresh() {
    this.tasksService
      .getExecutions(this.params)
      .pipe(takeUntil(this.ngUnsubscribe$))
      .subscribe((page: Page<TaskExecution>) => {
          if (page.items.length === 0 && this.params.page > 0) {
            this.params.page = 0;
            this.refresh();
            return;
          }
          this.taskExecutions = page;
          this.updateContext();
        },
        error => {
          this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
        }
      );

    if (this.tasksTabulation) {
      this.tasksTabulation.forceRefresh();
    }
  }

  /**
   * Write the context in the service.
   */
  updateContext() {
    this.context.q = this.params.q;
    this.context.sort = this.params.sort;
    this.context.order = this.params.order;
    this.context.page = this.params.page;
    this.context.size = this.params.size;
  }

  /**
   * Apply sort
   * Triggered on column header click
   *
   * @param {SortParams} sort
   */
  applySort(sort: SortParams) {
    this.params.sort = sort.sort;
    this.params.order = sort.order;
    this.refresh();
  }

  /**
   * Used for requesting a new page. The past is page number is
   * 1-index-based. It will be converted to a zero-index-based
   * page number under the hood.
   *
   * @param page 1-index-based
   */
  getPage(page: number) {
    this.loggerService.log(`Getting page ${page}.`);
    this.params.page = page - 1;
    this.refresh();
  }

  /**
   * Change pagination / Pager
   * @param params
   */
  changePaginationPager(params) {
    this.params.page = params.page;
    this.params.size = params.size;
    this.updateContext();
    this.refresh();
  }

  /**
   * Route to {@link TaskExecution} details page.
   * @param {TaskExecution} taskExecution
   */
  details(taskExecution: TaskExecution) {
    this.router.navigate([`tasks/executions/${taskExecution.executionId}`]);
  }

  /**
   * Route to {@link TaskDefinition} details page.
   * @param {taskDefinitionName} taskDefinitionName
   */
  detailsTask(taskDefinitionName: string) {
    this.router.navigate([`tasks/definitions/${taskDefinitionName}`]);
  }

  /**
   * Route to {@link TaskDefinition} launch page.
   * @param {taskDefinitionName} taskDefinitionName
   */
  launch(taskDefinitionName: string) {
    this.router.navigate([`tasks/definitions/launch/${taskDefinitionName}`]);
  }


}
<app-tasks-tabulation id="executions-list" *ngIf="taskExecutions" #tasksTabulation>

  <div dataflowLayoutType type="full">
    <div class="list-bar" *ngIf="!(taskExecutions?.totalPages < 2 && taskExecutions.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 *ngIf="taskExecutions?.items && taskExecutions.items.length > 0"
           class="table table-hover table-actions" id="taskExecutionsTable">
      <thead>
      <tr>
        <th style="width: 140px">
          <app-sort id="sort-id" (change)="applySort($event)" [value]="'TASK_EXECUTION_ID'" [sort]="params">
            Execution Id
          </app-sort>
        <th>
          <app-sort id="sort-task" (change)="applySort($event)" [value]="'TASK_NAME'" [sort]="params">
            Task Name
          </app-sort>
        </th>
        <th nowrap="">
          <app-sort id="sort-startdate" (change)="applySort($event)" [value]="'START_TIME'" [sort]="params">
            Start Date
          </app-sort>
        </th>
        <th nowrap="">
          <app-sort id="sort-enddate" (change)="applySort($event)" [value]="'END_TIME'" [sort]="params">
            End Date
          </app-sort>
        </th>
        <th nowrap="">
          <app-sort id="sort-exitcode" (change)="applySort($event)" [value]="'EXIT_CODE'" [sort]="params">
            Exit Code
          </app-sort>
        </th>
        <th>&nbsp;</th>
      </tr>
      </thead>
      <tbody>
      <ng-container
        *ngFor="let item of taskExecutions.items | paginate: taskExecutions.getPaginationInstance(); index as i">
        <tr>
          <td>
            <a (click)="details(item)" style="cursor:pointer;">#{{ item.executionId }}</a>
          </td>
          <td>
            <a [routerLink]="'/tasks/definitions/' + item.taskName">{{ item.taskName }}</a>
          </td>
          <td>
            {{ item.startTime | dataflowDateTime }}
          </td>
          <td>
            {{ item.endTime | dataflowDateTime }}
          </td>
          <td>
            {{ item.exitCode }}
          </td>
          <td class="table-actions" width="10px" nowrap="">
            <app-list-row-actions [item]="item" (action)="applyAction($event.action, $event.args)"
                                  [actions]="executionActions(item, i)"></app-list-row-actions>
          </td>
        </tr>
      </ng-container>
      </tbody>
    </table>

    <app-list-pagination [page]="taskExecutions" [params]="params" (changed)="changePaginationPager($event)"
                         [item]="'task execution'" [items]="'task executions'">
    </app-list-pagination>

    <app-list-empty [page]="taskExecutions" [filters]="[]">
      <p>There is <strong>no task executed</strong>, yet.</p>
      <p>
        You can <a (click)="refresh()">Refresh</a> the page
      </p>
    </app-list-empty>
  </div>
</app-tasks-tabulation>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""