import { Component , OnDestroy , OnInit } from '@angular/core' ; import { SystemService } from '../system.service' ; import { ReplaySubject } from 'rxjs' ; import { ToastService } from '../../../layout/toast/toast.service' ; import { takeUntil } from 'rxjs/operators' ; @ Component ( { selector : 'cmdb-properties' , templateUrl : './properties.component.html' , styleUrls : [ './properties.component.scss' ] } ) export class PropertiesComponent implements OnInit , OnDestroy { public config : { path : string ; properties : any [ ] ; } ; private subscriber : ReplaySubject < void > = new ReplaySubject < void > ( ) ; constructor ( private systemService , private toast ) { } public ngOnInit ( ) { this . systemService . getConfigInformation ( ) . pipe ( takeUntil ( this . subscriber ) ) . subscribe ( config => { this . config = { path : config . path , properties : [ ] } ; for ( const section of config . properties ) { for ( const prop of section [ 1 ] ) { this . config . properties . push ( { section : section [ 0 ] , key : prop [ 0 ] , value : prop [ 1 ] } ) ; } } } , ( error ) => { this . toast . error ( error ) ; } , ( ) => { } ) ; } public ngOnDestroy ( ) { this . subscriber . next ( ) ; this . subscriber . complete ( ) ; } }