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

/********************
 * 系统状态格式化输出
 */
@Pipe({
  name: 'frameStatus'
})
export class FrameStatusPipe implements PipeTransform {

  constructor(private sanitizer: DomSanitizer) {
  }

  transform(value: any, args = {'Active': 'text-success', 'InActive': 'text-muted'}): any {
    let text = FrameService.getFrameDictText('FrameStatus', value);
    if (!args[value])
      return '';
    return this.sanitizer.bypassSecurityTrustHtml(`<span class="${args[value]}">${text}</span>`);
  }

}
