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

@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(`<div class="` + active + `">${args[0]}</div>`);
    } else {
      return this.sanitizer.bypassSecurityTrustHtml(`<div class="` + inactive + `">${args[1]}</div>`);
    }
  }

}
