aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services/components
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/services/components')
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts32
-rw-r--r--catalog-ui/src/app/services/components/resource-service.ts1
-rw-r--r--catalog-ui/src/app/services/components/service-service.ts1
-rw-r--r--catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts106
4 files changed, 88 insertions, 52 deletions
diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts
index 1b2b9f2fa1..74166a0c9f 100644
--- a/catalog-ui/src/app/services/components/component-service.ts
+++ b/catalog-ui/src/app/services/components/component-service.ts
@@ -18,6 +18,7 @@
* ============LICENSE_END=========================================================
*/
'use strict';
+import * as _ from "lodash";
import {ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance,
AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties} from "app/models";
import {ComponentInstanceFactory, CommonUtils} from "app/utils";
@@ -40,6 +41,7 @@ export interface IComponentService {
updateAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
deleteProperty(componentId:string, propertyId:string):ng.IPromise<PropertyModel>;
deleteAttribute(componentId:string, attributeId:string):ng.IPromise<AttributeModel>;
+ checkResourceInstanceVersionChange(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<any>;
changeResourceInstanceVersion(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance>;
updateInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
addInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
@@ -55,7 +57,7 @@ export interface IComponentService {
deleteRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
fetchRelation(componentId:string, linkId:string):ng.IPromise<RelationshipModel>;
getRequirementsCapabilities(componentId:string):ng.IPromise<any>;
- updateInstanceProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>;
+ updateInstanceProperties(componentId:string, componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]>;
updateInstanceAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
getComponentInstancesFilteredByInputsAndProperties(componentId:string, searchText:string):ng.IPromise<Array<ComponentInstance>>
getComponentInstanceInputs(componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<InputModel>>;
@@ -422,6 +424,16 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
+ public checkResourceInstanceVersionChange = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance> => {
+ let deferred = this.$q.defer();
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one(componentUid).one("checkForwardingPathOnVersionChange").get().then((response:any) => {
+ deferred.resolve(response);
+ }, err => {
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ };
+
public changeResourceInstanceVersion = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer();
this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("changeVersion").customPOST({'componentUid': componentUid}).then((response:any) => {
@@ -498,14 +510,16 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public updateInstanceProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => {
- let deferred = this.$q.defer();
- let instanceId = property.resourceInstanceUniqueId;
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("property").customPOST(JSON.stringify(property)).then((response:any) => {
- let newProperty = new PropertyModel(response);
- newProperty.readonly = true;
- newProperty.resourceInstanceUniqueId = instanceId;
- deferred.resolve(newProperty);
+ public updateInstanceProperties = (componentId:string, componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]> => {
+ let deferred = this.$q.defer<PropertyModel[]>();
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("properties").customPOST(JSON.stringify(properties)).then((response:any) => {
+ const newProperties = response.map((res) => {
+ const newProperty = new PropertyModel(res);
+ newProperty.readonly = true;
+ newProperty.resourceInstanceUniqueId = componentInstanceId;
+ return newProperty;
+ });
+ deferred.resolve(newProperties);
}, (err)=> {
deferred.reject(err);
});
diff --git a/catalog-ui/src/app/services/components/resource-service.ts b/catalog-ui/src/app/services/components/resource-service.ts
index 641d7cba48..aabc14f8bd 100644
--- a/catalog-ui/src/app/services/components/resource-service.ts
+++ b/catalog-ui/src/app/services/components/resource-service.ts
@@ -22,6 +22,7 @@
* Created by obarda on 2/4/2016.
*/
'use strict';
+import * as _ from "lodash";
import {IComponentService, ComponentService} from "./component-service";
import {PropertyModel, IAppConfigurtaion, Resource, Component} from "../../models";
import {SharingService} from "../sharing-service";
diff --git a/catalog-ui/src/app/services/components/service-service.ts b/catalog-ui/src/app/services/components/service-service.ts
index 4229c4aa2a..d55cae75ce 100644
--- a/catalog-ui/src/app/services/components/service-service.ts
+++ b/catalog-ui/src/app/services/components/service-service.ts
@@ -22,6 +22,7 @@
* Created by obarda on 2/4/2016.
*/
'use strict';
+import * as _ from "lodash";
import {IComponentService, ComponentService} from "./component-service";
import {Distribution, DistributionComponent, Service, PropertyModel, Component, IAppConfigurtaion} from "app/models";
import {SharingService} from "../sharing-service";
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');