File

src/app/jobs/components/job-execution-status.component.ts

Description

Component that will format the Job Execution Status.

Implements

OnChanges

Example

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector app-job-execution-status

Index

Properties
Methods
Inputs

Constructor

constructor()

Inputs

status

The status that needs to be formatted.

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)

On Changes

Parameters :
Name Type Optional Description
changes SimpleChanges
Returns : void

Properties

className
className:
Default value : default

CSS class

state
state:

Current status

import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';

/**
 * Component that will format the Job Execution Status.
 *
 * @author Gunnar Hillert
 * @author Damien Vitrac
 */
@Component({
  selector: 'app-job-execution-status',
  template: `<span *ngIf="state" class="label label-job-status label-{{ className }}">{{ state | uppercase }}</span>`,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class JobExecutionStatusComponent implements OnChanges {

  /**
   * The status that needs to be formatted.
   */
  @Input() status;


  /**
   * Current status
   */
  state = '';

  /**
   * CSS class
   */
  className = 'default';

  /**
   * Constructor
   */
  constructor() {
  }


  /**
   * On Changes
   */
  ngOnChanges(changes: SimpleChanges) {
    if (changes.status.currentValue) {
      this.state = changes.status.currentValue;
      switch (this.state) {
        case 'STARTED':
          this.className = 'info';
          break;
        case 'COMPLETED':
          this.className = 'success';
          break;
        case 'FAILED':
          this.className = 'danger';
          break;
        default:
          this.className = 'default';
      }
    }
  }

}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""