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/objectsToTree/models/vfModule/vfModule.model.info.spec.ts115
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts20
-rw-r--r--vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts2
3 files changed, 126 insertions, 11 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts
index 54bc77877..8bdab11e3 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts
@@ -416,7 +416,33 @@ describe('VFModule Model Info', () => {
'modelInfo' : {
modelVersionId : 'vfModuleId'
}
+ },
+ 'vnfModuleName_111_1': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
+ }
+ }
+ }
+ }
+ },
+ 'vnfName_1' :{
+ 'action': 'Create',
+ 'originalName' : 'vnfName',
+ 'vfModules' : {
+ 'vfModuleName' : {
+ 'vnfModuleName_111': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
+ }
+ },
+ 'vnfModuleName_111_1': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
}
+ }
}
}
}
@@ -441,6 +467,95 @@ describe('VFModule Model Info', () => {
}
};
let result = vfModuleModel.getNodeCount(<any>node , serviceId);
+ expect(result).toEqual(2);
+ });
+
+
+ test('getNodeCount should return number of nodes : there is selectedVNF', ()=>{
+ let serviceId : string = 'servicedId';
+ jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({
+ global : {},
+ service : {
+ serviceHierarchy : {
+ 'servicedId' : {
+ 'vnfs' : {
+ 'vnfName' : {
+ 'properties' : {
+ 'max_instances' : 1
+ }
+ }
+ },
+ 'vfModules' : {
+ 'vfModuleName' : {
+ 'properties' : {
+ maxCountInstances : 2
+ }
+ }
+ }
+ }
+ },
+ serviceInstance : {
+ 'servicedId' : {
+ 'existingVNFCounterMap' : {
+ 'vnfId' : 1
+ },
+ 'vnfs' : {
+ 'vnfName' :{
+ 'action': 'Create',
+ 'originalName' : 'vnfName',
+ 'vfModules' : {
+ 'vfModuleName' : {
+ 'vnfModuleName_111': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
+ }
+ },
+ 'vnfModuleName_111_1': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
+ }
+ }
+ }
+ }
+ },
+ 'vnfName_1' :{
+ 'action': 'Create',
+ 'originalName' : 'vnfName',
+ 'vfModules' : {
+ 'vfModuleName' : {
+ 'vnfModuleName_111': {
+ 'action': 'Create',
+ 'modelInfo' : {
+ modelVersionId : 'vfModuleId'
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ });
+ jest.spyOn(_sharedTreeService, 'getSelectedVNF').mockReturnValue('vnfName_1');
+
+ let node = {
+ data : {
+ id : 'vfModuleId',
+ name : 'vfModuleName',
+ 'action': 'Create',
+ },
+ parent : {
+ data : {
+ id : 'vnfId',
+ name : 'vnfName_1',
+ 'action': 'Create',
+ }
+ }
+ };
+ let result = vfModuleModel.getNodeCount(<any>node , serviceId);
expect(result).toEqual(1);
});
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 a82cd49d7..73f35279f 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
@@ -177,12 +177,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
* @param serviceModelId - current service id
************************************************************/
getNodeCount(node: ITreeNode, serviceModelId: string): number {
+ const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs;
let count: number = 0;
if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) {
- const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs;
-
- for (let vnfKey in vnfs) {
- count += this.countNumberOfVFModule(vnfs[vnfKey], node);
+ const selectedVNF: string = this._sharedTreeService.getSelectedVNF();
+ if (selectedVNF) {
+ count += this.countNumberOfVFModule(vnfs[selectedVNF], node);
+ }else {
+ for (let vnfKey in vnfs) {
+ count += this.countNumberOfVFModule(vnfs[vnfKey], node);
+ }
}
return count;
}
@@ -206,11 +210,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
getCountVFModuleOfSelectedVNF(node: ITreeNode, vnfStoreKey: string, serviceModelId: string): number {
let count: number = 0;
if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) {
- const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs;
-
- for (let vnfKey in vnfs) {
- count += this.countNumberOfVFModule(vnfs[vnfKey], node);
- }
+ const vnf = this._store.getState().service.serviceInstance[serviceModelId].vnfs[vnfStoreKey];
+ count += this.countNumberOfVFModule(vnf, node);
return count;
}
return count;
@@ -238,7 +239,6 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
showVFModuleOnSelectedVNF(node: ITreeNode, selectedVNF: string, serviceModelId: string): AvailableNodeIcons {
-
if (!_.isNil(this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF]) && node.parent.data.name === this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF].originalName) {
const existingVFModules = this.getCountVFModuleOfSelectedVNF(node, selectedVNF, serviceModelId);
const reachedLimit = this.isVFModuleReachedLimit(node, this._store.getState().service.serviceHierarchy, serviceModelId, existingVFModules);
diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts b/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts
index 26a55e9d2..cf062f0e0 100644
--- a/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts
+++ b/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts
@@ -35,7 +35,7 @@ export class MultiselectFormControlComponent implements OnChanges{
this.options = options;
this._multiselectFormControlService.convertSelectedItems(this.data).then((res)=> {
this.selectedItems = res;
- this.form.controls[this.data.controlName].setValue(this.selectedItems);
+ this.data.onChange(this.selectedItems ,this.form);
})
});
}