import { Component , OnInit , ViewEncapsulation } from '@angular/core' ; import { ActivatedRoute , PRIMARY_OUTLET , Router } from '@angular/router' ; import { NodesApiService } from '@alfresco/adf-core' ; import { MatSnackBar } from '@angular/material/snack-bar' ; @ Component ( { selector : 'app-file-view' , templateUrl : 'file-view.component.html' , styleUrls : [ 'file-view.component.scss' ] , encapsulation : ViewEncapsulation . None , } ) export class FileViewComponent implements OnInit { nodeId : string = null ; constructor ( private router , private route , private snackBar , private nodeApiService ) { } ngOnInit ( ) { this . route . params . subscribe ( ( params ) => { const id = params . nodeId ; if ( id ) { this . nodeApiService . getNode ( id ) . subscribe ( ( node ) => { if ( node && node . isFile ) { this . nodeId = id ; return ; } this . router . navigate ( [ '/files' , id ] ) ; } , ( ) => this . router . navigate ( [ '/files' , id ] ) ) ; } } ) ; } onUploadError ( errorMessage ) { this . snackBar . open ( errorMessage , '' , { duration : 4000 } ) ; } onViewerVisibilityChanged ( ) { const primaryUrl = this . router . parseUrl ( this . router . url ) . root . children [ PRIMARY_OUTLET ] . toString ( ) ; this . router . navigateByUrl ( primaryUrl ) ; } }