import { Component , Input , Output , EventEmitter } from "@angular/core" ; import { PreviewFileService } from "../../../core/services" ; import { AppFile } from "../../../data" ; import { LoaderAnimation } from "../../animations" ; import { getEncodedSvgCSSBackground } from "../../utilities" ; @ Component ( { selector : "app-grid-view" , templateUrl : "./grid-view.component.html" , styleUrls : [ "./grid-view.component.scss" ] , animations : [ LoaderAnimation ] , } ) export class GridViewComponent { @ Input ( ) files : AppFile [ ] = [ ] ; @ Output ( ) fileRightClick = new EventEmitter ( ) ; @ Output ( ) fileRightClickBody = new EventEmitter ( ) ; @ Output ( ) selectFile = new EventEmitter ( ) ; private isSingleClick = true ; constructor ( private previewFileService ) { } public getPreviewURI ( path ) { return `"${ encodeURI ( path ) . replace ( "(" , "%28" ) . replace ( ")" , "%29" ) }"` ; } public getEncodedSvgCSSBackground ( data ) { return getEncodedSvgCSSBackground ( data ) ; } public addSelectedFile ( file ) { this . isSingleClick = true ; setTimeout ( ( ) => { if ( this . isSingleClick ) { this . selectFile . emit ( file ) ; } } , 250 ) ; } public previewFile ( file ) { this . isSingleClick = false ; this . previewFileService . showPreviewFile ( file ) ; } public onRightClick ( file ) { this . fileRightClick . emit ( file ) ; } public onRightClickBody ( ) { this . fileRightClickBody . emit ( ) ; } public trackByFn ( index , file ) { return file . id ; } }