import {Pipe, PipeTransform} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';

@Pipe({
  name: 'frameStatusCustom'
})
export class FrameStatusCustomPipe implements PipeTransform {

  constructor(private sanitizer: DomSanitizer) {

  }

  transform(value: any, args: any): any {
    let active = 'text-success', inactive = 'text-danger';
    if (args.length > 2) {
      active = args[2];
    }
    if (args.length > 3) {
      inactive = args[3];
    }
    if (value === 'Active') {
      return this.sanitizer.bypassSecurityTrustHtml(`<span class="` + active + `">${args[0]}</span>`);
    } else {
      return this.sanitizer.bypassSecurityTrustHtml(`<span class="` + inactive + `">${args[1]}</span>`);
    }
  }

}
