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

@Pipe({
  name: 'frameStatus'
})
export class FrameStatusPipe implements PipeTransform {

  constructor (private sanitizer: DomSanitizer) {

  }

  transform(value: any, args?: any): any {
    let text = FrameVariable.getFrameDictText('FrameStatus', value);
    if (value === 'Active') {
      text =  '<div class="text-success">' + text + '</div>';
    } else if (value === 'InActive') {
      text =  '<div class="text-muted">' + text + '</div>';
    } else if (text === undefined) {
      text = '';
    }
    return this.sanitizer.bypassSecurityTrustHtml(text);
  }

}
