File

src/app/tasks/task-definitions-destroy/task-definitions-destroy.component.ts

Description

Component used to destroy task definitions.

Extends

Modal

Implements

OnDestroy

Example

Metadata

selector app-task-definitions-destroy
templateUrl ./task-definitions-destroy.component.html

Index

Properties
Methods

Constructor

constructor(modalRef: BsModalRef, tasksService: TasksService, loggerService: LoggerService, blockerService: BlockerService, notificationService: NotificationService)

Initialize component

Parameters :
Name Type Optional Description
modalRef BsModalRef

used to control the current modal

tasksService TasksService
loggerService LoggerService
blockerService BlockerService
notificationService NotificationService

Methods

destroy
destroy()

Submit destroy task(s) Blocking action

Returns : void
ngOnDestroy
ngOnDestroy()

On Destroy operations

Returns : void
open
open(args: literal type)

Initialize

Parameters :
Name Type Optional Description
args literal type
Returns : Observable<any>

Properties

confirm
confirm: EventEmitter<string>
Type : EventEmitter<string>

Emit after undeploy success

Private ngUnsubscribe$
ngUnsubscribe$: Subject<any>
Type : Subject<any>

Unsubscribe

taskDefinitions
taskDefinitions: TaskDefinition[]
Type : TaskDefinition[]

Task Definitions

import { Component, EventEmitter, OnDestroy } from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap';
import { Modal } from '../../shared/components/modal/modal-abstract';
import { Observable, Subject } from 'rxjs';
import { finalize, takeUntil } from 'rxjs/operators';
import { TaskDefinition } from '../model/task-definition';
import { TasksService } from '../tasks.service';
import { NotificationService } from '../../shared/services/notification.service';
import { LoggerService } from '../../shared/services/logger.service';
import { BlockerService } from '../../shared/components/blocker/blocker.service';

/**
 * Component used to destroy task definitions.
 *
 * @author Damien Vitrac
 */
@Component({
  selector: 'app-task-definitions-destroy',
  templateUrl: './task-definitions-destroy.component.html'
})
export class TaskDefinitionsDestroyComponent extends Modal implements OnDestroy {

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

  /**
   * Task Definitions
   */
  taskDefinitions: TaskDefinition[];

  /**
   * Emit after undeploy success
   */
  confirm: EventEmitter<string> = new EventEmitter();

  /**
   * Initialize component
   *
   * @param {BsModalRef} modalRef used to control the current modal
   * @param {TasksService} tasksService
   * @param {BlockerService} blockerService
   * @param {NotificationService} notificationService
   * @param {LoggerService} loggerService
   */
  constructor(private modalRef: BsModalRef,
              private tasksService: TasksService,
              private loggerService: LoggerService,
              private blockerService: BlockerService,
              private notificationService: NotificationService) {
    super(modalRef);
  }

  /**
   * Initialize
   */
  open(args: { taskDefinitions: TaskDefinition[] }): Observable<any> {
    this.taskDefinitions = args.taskDefinitions;
    return this.confirm;
  }

  /**
   * Submit destroy task(s)
   * Blocking action
   */
  destroy() {
    this.loggerService.log(`Proceeding to destroy ${this.taskDefinitions.length} task definition(s).`, this.taskDefinitions);
    this.blockerService.lock();
    this.tasksService.destroyDefinitions(this.taskDefinitions)
      .pipe(takeUntil(this.ngUnsubscribe$), finalize(() => this.blockerService.unlock()))
      .subscribe((data) => {
        this.notificationService.success(`${data.length} task definition(s) destroyed.`);
        this.confirm.emit('done');
        this.cancel();
      }, () => {
        this.notificationService.error('An error occurred while bulk deleting Composed Tasks. ' +
          'Please check the server logs for more details.');
        this.confirm.emit('done');
        this.cancel();
      });
  }

  /**
   * On Destroy operations
   */
  ngOnDestroy() {
    this.ngUnsubscribe$.next();
    this.ngUnsubscribe$.complete();
  }

}
<div *ngIf="taskDefinitions">
  <div class="modal-header">
    <h4 class="modal-title pull-left">Confirm Destroy Task Definitions</h4>
    <button type="button" class="close pull-right" aria-label="Close" (click)="cancel()">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body" *ngIf="taskDefinitions.length == 1">
    <p>This action will destroy and delete the task <strong>{{ taskDefinitions[0].name }}</strong>.
      Are you sure?</p>
  </div>
  <div class="modal-body" *ngIf="taskDefinitions.length > 1">
    <p>
      This action will destroy the <strong>{{ taskDefinitions.length }} task definitions</strong> listed below.
      Are you sure?
    </p>
    <br/>
    <table id="table-tasks" class="table table-striped">
      <thead>
      <tr>
        <th>Name</th>
        <th>Definition</th>
      </tr>
      </thead>
      <tbody>
      <tr *ngFor="let item of taskDefinitions">
        <td>{{ item.name }}</td>
        <td>
          <app-stream-dsl>{{ item.dslText | truncate: 95 }}</app-stream-dsl>
        </td>
      </tr>
      </tbody>
    </table>
  </div>
  <div class="modal-footer" style="text-align:center">
    <button id="btn-cancel" type="button" class="btn btn-default" (click)="cancel()">No</button>
    <button id="btn-destroy" type="button" class="btn btn-primary" (click)="destroy(taskDefinitions)">
      Destroy Task Definition(s)
    </button>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""