summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts15
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.spec.ts112
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.ts41
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts9
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html2
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts43
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts5
-rw-r--r--vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts63
-rw-r--r--vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts2
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts14
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts28
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts17
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts16
14 files changed, 312 insertions, 59 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts
index 2014be99d..8790afa56 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts
@@ -168,8 +168,19 @@ export class AvailableModelsTreeComponent {
DrawingBoardTreeService.triggerCheckIsDirty.next(this.serviceModelId);
} else {
let vfModule = this._defaultDataGeneratorService.generateVFModule(this.serviceHierarchy.vnfs[node.parent.data.name].vfModules[node.data.name], dynamicInputs, isEcompGeneratedNaming, isAlaCarte);
+ let positionOfNextInstance = null;
+ if(this._sharedTreeService.isAddPositionFlagTrue()) {
+ let baseModule = this.serviceHierarchy.vnfs[node.parent.data.name].vfModules[node.data.name].properties.baseModule;
+ if(baseModule) {
+ //Assign Position of 1 for the instance being created & update the positions(existing position +1) for remaining instances
+ positionOfNextInstance = 1;
+ this._defaultDataGeneratorService.updatePositionForRemainingVfModules(this.serviceModelId);
+ } else {
+ positionOfNextInstance = this._defaultDataGeneratorService.calculatePositionOfVfmodule(this.serviceModelId);
+ }
+ }
if (this._sharedTreeService.selectedVNF) {
- this.store.dispatch(createVFModuleInstance(vfModule, node.data.name, this.serviceModelId, null, this._sharedTreeService.selectedVNF));
+ this.store.dispatch(createVFModuleInstance(vfModule, node.data.name, this.serviceModelId, positionOfNextInstance, this._sharedTreeService.selectedVNF));
DrawingBoardTreeService.triggerCheckIsDirty.next(this.serviceModelId);
} else if (this._availableModelsTreeService.getOptionalVNFs(this.serviceModelId, node.parent.data.modelUniqueId).length === 1) {
let existVnf = this._store.getState().service.serviceInstance[this.serviceModelId].vnfs;
@@ -177,7 +188,7 @@ export class AvailableModelsTreeComponent {
for(let vnfKey in existVnf){
const modelUniqueId = this._sharedTreeService.modelUniqueId(existVnf[vnfKey]);
if(modelUniqueId === node.parent.data.id){
- this.store.dispatch(createVFModuleInstance(vfModule, node.data.name, this.serviceModelId, null, vnfKey));
+ this.store.dispatch(createVFModuleInstance(vfModule, node.data.name, this.serviceModelId, positionOfNextInstance, vnfKey));
DrawingBoardTreeService.triggerCheckIsDirty.next(this.serviceModelId);
}
}
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.spec.ts
index 425568b68..2053e6df1 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.spec.ts
@@ -13,10 +13,22 @@ class MockAppStore<T> {
return {
global: {
flags: {
- "FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE": true
+ "FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE": true,
+ "FLAG_2008_DISABLE_DRAG_FOR_BASE_MODULE":true
}
},
service: {
+ serviceHierarchy:{
+ "serviceInstanceId":{
+ vfModules: {
+ "vfModulesName":{
+ properties:{
+ baseModule:true
+ }
+ }
+ }
+ }
+ },
serviceInstance: {
"serviceInstanceId": {
vnfs: {
@@ -123,6 +135,7 @@ describe('Drag and drop service', () => {
index: 0,
data: {
instanceName: 'puwesovabe',
+ modelName: 'vocggrapitesting0..VocgGrapiTesting..ocgmgr..module-1'
},
parent: {
data: {
@@ -167,6 +180,7 @@ describe('Drag and drop service', () => {
index: 0,
data: {
instanceName: '2017-488_PASQUALE-vPE',
+ modelName: 'vocggrapitesting0..VocgGrapiTesting..ocgmgr..module-1'
},
parent: {}
};
@@ -207,4 +221,100 @@ describe('Drag and drop service', () => {
expect(arr[1]).toMatchObject({instanceName: "puwesovabe", position: 2});
});
+
+ test('drag shouldnt execute isAllowDrop when the to index is 0 & the drop node is a base module', () => {
+
+ let from = {
+ id: "04686zg11ur2",
+ index: 1,
+ data: {
+ instanceName: 'puwesovabe',
+ modelName: 'vocggrapitesting0..VocgGrapiTesting..ocgmgr..module-1'
+ },
+ parent: {
+ data: {
+ type: 'VF',
+ index: 0,
+ trackById: 'ckfqe3sb3y8',
+ vnfStoreKey: '2017-488_PASQUALE-vPE 0',
+ }
+ }
+ };
+
+ let to = {
+ parent: {
+ id: "4637423092446",
+ index: 0,
+ data: {
+ instanceName: 'bnmgtrx',
+ },
+ parent: {
+ data: {
+ type: 'VF',
+ trackById: 'ckfqe3sb3y8',
+ vnfStoreKey: '2017-488_PASQUALE-vPE 0',
+ }
+ }
+ }
+ };
+
+
+ jest.spyOn(service, 'isAllowDrop');
+
+ service.drop(store, "serviceInstanceId", nodes, {from, to});
+
+ jest.clearAllMocks();
+
+ expect(service.isAllowDrop).not.toHaveBeenCalled();
+
+ });
+
+ test('drag shouldnt execute isAllowDrop when the from node is base module', () => {
+
+ let from = {
+ id: "04686zg11ur2",
+ index: 0,
+ data: {
+ instanceName: 'puwesovabe',
+ modelName: 'vocggrapitesting0..VocgGrapiTesting..ocgmgr..module-1'
+ },
+ parent: {
+ data: {
+ type: 'VF',
+ index: 0,
+ trackById: 'ckfqe3sb3y8',
+ vnfStoreKey: '2017-488_PASQUALE-vPE 0',
+ }
+ }
+ };
+
+ let to = {
+ parent: {
+ id: "4637423092446",
+ index: 1,
+ data: {
+ instanceName: 'bnmgtrx',
+ },
+ parent: {
+ data: {
+ type: 'VF',
+ trackById: 'ckfqe3sb3y8',
+ vnfStoreKey: '2017-488_PASQUALE-vPE 0',
+ }
+ }
+ }
+ };
+
+
+ jest.spyOn(service, 'isAllowDrop');
+
+ service.drop(store, "serviceInstanceId", nodes, {from, to});
+
+ jest.clearAllMocks();
+
+ expect(service.isAllowDrop).not.toHaveBeenCalled();
+
+ });
+
+
});
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.ts
index 2daaaaf71..2f86b0aa8 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/dragAndDrop/dragAndDrop.service.ts
@@ -9,16 +9,30 @@ export class DragAndDropService {
constructor(private store: NgRedux<AppState>) {
}
- isFlagOn(): boolean {
- return FeatureFlagsService.getFlagState(Features.FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE, this.store);
+ checkFeatureFlag(flagValue):boolean {
+ let featureFlag :boolean;
+ featureFlag = FeatureFlagsService.getFlagState(flagValue, this.store);
+ return featureFlag;
+ }
+
+ /***********************************************************************************************
+ if the dragged node is a base module instance
+ ***********************************************************************************************/
+ isBaseModule(serviceInstanceId, from): boolean {
+ try {
+ let baseModuleFlag = this.store.getState().service.serviceHierarchy[serviceInstanceId].vnfs[from.parent.data.vnfStoreKey].vfModules[from.data.modelName].properties.baseModule;
+ return (baseModuleFlag != 'undefined' ? baseModuleFlag : false);
+ }catch(e) {
+ return false;
+ }
}
/***********************************************************************************************
- if the falg is ON and nodes have same parent
+ if the flag is ON and nodes have same parent
***********************************************************************************************/
isAllowDrop(from: any, to: any): boolean {
- return this.isFlagOn() && this.isSameParent(from, to);
+ return this.checkFeatureFlag(Features.FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE) && this.isSameParent(from, to);
}
private isSameParent(from: any, to: any): boolean {
@@ -40,7 +54,11 @@ export class DragAndDropService {
drop(store, instanceId: string, nodes, {from, to}): void {
- if (!this.isFlagOn()) return;
+ if (!this.checkFeatureFlag(Features.FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE)) return;
+
+ if(this.checkFeatureFlag(Features.FLAG_2008_DISABLE_DRAG_FOR_BASE_MODULE)) {
+ if ((to.parent.index == 0 && this.isBaseModule(instanceId, to.parent)) || this.isBaseModule(instanceId, from )) return;
+ }
if (this.isAllowDrop(from, to)) {
let vfModules = nodes.find((parent) => {
@@ -101,4 +119,17 @@ export class DragAndDropService {
return arr;
};
+
+ drag(store, serviceModelId: string, fromObj): boolean {
+ if(!this.checkFeatureFlag(Features.FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE)) {
+ return;
+ } else{
+ if (this.checkFeatureFlag(Features.FLAG_2008_DISABLE_DRAG_FOR_BASE_MODULE)) {
+ if(this.isBaseModule(serviceModelId,fromObj)) {
+ return;
+ }
+ }
+ }
+
+ }
}
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts
index 837471395..7526970d3 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts
@@ -126,11 +126,14 @@ export class DrawingBoardTreeComponent implements OnInit, AfterViewInit {
nodes = [];
serviceModelId: string;
options = {
- allowDrag: this._dragAndDropService.isFlagOn(),
+ allowDrag: this._dragAndDropService.checkFeatureFlag(Features.FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE),
actionMapping: {
mouse: {
drop: (tree:TreeModel, node:TreeNode, $event:any, {from, to}) => {
this._dragAndDropService.drop(this.store, this.serviceModelId, this.nodes, {from, to});
+ },
+ drag:(tree: TreeModel, node:TreeNode, $event:any) => {
+ this._dragAndDropService.drag(this.store,this.serviceModelId, node);
}
}
},
@@ -256,6 +259,10 @@ export class DrawingBoardTreeComponent implements OnInit, AfterViewInit {
}
return optionLabel;
}
+
+ isAddPositionFlagTrue() {
+ return this._sharedTreeService.isAddPositionFlagTrue();
+ }
}
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html
index 59905bd75..a1ef96a62 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html
@@ -36,7 +36,7 @@
<div class="failed-msg" [attr.data-tests-id]="'failed-error-message'" *ngIf="node?.data?.isFailed">Failed
</div>
</custom-popover>
- <div *ngIf= "node?.data?.type == 'VFmodule'" class="instance-type" style="position: relative;border: 1px solid #D2D2CD;">
+ <div *ngIf= "node?.data?.type == 'VFmodule' && isAddPositionFlagTrue()" class="instance-type" style="position: relative;border: 1px solid #D2D2CD;">
<div *ngIf="node?.data?.action == 'Create' && node?.data?.type == 'VFmodule'" class="notShowOnViewMode notShowOnCreateMode newIcon"></div>
<div><span title="{{node.data.position}}"
[attr.data-tests-id]="'node-position-indicator'">{{node?.data?.position}}</span></div>
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts
index 33ec0804f..80b2a4b52 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts
@@ -348,7 +348,9 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
enable: (node) => this._sharedTreeService.shouldShowAuditInfo(node)
},
remove: {
- method: (node, serviceModelId) => this._store.dispatch(removeVfModuleInstance(node.data.modelName, serviceModelId, node.parent.data.modelName, node.parent.data.vnfStoreKey, node.data.dynamicModelName)),
+ method: (node, serviceModelId) => {
+ this.removeVFM(serviceModelId,node);
+ },
visible: (node) => this._sharedTreeService.shouldShowRemoveAndEdit(node),
enable: (node) => this._sharedTreeService.shouldShowRemoveAndEdit(node),
},
@@ -431,8 +433,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
}
}
- updatePosition(that, node, instanceId, parentStoreKey): void {
- this._store.dispatch(updateVFModulePosition(node, instanceId, parentStoreKey));
+ updatePosition(that, node,instanceId, parentStoreKey): void {
+ that.store.dispatch(updateVFModulePosition(node.modelName,node.dynamicModelName, node.position,instanceId, parentStoreKey));
}
@@ -452,4 +454,39 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
const result = [modelInformation, instanceInfo];
return _.uniq(_.flatten(result));
}
+
+ private removeVFM(serviceModelId, node) {
+ if (FeatureFlagsService.getFlagState(Features.FLAG_2008_CREATE_VFMODULE_INSTANTIATION_ORDER_NUMBER, this._store)) {
+ let nodeArray = node.parent.children;
+ let totalNumOfNodes = nodeArray.length;
+ let removedNodeIndex = node.index;
+ let remainingNodes = totalNumOfNodes - (removedNodeIndex+1);
+ if(!_.isNull(remainingNodes)) {
+ if(remainingNodes !== 0 && remainingNodes >0) {
+ for(let i= 0;i<remainingNodes;i++) {
+ let temp = nodeArray[removedNodeIndex];
+ nodeArray[removedNodeIndex] = nodeArray[removedNodeIndex + 1];
+ nodeArray[removedNodeIndex + 1] = temp;
+ removedNodeIndex= removedNodeIndex+1;
+ }
+ let removedNode = nodeArray[nodeArray.length - 1];
+ this._store.dispatch(removeVfModuleInstance(removedNode.data.modelName, serviceModelId, removedNode.parent.data.modelName, removedNode.parent.data.vnfStoreKey, removedNode.data.dynamicModelName));
+ nodeArray.pop();
+ nodeArray.forEach((item, index) => {
+ if (item.position !== index + 1) {
+ item.position = index + 1;
+ this._store.dispatch(updateVFModulePosition(item.data.modelName,item.data.dynamicModelName, item.position,serviceModelId, item.parent.data.vnfStoreKey));
+ }
+ });
+
+
+ }else{
+ this._store.dispatch(removeVfModuleInstance(node.data.modelName, serviceModelId, node.parent.data.modelName, node.parent.data.vnfStoreKey, node.data.dynamicModelName));
+
+ }
+ }
+ } else {
+ this._store.dispatch(removeVfModuleInstance(node.data.modelName, serviceModelId, node.parent.data.modelName, node.parent.data.vnfStoreKey, node.data.dynamicModelName));
+ }
+ }
}
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
index 3b00e64c3..51fcf52a1 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
@@ -551,4 +551,8 @@ export class SharedTreeService {
!_.isNil(model.max) ? String(model.max) : Constants.ModelInfo.UNLIMITED_DEFAULT
);
}
+
+ isAddPositionFlagTrue():boolean{
+ return FeatureFlagsService.getFlagState(Features.FLAG_2008_CREATE_VFMODULE_INSTANTIATION_ORDER_NUMBER, this._store);
+ }
}
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
index 70b23f23b..47d3413b5 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
@@ -40,9 +40,10 @@ export abstract class VfModulePopupServiceBase {
formValues.uuid = formValues.modelInfo.uuid;
formValues.isMissingData = false;
if (!that.uuidData.vFModuleStoreKey) {
- this._store.dispatch(createVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, 0, that.uuidData.vnfStoreKey));
+ let positionOfNextInstance = this._defaultDataGeneratorService.calculatePositionOfVfmodule(that.uuidData.serviceId);
+ this._store.dispatch(createVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, !_.isNil(positionOfNextInstance)? positionOfNextInstance : null, that.uuidData.vnfStoreKey));
} else {
- this._store.dispatch(updateVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, that.uuidData.vFModuleStoreKey, that.uuidData.vnfStoreKey));
+ this._store.dispatch(updateVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, that.uuidData.vFModuleStoreKey, that.uuidData.vnfStoreKey, this.getInstance(that.uuidData.serviceId, that.uuidData.vnfStoreKey, that.uuidData.vFModuleStoreKey).position));
}
};
diff --git a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts
index 79cd0682e..e00b259a0 100644
--- a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts
+++ b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts
@@ -15,7 +15,7 @@ import {NetworkTreeNode} from "../../models/networkTreeNode";
import {createVNFInstance} from "../../storeUtil/utils/vnf/vnf.actions";
import {changeInstanceCounter} from "../../storeUtil/utils/general/general.actions";
import {createNetworkInstance} from "../../storeUtil/utils/network/network.actions";
-import {createVFModuleInstance} from "../../storeUtil/utils/vfModule/vfModule.actions";
+import {createVFModuleInstance, updateVFModulePosition} from "../../storeUtil/utils/vfModule/vfModule.actions";
import {createVnfGroupInstance} from "../../storeUtil/utils/vnfGroup/vnfGroup.actions";
import {VnfGroupTreeNode} from "../../models/vnfGroupTreeNode";
import {ModelInfo} from "../../models/modelInfo";
@@ -234,6 +234,7 @@ export class DefaultDataGeneratorService {
this.addDefaultVfModulesInRedux(
serviceId,
vfModuleModel.properties.initialCount,
+ vfModuleModel.properties.baseModule,
vfModule,
vnfModuleUUID,
vnfUUID
@@ -282,9 +283,14 @@ export class DefaultDataGeneratorService {
}
}
- addDefaultVfModulesInRedux(serviceId: string, numberOfVfModules: number, vfModuleData: any, vfModuleName: string, vnfUUID : string){
+ addDefaultVfModulesInRedux(serviceId: string, numberOfVfModules: number,baseModule:boolean, vfModuleData: any, vfModuleName: string, vnfUUID : string){
for (let i = 0; i < numberOfVfModules; i++) {
- this.store.dispatch(createVFModuleInstance(vfModuleData, vfModuleName, serviceId, null, vnfUUID));
+ if(baseModule) {
+ this.store.dispatch(createVFModuleInstance(vfModuleData, vfModuleName, serviceId, 1, vnfUUID));
+ } else {
+ this.store.dispatch(createVFModuleInstance(vfModuleData, vfModuleName, serviceId, i+1, vnfUUID));
+ }
+
}
}
@@ -460,4 +466,55 @@ export class DefaultDataGeneratorService {
return newVfModule;
}
+ calculatePositionOfVfmodule(serviceModelId:string) {
+ const serviceInstance = this.store.getState().service.serviceInstance[serviceModelId];
+ const serviceHierarchy = this.store.getState().service.serviceHierarchy[serviceModelId];
+
+ const vnfList = serviceInstance.vnfs;
+ let totalSecondListLength =1;
+ if (!_.isEmpty(vnfList)) {
+ for (let vnfStoreKey in vnfList) {
+ const firstVfModuleInstanceList = vnfList[vnfStoreKey].vfModules;
+ if (!_.isEmpty(firstVfModuleInstanceList)) {
+ for (let vfModuleInstanceKey in firstVfModuleInstanceList) {
+ let secondVfModuleInstanceList = firstVfModuleInstanceList[vfModuleInstanceKey];
+ let numSecondVfModuleInstanceList = Object.keys(secondVfModuleInstanceList).length;
+ totalSecondListLength = totalSecondListLength + numSecondVfModuleInstanceList;
+
+ }
+ } else {
+ //No instances added yet , hence start from 1
+ totalSecondListLength = 1;
+ }
+
+ }
+ }
+
+ return totalSecondListLength;
+ }
+
+
+ updatePositionForRemainingVfModules(serviceModelId: string) {
+
+ const serviceInstance = this.store.getState().service.serviceInstance[serviceModelId];
+ const vnfList = serviceInstance.vnfs;
+ if (!_.isEmpty(vnfList)) {
+ for (let vnfStoreKey in vnfList) {
+ const firstVfModuleInstanceList = vnfList[vnfStoreKey].vfModules;
+ if (!_.isEmpty(firstVfModuleInstanceList)) {
+ for (let vfModuleInstanceKey in firstVfModuleInstanceList) {
+ let secondVfModuleInstanceList = firstVfModuleInstanceList[vfModuleInstanceKey];
+ for(let secondVfModuleInstanceKey in secondVfModuleInstanceList) {
+ let secondVfModuleObj = secondVfModuleInstanceList[secondVfModuleInstanceKey];
+ if(!_.isNil(secondVfModuleObj.position)) {
+ this.store.dispatch(updateVFModulePosition(vfModuleInstanceKey,secondVfModuleInstanceKey, secondVfModuleObj.position+1,serviceModelId, vnfStoreKey));
+ }
+ }
+
+ }
+ }
+
+ }
+ }
+ }
}
diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
index e652be79d..758aa4b15 100644
--- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
+++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
@@ -25,6 +25,8 @@ export enum Features {
FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION = 'FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION',
FLAG_2008_PAUSE_INSTANTIATION_ON_VFMODULE_POPUP = 'FLAG_2008_PAUSE_INSTANTIATION_ON_VFMODULE_POPUP',
FLAG_2008_REMOVE_PAUSE_INSTANTIATION = 'FLAG_2008_REMOVE_PAUSE_INSTANTIATION',
+ FLAG_2008_DISABLE_DRAG_FOR_BASE_MODULE ='FLAG_2008_DISABLE_DRAG_FOR_BASE_MODULE',
+ FLAG_2008_CREATE_VFMODULE_INSTANTIATION_ORDER_NUMBER ='FLAG_2008_CREATE_VFMODULE_INSTANTIATION_ORDER_NUMBER'
}
@Injectable()
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
index cc2ed4fe3..c192ece48 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
@@ -28,17 +28,3 @@ function resetUpgradeStatus(newState: any, serviceUuid: string){
newState.serviceInstance[serviceUuid].upgradedVFMSonsCounter = 0;
newState.serviceInstance[serviceUuid].isUpgraded = false;
}
-
-export function calculatePosition(newState :any,serviceUuid: string, vnfStoreKey :string) {
-
- let totalNumOfVfModules =(Object.keys(newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules).length);
- totalNumOfVfModules = 0;
- _.forOwn(newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules, (vfModuleInstance) => {
- _.forOwn(vfModuleInstance, (module) => {
- module.position = totalNumOfVfModules +1;
- totalNumOfVfModules= totalNumOfVfModules+1;
- })
- });
-
-
-}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts
index c250993df..8096940d4 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts
@@ -17,7 +17,9 @@ export enum VfModuleActions {
export interface UpdateVFModluePosition extends Action {
- node: any,
+ vfKey: string,
+ dynamicModelName?: string,
+ position: number,
instanceId : string,
vnfStoreKey ?: string;
}
@@ -43,7 +45,8 @@ export interface UpdateVFModuleInstanceAction extends Action {
vfId: string;
serviceUuid: string;
dynamicModelName : string;
- vnfStoreKey : string
+ vnfStoreKey : string,
+ position : number
}
@@ -124,13 +127,14 @@ export const createVFModuleInstance: ActionCreator<CreateVFModuleInstanceAction>
vnfStoreKey : vnfStoreKey
});
-export const updateVFModuleInstance: ActionCreator<UpdateVFModuleInstanceAction> = (vfInstance, vfId, serviceUuid, dynamicModelName, vnfStoreKey) => ({
+export const updateVFModuleInstance: ActionCreator<UpdateVFModuleInstanceAction> = (vfInstance, vfId, serviceUuid, dynamicModelName, vnfStoreKey, position) => ({
type: VfModuleActions.UPDATE_VF_MODULE,
vfInstance: vfInstance,
vfId: vfId,
serviceUuid: serviceUuid,
dynamicModelName : dynamicModelName,
- vnfStoreKey : vnfStoreKey
+ vnfStoreKey : vnfStoreKey,
+ position : position
});
export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId, vfModuleModelName) => ({
@@ -149,12 +153,16 @@ export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleI
vfModuleModelName
});
-export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (node, instanceId, vnfStoreKey) => ({
- type: VfModuleActions.UPDATE_VFMODULE_POSITION,
- node: node,
- instanceId: instanceId,
- vnfStoreKey : vnfStoreKey
-});
+export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (vfKey,dynamicModelName,position,instanceId, vnfStoreKey) => {
+ return ({
+ type: VfModuleActions.UPDATE_VFMODULE_POSITION,
+ vfKey: vfKey,
+ dynamicModelName: dynamicModelName,
+ position: position,
+ instanceId: instanceId,
+ vnfStoreKey: vnfStoreKey
+ });
+};
export const upgradeVFModule: ActionCreator<UpgradeVfModuleInstanceAction> = (modelName, vnfStoreKey, serviceId, dynamicModelName) => ({
type: VfModuleActions.UPGRADE_VFMODULE,
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
index 50981e158..97e25d27e 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
@@ -177,9 +177,10 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => {
vnfs: {
'vfName': {
vfModules: {
- 'modelName': {
- 'dynamicModelName': {
- isMissingData: true
+ 'vfKey': {
+ dynamicModelName: {
+ isMissingData: true,
+ position :1
}
}
}
@@ -190,15 +191,13 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => {
},
<UpdateVFModluePosition>{
type: VfModuleActions.UPDATE_VFMODULE_POSITION,
- node: {
- position: 1,
- dynamicModelName: "dynamicModelName",
- modelName: "modelName"
- },
+ vfKey: "vfKey",
+ dynamicModelName: "dynamicModelName",
+ position: 1,
instanceId: "serviceModelId",
vnfStoreKey: "vfName"
- }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"];
+ }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["vfKey"]["dynamicModelName"];
expect(vfModule.position).toEqual(1);
});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
index f3584ebd9..d2f6bdf2b 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
@@ -18,7 +18,6 @@ import {VfModuleMap} from "../../../models/vfModulesMap";
import {ServiceState} from "../main.reducer";
import {PauseStatus, ServiceInstanceActions} from "../../../models/serviceInstanceActions";
import {updateServiceValidationCounter} from "../reducersHelper";
-import {calculatePosition} from "../reducersHelper";
export function vfModuleReducer(state: ServiceState , action: Action) : ServiceState{
@@ -29,6 +28,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
const serviceUuid = updateVFModuleInstanceAction.serviceUuid;
const vfModuleId = updateVFModuleInstanceAction.vfId;
const vnfStoreKey = updateVFModuleInstanceAction.vnfStoreKey;
+ const position = updateVFModuleInstanceAction.index;
let newState = Object.assign({}, state);
@@ -42,8 +42,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
updateServiceValidationCounter(newState, false, vfInstance['isMissingData'], serviceUuid);
newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId] = vfModulesMap;
- //update position of newly added VF module
- calculatePosition(newState,serviceUuid, vnfStoreKey);
+ newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId][dynamicName].position = position;
return newState;
}
case VfModuleActions.UPDATE_VF_MODULE: {
@@ -51,6 +50,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
const vfInstance = updateVFModuleInstanceAction.vfInstance;
const serviceUuid = updateVFModuleInstanceAction.serviceUuid;
const vfModuleId = updateVFModuleInstanceAction.vfId;
+ const position = updateVFModuleInstanceAction.position;
const newState = _.cloneDeep(state);
const vnfs = newState.serviceHierarchy[serviceUuid].vnfs;
let vnfId = getVfModuleParentVnfId(vnfs, vfModuleId);
@@ -64,8 +64,8 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
updateUniqueNames(vfModulesMap[updateVFModuleInstanceAction.dynamicModelName].volumeGroupName, vfInstance.volumeGroupName, newState.serviceInstance[serviceUuid]);
vfModulesMap[updateVFModuleInstanceAction.dynamicModelName] = vfInstance;
newState.serviceInstance[serviceUuid].vnfs[vnfId].vfModules[vfModuleId] = vfModulesMap;
- //retain the position of newly added VF module -- change logic
- calculatePosition(newState,serviceUuid, vnfStoreKey);
+ //retain the position of newly added VF module
+ newState.serviceInstance[serviceUuid].vnfs[vnfId].vfModules[vfModuleId][updateVFModuleInstanceAction.dynamicModelName].position= updateVFModuleInstanceAction.position;
return newState;
}
case VfModuleActions.REMOVE_VNF_MODULE_INSTANCE: {
@@ -130,11 +130,11 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
case VfModuleActions.UPDATE_VFMODULE_POSITION : {
const updateVFModluePosition = <UpdateVFModluePosition>action;
const serviceUuid = updateVFModluePosition.instanceId;
- const dynamicModelName = updateVFModluePosition.node.dynamicModelName;
- const modelName = updateVFModluePosition.node.modelName;
+ const dynamicModelName = updateVFModluePosition.dynamicModelName;
+ const modelName = updateVFModluePosition.vfKey;
const newState = _.cloneDeep(state);
- newState.serviceInstance[serviceUuid].vnfs[updateVFModluePosition.vnfStoreKey].vfModules[modelName][dynamicModelName].position = updateVFModluePosition.node.position;
+ newState.serviceInstance[serviceUuid].vnfs[updateVFModluePosition.vnfStoreKey].vfModules[modelName][dynamicModelName].position = updateVFModluePosition.position;
return newState;
}