import { ChangeDetectorRef , Component } from '@angular/core' ; import { RuntimeService } from '../../services/runtime.service' ; import { GadgetInstanceService } from '../../grid/grid.service' ; import { EndPointService } from '../../configuration/tab-endpoint/endpoint.service' ; import { GadgetPropertyService } from '../_common/gadget-property.service' ; import { GadgetBase } from '../_common/gadget-base' ; import { StorageService } from './service' ; import { animate , style , transition , trigger } from '@angular/animations' ; import { Facet } from '../../facet/facet-model' ; import { FacetTagProcessor } from '../../facet/facet-tag-processor' ; import { OptionsService } from "../../configuration/tab-options/service" ; @ Component ( { selector : 'app-dynamic-component' , moduleId : module . id , templateUrl : './view.html' , styleUrls : [ './style.css' ] , animations : [ trigger ( 'showHideAnimation' , [ transition ( ':enter' , [ style ( { opacity : 0 } ) , animate ( 750 , style ( { opacity : 1 } ) ) ] ) , transition ( ':leave' , [ animate ( 750 , style ( { opacity : 0 } ) ) ] ) ] ) ] } ) export class StorageObjectListComponent extends GadgetBase { news : any ; resource : string ; objectList : any [ ] = [ ] ; facetTags : Array < Facet > ; objectTitleList : string [ ] = [ ] ; placeHolderText = 'Enter volume search string' ; layoutColumnOneWidth = 'four' ; layoutColumnTwoWidth = 'twelve' ; gadgetHasOperationControls = false ; constructor ( protected _runtimeService , protected _gadgetInstanceService , protected _propertyService , protected _endPointService , protected _changeDetectionRef , protected _storageService , protected _optionsService ) { super ( _runtimeService , _gadgetInstanceService , _propertyService , _endPointService , _changeDetectionRef , _optionsService ) ; } public preRun ( ) { this . updateData ( null ) ; this . run ( ) ; } public run ( ) { this . news = [ ] ; this . initializeRunState ( true ) ; this . updateData ( null ) ; } public stop ( ) { this . setStopState ( false ) ; } public updateData ( data ) { this . _storageService . get ( ) . subscribe ( item => { item [ 'volumes' ] . forEach ( _data => { this . objectList . push ( _data ) ; this . objectTitleList . push ( _data . name ) ; } ) ; const facetTagProcess = new FacetTagProcessor ( this . objectList ) ; this . facetTags = facetTagProcess . getFacetTags ( ) ; } , error => this . handleError ( error ) ) ; } public updateProperties ( updatedProperties ) { /**
         * todo
         *  A similar operation exists on the procmman-config-service
         *  whenever the property page form is saved, the in memory board model
         *  is updated as well as the gadget instance properties
         *  which is what the code below does. This can be eliminated with code added to the
         *  config service or the property page service.
         *
         * **/ const updatedPropsObject = JSON . parse ( updatedProperties ) ; this . propertyPages . forEach ( function ( propertyPage ) { for ( let x = 0 ; x < propertyPage . properties . length ; x ++ ) { for ( const prop in updatedPropsObject ) { if ( updatedPropsObject . hasOwnProperty ( prop ) ) { if ( prop === propertyPage . properties [ x ] . key ) { propertyPage . properties [ x ] . value = updatedPropsObject [ prop ] ; } } } } } ) ; this . title = updatedPropsObject . title ; this . setEndPoint ( updatedPropsObject . endpoint ) ; this . updateData ( null ) ; } actionHandler ( actionItem , actionName ) { } }