aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/services
parent51157f92c21976cba4914c378aaa3cba49826931 (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')
-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
-rw-r--r--catalog-ui/src/app/services/entity-service.ts4
-rw-r--r--catalog-ui/src/app/services/event-listener-service.ts1
-rw-r--r--catalog-ui/src/app/services/onboarding-service.ts2
7 files changed, 92 insertions, 55 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');
diff --git a/catalog-ui/src/app/services/entity-service.ts b/catalog-ui/src/app/services/entity-service.ts
index 27b0513b39..b7ac8805ce 100644
--- a/catalog-ui/src/app/services/entity-service.ts
+++ b/catalog-ui/src/app/services/entity-service.ts
@@ -54,13 +54,13 @@ export class EntityService implements IEntityService {
let followedResponse: IComponentsArray = response.data;
let componentsList:Array<Component> = new Array();
- followedResponse.services.forEach((serviceResponse:Service) => {
+ followedResponse.services && followedResponse.services.forEach((serviceResponse:Service) => {
let component:Service = this.ComponentFactory.createService(serviceResponse); // new Service(serviceResponse);
componentsList.push(component);
this.sharingService.addUuidValue(component.uniqueId, component.uuid);
});
- followedResponse.resources.forEach((resourceResponse:Resource) => {
+ followedResponse.resources && followedResponse.resources.forEach((resourceResponse:Resource) => {
let component:Resource = this.ComponentFactory.createResource(resourceResponse);
componentsList.push(component);
this.sharingService.addUuidValue(component.uniqueId, component.uuid);
diff --git a/catalog-ui/src/app/services/event-listener-service.ts b/catalog-ui/src/app/services/event-listener-service.ts
index 96f9e17641..360edad700 100644
--- a/catalog-ui/src/app/services/event-listener-service.ts
+++ b/catalog-ui/src/app/services/event-listener-service.ts
@@ -21,6 +21,7 @@
* Created by obarda on 7/4/2016.
*/
'use strict';
+import * as _ from "lodash";
import {Dictionary} from "../utils/dictionary/dictionary";
interface IEventListenerService {
diff --git a/catalog-ui/src/app/services/onboarding-service.ts b/catalog-ui/src/app/services/onboarding-service.ts
index 3dd7269326..3a6e940c6e 100644
--- a/catalog-ui/src/app/services/onboarding-service.ts
+++ b/catalog-ui/src/app/services/onboarding-service.ts
@@ -75,7 +75,7 @@ export class OnboardingService implements IOnboardingService {
};
downloadOnboardingCsar = (packageId:string):ng.IPromise<IFileDownload> => {
- let defer = this.$q.defer();
+ let defer = this.$q.defer<IFileDownload>();
this.$http({
url: this.api.GET_onboarding + "/" + packageId,
method: "get",