File

src/app/audit/components/audit-record-action/audit-record-action.component.ts

Description

Runtime application status.

Implements

OnChanges

Example

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector app-audit-record-action
styleUrls styles.scss

Index

Properties
Methods
Inputs

Constructor

constructor()

Inputs

auditRecord

Runtime Application

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional Description
changes SimpleChanges
Returns : void

Properties

className
className:
Default value : default

CSS class

state
state:

Current status

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

/**
 * Runtime application status.
 *
 * @author Vitrac Damien
 */
@Component({
  selector: 'app-audit-record-action',
  styleUrls: ['./styles.scss'],
  template: `<span *ngIf="state" class="label label-{{ className }}">{{ state | uppercase }}</span>`,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AuditRecordActionComponent implements OnChanges {

  /**
   * Runtime Application
   */
  @Input() auditRecord;

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

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

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

  ngOnChanges(changes: SimpleChanges) {
    if (changes.auditRecord.currentValue.auditAction) {
      this.state = changes.auditRecord.currentValue.auditAction;
      switch (this.state.toLowerCase()) {
        case 'create':
        case 'deploy':
          this.className = 'success';
          break;
        case 'delete':
          this.className = 'danger';
          break;
        case 'undeploy':
        case 'rollback':
          this.className = 'warning';
          break;
        case 'update':
          this.className = 'info';
          break;
      }
    }
  }


}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""