File

src/app/streams/stream-deploy/builder/errors/errors.component.ts

Description

StreamDeployBuilderErrorsComponent

Example

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector app-stream-deploy-builder-errors
styleUrls styles.scss
templateUrl errors.component.html

Index

Methods
Inputs
Outputs

Inputs

errors

Error Object

Type: StreamBuilderError

Outputs

removeError

Event triggered to remove a property

$event type: EventEmitter

Methods

getErrors
getErrors()

List all errors

Returns : any
removeProperty
removeProperty(type: string, index: number)
Parameters :
Name Type Optional Description
type string
index number
Returns : void
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output, } from '@angular/core';
import { StreamBuilderError } from '../../../components/streams.interface';

/**
 * StreamDeployBuilderErrorsComponent
 *
 * @author Damien Vitrac
 */
@Component({
  selector: 'app-stream-deploy-builder-errors',
  templateUrl: 'errors.component.html',
  styleUrls: ['styles.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class StreamDeployBuilderErrorsComponent {

  /**
   * Error Object
   */
  @Input() errors: StreamBuilderError;

  /**
   * Event triggered to remove a property
   */
  @Output() removeError = new EventEmitter<{ type: string, index: number }>();

  removeProperty(type: string, index: number) {
    this.removeError.emit({ type: type, index: index });
  }

  /**
   * List all errors
   */
  getErrors() {
    const result = [];
    if (this.errors) {
      this.errors.global.forEach((error, index) => {
        result.push({ type: 'global', index: index, property: error });
      });
      this.errors.app.forEach((error, index) => {
        result.push({ type: 'app', index: index, property: error });
      });
    }
    return result.sort((a, b) => {
      return a.property > b.property ? 1 : -1;
    });
  }

}
<div class="alert alert-danger" *ngIf="errors?.app?.length > 0 || errors?.global?.length > 0">
  <div *ngFor="let line of getErrors()" class="alert-line">
    {{ line.property }}
    <a class="trash" (click)="removeProperty(line.type, line.index)">
      <span class="fa fa-trash"></span>
    </a>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""