summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil')
-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.reducers.ts8
2 files changed, 21 insertions, 1 deletions
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 c192ece48..cc2ed4fe3 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
@@ -28,3 +28,17 @@ 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.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
index 294536de6..fa6bd9ecb 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,6 +18,7 @@ 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{
@@ -34,12 +35,15 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
let vfModulesMap = newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId] || new VfModuleMap();
let randomId = generateId();
vfInstance.action = ServiceInstanceActions.Create;
- vfModulesMap[vfModuleId + randomId] = vfInstance;
+ let dynamicName = vfModuleId + randomId;
+ vfModulesMap[dynamicName] = vfInstance;
updateUniqueNames(null, vfInstance.instanceName, newState.serviceInstance[serviceUuid]);
updateUniqueNames(null, vfInstance.volumeGroupName, newState.serviceInstance[serviceUuid]);
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);
return newState;
}
case VfModuleActions.UPDATE_VF_MODULE: {
@@ -60,6 +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);
return newState;
}
case VfModuleActions.REMOVE_VNF_MODULE_INSTANCE: {