import { Pipe , PipeTransform } from '@angular/core' ; @ Pipe ( { name : 'fileExtension' } ) export class FileExtensionPipe implements PipeTransform { private iconList = [ { type : [ 'xlsx' ] , icon : 'fa fa-file-excel-o' } , { type : [ 'pdf' ] , icon : 'fa fa-file-pdf-o' } , { type : [ 'csv' ] , icon : 'fas fa-file-csv' } , { type : [ 'gif' , 'png' , 'jpg' , 'jpeg' ] , icon : 'fa fa-file-image-o' } , { type : [ 'ppt' , 'pptx' ] , icon : 'far fa-file-powerpoint' } , { type : [ 'doc' , 'docx' ] , icon : 'far fa-file-word' } ] ; /**
     * Converts input values into fontawesome i-tags.
     * Creates ICONS based on the document extension.
     */ transform ( filename ) { const ext = filename . split ( '.' ) . pop ( ) ; const obj = this . iconList . filter ( row => { if ( row . type . includes ( ext ) ) { return true ; } } ) ; if ( obj . length > 0 ) { return obj [ 0 ] . icon ; } else { return 'far fa-file-code' ; } } }