Merge "regression unit test for getServicesByOwningEntityId"
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / available-models-tree / available-models-tree.component.ts
index 31d7b03..2e04f53 100644 (file)
@@ -10,7 +10,7 @@ import {AaiService} from '../../../shared/services/aaiService/aai.service';
 import {ServiceNodeTypes} from '../../../shared/models/ServiceNodeTypes';
 import {IframeService} from "../../../shared/utils/iframe.service";
 import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataServiceGenerator/default.data.generator.service";
-import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service";
+import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service";
 import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service";
 import {createVFModuleInstance} from "../../../shared/storeUtil/utils/vfModule/vfModule.actions";
 import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
@@ -25,6 +25,10 @@ import {VnfGroupControlGenerator} from "../../../shared/components/genericForm/f
 import {HighlightPipe} from "../../../shared/pipes/highlight/highlight-filter.pipe";
 import * as _ from 'lodash';
 import {DrawingBoardTreeComponent} from "../drawing-board-tree/drawing-board-tree.component";
+import {ComponentInfoModel} from "../component-info/component-info-model";
+import {ComponentInfoService} from "../component-info/component-info.service";
+import {FeatureFlagsService, Features} from "../../../shared/services/featureFlag/feature-flags.service";
+import {Utils} from "../../../shared/utils/utils";
 
 
 @Component({
@@ -52,7 +56,7 @@ export class AvailableModelsTreeComponent {
               private _drawingBoardTreeService: DrawingBoardTreeService,
               private _defaultDataGeneratorService: DefaultDataGeneratorService,
               private _vnfGroupControlGenerator: VnfGroupControlGenerator,
-              private _vfModulePopuopService: VfModulePopuopService,
+              private _vfModulePopuopService: VfModulePopupService,
               private _vnfGroupPopupService: VnfGroupPopupService,
               private _vnfPopupService: VnfPopupService,
               private _networkPopupService: NetworkPopupService,
@@ -72,6 +76,7 @@ export class AvailableModelsTreeComponent {
           value => {
             this.serviceHierarchy = value;
             this.nodes = this._objectToModelTreeService.convertServiceHierarchyModelToTreeNodes(this.serviceHierarchy);
+            this.shouldOpenVRFModal(this.nodes);
           },
           error => {
             console.log('error is ', error)
@@ -83,12 +88,13 @@ export class AvailableModelsTreeComponent {
 
   @Output()
   highlightInstances: EventEmitter<number> = new EventEmitter<number>();
-  @ViewChild('tree') tree: TreeComponent;
+  @ViewChild('tree', {static: false}) tree: TreeComponent;
 
   nodes = [];
   service = {name: ''};
 
   options: ITreeOptions = {
+    allowDrop:false,
     nodeHeight: 36,
     dropSlotHeight: 0,
     nodeClass: (node: ITreeNode) => {
@@ -102,6 +108,13 @@ export class AvailableModelsTreeComponent {
   };
 
 
+  shouldOpenVRFModal(nodes) :void {
+    const node = this._availableModelsTreeService.shouldOpenVRFModal(nodes, this.serviceModelId, this.store.getState().service);
+    if(!_.isNil(node)){
+      this.onClickAdd(node,  this.serviceModelId);
+    }
+  }
+
   getNodeName(node : ITreeNode, filter : string) {
     return this._highlightPipe.transform(node.data.name ,filter ? filter : '');
   }
@@ -119,6 +132,19 @@ export class AvailableModelsTreeComponent {
     node.expand();
     this._sharedTreeService.setSelectedVNF(null);
     this.highlightInstances.emit(node.data.modelUniqueId);
+    if (FeatureFlagsService.getFlagState(Features.FLAG_1906_COMPONENT_INFO, this.store)) {
+      const serviceHierarchy = this._store.getState().service.serviceHierarchy[this.serviceModelId];
+
+      const instanceModel = this._sharedTreeService.modelByIdentifiers(
+        serviceHierarchy, node.data.modelTypeName,
+        this._sharedTreeService.modelUniqueNameOrId(node.data), node.data.name
+      );
+
+      const model = node.data.getModel(instanceModel);
+      const modelInfoItems  = node.data.getInfo(model, null);
+      const componentInfoModel :ComponentInfoModel = this._sharedTreeService.addGeneralInfoItems(modelInfoItems, node.data.componentInfoType, model, null);
+      ComponentInfoService.triggerComponentInfoChange.next(componentInfoModel);
+    }
   }
 
 
@@ -127,10 +153,10 @@ export class AvailableModelsTreeComponent {
     this.isNewObject = isNewObject;
     let data = node.data;
     let dynamicInputs = data.dynamicInputs;
-    let isAlaCarte: boolean = this.serviceHierarchy.service.instantiationType == "A-La-Carte";
+    let isAlaCarte: boolean = Utils.isALaCarte(this.serviceHierarchy.service.vidNotions.instantiationType);
     let isEcompGeneratedNaming: boolean = data.isEcompGeneratedNaming;
     let type: string = data.type;
-    if (!this.store.getState().global.flags['FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD'] || node.data.type === ServiceNodeTypes.VF ||
+    if (node.data.type === ServiceNodeTypes.VF ||
       this._availableModelsTreeService.shouldOpenDialog(type, dynamicInputs, isEcompGeneratedNaming)) {
       this._iframeService.addClassOpenModal(this.parentElementClassName);
       node.data.onAddClick(node, serviceId);
@@ -146,11 +172,12 @@ export class AvailableModelsTreeComponent {
         if (this._sharedTreeService.selectedVNF) {
           this.store.dispatch(createVFModuleInstance(vfModule, node.data.name, this.serviceModelId, null, this._sharedTreeService.selectedVNF));
           DrawingBoardTreeComponent.triggerreCalculateIsDirty.next(this.serviceModelId);
-        } else if (this._availableModelsTreeService.getOptionalVNFs(this.serviceModelId, node.parent.data.name).length === 1) {
+        } else if (this._availableModelsTreeService.getOptionalVNFs(this.serviceModelId, node.parent.data.modelUniqueId).length === 1) {
           let existVnf = this._store.getState().service.serviceInstance[this.serviceModelId].vnfs;
           if(!_.isNil(existVnf)){
             for(let vnfKey in existVnf){
-              if(existVnf[vnfKey]['modelInfo'].modelUniqueId === node.parent.data.id){
+              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));
                 DrawingBoardTreeComponent.triggerreCalculateIsDirty.next(this.serviceModelId);
               }