diff options
author | ikram <ikram@research.att.com> | 2020-08-07 15:49:11 -0400 |
---|---|---|
committer | Kruthi Bhat <krutbhat@att.com> | 2020-08-10 19:21:30 +0000 |
commit | 32af6479c686d217204de3a86940ac1256da4b9f (patch) | |
tree | 98eb5135887c5bf5943099a783c9cd3d7dbbd8a4 /vid-webpack-master/src/app/shared/storeUtil/utils | |
parent | 09a6562a16715a2b89be11c941486be783c72364 (diff) |
Visualization of the VF Module Sequencing
Issue-ID: VID-860
More scenarios covered in VID-860 for vf-module sequencing.
Signed-off-by: ikram <ikram@research.att.com>
Change-Id: Ie138ba2616961fba7856eaaf5f17b5dc63a08e6e
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils')
4 files changed, 34 insertions, 41 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 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; } |