Visualization of the VF Module Sequencing 36/110136/1
authorikram <ikram@research.att.com>
Mon, 13 Jul 2020 19:28:31 +0000 (15:28 -0400)
committerikram <ikram@research.att.com>
Mon, 13 Jul 2020 19:28:31 +0000 (15:28 -0400)
Issue-ID: VID-860

In this user story, we plan to allow the user to visually see the sequence numbers when a VF module is added from the left panel of the drawing board onto the right one. Note: The idea that the sequence change when a VF Module is dragged up and down is not part of the scope of this story - we will deliver that separately. This is only about the default sequencing that the drawing board renders when a new VF module is created into the 'instance' part of the drawing board from the 'model' part of the drawing board.

Signed-off-by: ikram <ikram@research.att.com>
Change-Id: Iadd5cef1012f8ef5c670bbd2c46950680a9e6b0e

vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html
vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts
vid-webpack-master/src/app/shared/models/vfModuleTreeNode.ts
vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts
vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts

index 0ebee90..59905bd 100644 (file)
           <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?.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>
+          <div *ngIf="isLinkedInstance(node?.data)">
+            <custom-icon
+              [ngClass]="'link'"
+              class="icon-link"
+              [size]="'small'"
+              [name]="'link'">
+            </custom-icon>
+          </div>
+        </div>
         <div class="instance-type" style="position: relative;border: 1px solid #D2D2CD;">
           <div *ngIf="node?.data?.action == 'Create'" class="notShowOnViewMode notShowOnCreateMode newIcon"></div>
           <div><span title="{{node.data.type}}"
           <span>Limit</span><span>{{node?.data?.limitMembers}}</span>
         </div>
         <div class="model-actions notShowOnViewMode" *ngIf="isPaused(node)" style="border-right: none;">
-              <custom-icon
-                [size]="'large'"
-                [name]="'pause-upon-completion'"
-                [testId]="'pause-upon-completion'">
-              </custom-icon>
+          <custom-icon
+            [size]="'large'"
+            [name]="'pause-upon-completion'"
+            [testId]="'pause-upon-completion'">
+          </custom-icon>
         </div>
         <div class="model-actions notShowOnViewMode">
           <span class="icon-browse"
index 607519a..f7bf35a 100644 (file)
@@ -99,7 +99,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
     newVfModule.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed;
     newVfModule.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : "";
     newVfModule.pauseInstantiation = instance.pauseInstantiation;
-
+    newVfModule.position = instance.position;
     newVfModule = this._sharedTreeService.addingStatusProperty(newVfModule);
     return newVfModule;
   }
@@ -424,7 +424,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
   }
 
   updatePosition(that, node, instanceId, parentStoreKey): void {
-    that.store.dispatch(updateVFModulePosition(node, instanceId, parentStoreKey));
+    this._store.dispatch(updateVFModulePosition(node, instanceId, parentStoreKey));
   }
 
 
index e3d1b79..166d90f 100644 (file)
@@ -10,6 +10,7 @@ export class VfModuleTreeNode extends TreeNodeModel{
   menuActions: { [p: string]: { method: Function; visible: Function; enable: Function } };
   isFailed: boolean;
   statusMessage?: string;
+  position: number;
 
   constructor(vfModuleInstance: VfModuleInstance, vfModuleModel: VfModule, vfModuleModelName: string, dynamicInputs: any, isEcompGeneratedNaming: boolean, dynamicModelName : string){
     super(vfModuleInstance,vfModuleModel);
index 3b3092a..79cd068 100644 (file)
@@ -329,6 +329,8 @@ export class DefaultDataGeneratorService {
       ],
       'trackById': DefaultDataGeneratorService.createRandomTrackById(),
       'rollbackOnFailure' : isALaCarte ? true : null,
+      'position': vfModule.position
+
     };
   }
 
index c192ece..cc2ed4f 100644 (file)
@@ -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;
+    })
+  });
+
+
+}
index 294536d..fa6bd9e 100644 (file)
@@ -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: {