diff options
author | Michael Lando <ml636r@att.com> | 2018-03-04 14:53:33 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-03-07 13:19:05 +0000 |
commit | a5445100050e49e83f73424198d73cd72d672a4d (patch) | |
tree | cacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/services/components/utils | |
parent | 51157f92c21976cba4914c378aaa3cba49826931 (diff) |
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74
Issue-ID: SDC-977
Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/services/components/utils')
-rw-r--r-- | catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts | 106 |
1 files changed, 63 insertions, 43 deletions
diff --git a/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts index a1fa65159f..2ed995c78c 100644 --- a/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts +++ b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts @@ -21,25 +21,28 @@ * Created by obarda on 3/13/2016. */ 'use strict'; -import {LeftPaletteComponent} from "../../../models/components/displayComponent"; -import {Component} from "../../../models/components/component"; +import * as _ from "lodash"; +import {LeftPaletteComponent, LeftPaletteMetadataTypes} from "app/models/components/displayComponent"; +import {Component} from "app/models/components/component"; import {EventListenerService} from "../../event-listener-service"; import {ComponentFactory} from "../../../utils/component-factory"; -import {IAppConfigurtaion} from "../../../models/app-config"; +import {IAppConfigurtaion} from "app/models/app-config"; import {ResourceType, ComponentType, EVENTS} from "../../../utils/constants"; -import {ComponentMetadata} from "../../../models/component-metadata"; +import {ComponentMetadata} from "app/models/component-metadata"; +import {GroupMetadata, GroupTpes} from "app/models/group-metadata"; +import {PolicyMetadata, PolicyTpes} from "app/models/policy-metadata"; import {Resource} from "app/models/components/resource"; -export class LeftPaletteDataObject { - displayLeftPanelComponents:Array<LeftPaletteComponent>; - onFinishLoadingEvent:string; +// export class LeftPaletteDataObject { +// displayLeftPanelComponents:Array<LeftPaletteComponent>; +// onFinishLoadingEvent:string; - constructor(onFinishEventListener:string) { +// constructor(onFinishEventListener:string) { - this.displayLeftPanelComponents = new Array<LeftPaletteComponent>(); - this.onFinishLoadingEvent = onFinishEventListener; - } -} +// this.displayLeftPanelComponents = new Array<LeftPaletteComponent>(); +// this.onFinishLoadingEvent = onFinishEventListener; +// } +// } export class LeftPaletteLoaderService { @@ -62,55 +65,72 @@ export class LeftPaletteLoaderService { } - private serviceLeftPaletteData:LeftPaletteDataObject; - private resourceLeftPaletteData:LeftPaletteDataObject; - private resourcePNFLeftPaletteData:LeftPaletteDataObject; - private vlData:LeftPaletteDataObject; + // private serviceLeftPaletteData:LeftPaletteDataObject; + // private resourceLeftPaletteData:LeftPaletteDataObject; + // private resourcePNFLeftPaletteData:LeftPaletteDataObject; + // private vlData:LeftPaletteDataObject; + leftPanelComponents:Array<LeftPaletteComponent>; public loadLeftPanel = (component:Component):void => { - this.serviceLeftPaletteData = new LeftPaletteDataObject(EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT); - this.resourceLeftPaletteData = new LeftPaletteDataObject(EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT); - this.resourcePNFLeftPaletteData = new LeftPaletteDataObject(EVENTS.RESOURCE_PNF_LEFT_PALETTE_UPDATE_EVENT); - this.updateComponentLeftPalette(component); + // this.serviceLeftPaletteData = new LeftPaletteDataObject(EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT); + // this.resourceLeftPaletteData = new LeftPaletteDataObject(EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT); + // this.resourcePNFLeftPaletteData = new LeftPaletteDataObject(EVENTS.RESOURCE_PNF_LEFT_PALETTE_UPDATE_EVENT); + this.leftPanelComponents = []; + this.updateLeftPaletteForTopologyTemplate(component); } - private getResourceLeftPaletteDataByResourceType = (resourceType:string):LeftPaletteDataObject => { - if(resourceType == ResourceType.PNF) { - return this.resourcePNFLeftPaletteData; - } - return this.resourceLeftPaletteData; - } + // private getResourceLeftPaletteDataByResourceType = (resourceType:string):LeftPaletteDataObject => { + // if(resourceType == ResourceType.PNF) { + // return this.resourcePNFLeftPaletteData; + // } + // return this.resourceLeftPaletteData; + // } - private onFinishLoading = (componentType:string, leftPaletteData:LeftPaletteDataObject):void => { - this.EventListenerService.notifyObservers(leftPaletteData.onFinishLoadingEvent); - }; - - private updateLeftPalette = (componentType, componentInternalType:string, leftPaletteData:LeftPaletteDataObject):void => { + private updateLeftPalette = (componentInternalType:string):void => { + /* add components */ this.restangular.one("resources").one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => { _.forEach(leftPaletteComponentMetadata, (componentMetadata:ComponentMetadata) => { - leftPaletteData.displayLeftPanelComponents.push(new LeftPaletteComponent(componentMetadata)); + this.leftPanelComponents.push(new LeftPaletteComponent(LeftPaletteMetadataTypes.Component, componentMetadata)); }); - this.onFinishLoading(componentType, leftPaletteData); + this.EventListenerService.notifyObservers(EVENTS.LEFT_PALETTE_UPDATE_EVENT); }); - }; + + /* add groups */ + //TODO: In backend implement like this: + //this.restangular.one("groups").one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => { + this.restangular.one('/groupTypes').get().then((leftPaletteGroupTypes:GroupTpes) => { + _.forEach(leftPaletteGroupTypes.groupTypes, (groupMetadata: GroupMetadata) => { + this.leftPanelComponents.push(new LeftPaletteComponent(LeftPaletteMetadataTypes.Group, groupMetadata)); + }); + this.EventListenerService.notifyObservers(EVENTS.LEFT_PALETTE_UPDATE_EVENT); + }); + + /* add policies */ + //TODO: In backend implement like this: + //this.restangular.one("policies").one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => { + this.restangular.one('/policyTypes').get().then((leftPalettePolicyTypes:PolicyTpes) => { + _.forEach(leftPalettePolicyTypes.policyTypes, (policyMetadata: PolicyMetadata) => { + this.leftPanelComponents.push(new LeftPaletteComponent(LeftPaletteMetadataTypes.Policy, policyMetadata)); + }); + this.EventListenerService.notifyObservers(EVENTS.LEFT_PALETTE_UPDATE_EVENT); + }); + } public getLeftPanelComponentsForDisplay = (component:Component):Array<LeftPaletteComponent> => { - switch (component.componentType) { - case ComponentType.SERVICE: - return this.serviceLeftPaletteData.displayLeftPanelComponents; - default://resource - return this.getResourceLeftPaletteDataByResourceType((<Resource>component).resourceType).displayLeftPanelComponents; - } + return this.leftPanelComponents; }; - public updateComponentLeftPalette = (component:Component):void => { + /** + * Update left palete items according to current topology templates we are in. + */ + public updateLeftPaletteForTopologyTemplate = (component:Component):void => { switch (component.componentType) { case ComponentType.SERVICE: - this.updateLeftPalette(ComponentType.SERVICE, ComponentType.SERVICE, this.serviceLeftPaletteData); + this.updateLeftPalette(ComponentType.SERVICE); break; case ComponentType.RESOURCE: - this.updateLeftPalette(ComponentType.RESOURCE, (<Resource>component).resourceType, this.getResourceLeftPaletteDataByResourceType((<Resource>component).resourceType)); + this.updateLeftPalette((<Resource>component).resourceType); break; default: console.log('ERROR: Component type '+ component.componentType + ' is not exists'); |