import { Component , OnInit , ViewEncapsulation , OnDestroy } from '@angular/core' ; import { ActivatedRoute } from '@angular/router' ; import { PageComponent } from '../page.component' ; import { AppExtensionService , ContentApiService } from '@alfresco/aca-shared' ; import { AppStore , NavigateToPreviousPage , SetSelectedNodesAction } from '@alfresco/aca-shared/store' ; import { Store } from '@ngrx/store' ; import { ContentManagementService } from '../../services/content-management.service' ; import { Subject } from 'rxjs' ; @ Component ( { selector : 'app-details-manager' , templateUrl : './details.component.html' , styleUrls : [ './details.component.scss' ] , encapsulation : ViewEncapsulation . None } ) export class DetailsComponent extends PageComponent implements OnInit , OnDestroy { nodeId : string ; isLoading : boolean ; onDestroy$ = new Subject < boolean > ( ) ; activeTab = 1 ; constructor ( private route , private contentApi , store , content , extensions ) { super ( store , extensions , content ) ; } ngOnInit ( ) { super . ngOnInit ( ) ; this . isLoading = true ; const { route } = this ; const { data } = route . snapshot ; this . title = data . title ; this . route . params . subscribe ( ( params ) => { this . isLoading = true ; this . setActiveTab ( params . activeTab ) ; this . nodeId = params . nodeId ; this . contentApi . getNode ( this . nodeId ) . subscribe ( ( node ) => { this . node = node . entry ; this . isLoading = false ; this . store . dispatch ( new SetSelectedNodesAction ( [ { entry : this . node } ] ) ) ; } ) ; } ) ; } setActiveTab ( tabName ) { switch ( tabName ) { case 'comments' : this . activeTab = 1 ; break ; case 'permissions' : this . activeTab = 2 ; break ; case 'metadata' : default : this . activeTab = 0 ; } } goBack ( ) { this . store . dispatch ( new NavigateToPreviousPage ( ) ) ; } ngOnDestroy ( ) { this . store . dispatch ( new SetSelectedNodesAction ( [ ] ) ) ; this . onDestroy$ . next ( ) ; this . onDestroy$ . complete ( ) ; } }