import { AppExtensionService , ContentApiService } from '@alfresco/aca-shared' ; import { AppStore } from '@alfresco/aca-shared/store' ; import { UploadService } from '@alfresco/adf-core' ; import { MinimalNodeEntity , MinimalNodeEntryEntity , PathElementEntity , PathInfo } from '@alfresco/js-api' ; import { BreakpointObserver , Breakpoints } from '@angular/cdk/layout' ; import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { Store } from '@ngrx/store' ; import { debounceTime , map } from 'rxjs/operators' ; import { ContentManagementService } from '../../services/content-management.service' ; import { PageComponent } from '../page.component' ; import { DocumentListPresetRef } from '@alfresco/adf-extensions' ; @ Component ( { templateUrl : './favorites.component.html' } ) export class FavoritesComponent extends PageComponent implements OnInit { isSmallScreen = false ; columns : DocumentListPresetRef [ ] = [ ] ; constructor ( private router , store , extensions , private contentApi , content , private uploadService , private breakpointObserver ) { super ( store , extensions , content ) ; } ngOnInit ( ) { super . ngOnInit ( ) ; this . subscriptions = this . subscriptions . concat ( [ this . uploadService . fileUploadComplete . pipe ( debounceTime ( 300 ) ) . subscribe ( ( _ ) => this . reload ( ) ) , this . uploadService . fileUploadDeleted . pipe ( debounceTime ( 300 ) ) . subscribe ( ( _ ) => this . reload ( ) ) , this . breakpointObserver . observe ( [ Breakpoints . HandsetPortrait , Breakpoints . HandsetLandscape ] ) . subscribe ( ( result ) => { this . isSmallScreen = result . matches ; } ) ] ) ; this . columns = this . extensions . documentListPresets . favorites ; } navigate ( favorite ) { const { isFolder , id } = favorite ; const isSitePath = ( path ) : boolean => { return path && path . elements && path . elements . some ( ( { name } ) => name === 'Sites' ) ; } ; if ( isFolder ) { this . contentApi . getNode ( id ) . pipe ( map ( ( node ) => node . entry ) ) . subscribe ( ( { path } ) => { const routeUrl = isSitePath ( path ) ? '/libraries' : '/personal-files' ; this . router . navigate ( [ routeUrl , id ] ) ; } ) ; } } onNodeDoubleClick ( node ) { if ( node && node . entry ) { if ( node . entry . isFolder ) { this . navigate ( node . entry ) ; } if ( node . entry . isFile ) { this . showPreview ( node , { location : this . router . url } ) ; } } } handleNodeClick ( event ) { this . onNodeDoubleClick ( ( event as CustomEvent ) . detail ?. node ) ; } }