Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / InstantiationController.js
index 1b3ab09..06622cf 100755 (executable)
@@ -27,7 +27,7 @@
 \r
     appDS2.requires.push('ui.tree');\r
 \r
-    appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService, AaiService, PnfService, CrService, AsdcService, $q, featureFlags, _, CreationService, $window) {\r
+    appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, $uibModal, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService, AaiService, PnfService, CrService, AsdcService, $q, featureFlags, _, CreationService, $window, DeleteResumeService) {\r
         $scope.popup = new Object();\r
         $scope.defaultBaseUrl = "";\r
         $scope.responseTimeoutMsec = 60000;\r
             // takes a default value, retrieves the prop value from the file system and sets it\r
             var polls = PropertyService.retrieveMsoMaxPolls();\r
             PropertyService.setMsoMaxPolls(polls);\r
+        };\r
 \r
-            PropertyService.setServerResponseTimeoutMsec(30000);\r
-\r
-            /*\r
-             * Common parameters that shows an example of how the view edit screen\r
-             * is expected to pass some common service instance values to the\r
-             * popups.\r
-             */\r
-\r
-//            DataService.setSubscriberName("Mobility");\r
-//            DataService.setGlobalCustomerId("CUSTID12345")\r
-//            DataService.setServiceType("Mobility Type 1");\r
-//            DataService.setServiceInstanceName("Example Service Instance Name");\r
-//            DataService.setServiceName("Mobility Service 1");\r
-//            DataService.setServiceInstanceId("mmsc-test-service-instance");\r
-//            DataService.setServiceUuid("XXXX-YYYY-ZZZZ");\r
-//            DataService.setUserServiceInstanceName("USER_SERVICE_INSTANCE_NAME");\r
-\r
-        }\r
-\r
-        //PropertyService.setMsoBaseUrl("testmso");\r
 \r
         $scope.convertModel = function (asdcModel) {\r
             if (!asdcModel) return undefined;\r
             DataService.setServiceUuid($scope.service.model.service.uuid);\r
         }\r
 \r
-        $scope.deleteVfModule = function (serviceObject, vfModule, vnf) {\r
+        var modalInstance;\r
 \r
-            console.log("Removing VF-Module " + vfModule.name);\r
+        var openMsoModal = function (msoType, requestParams, callbackFunction, configuration) {\r
+             modalInstance = $uibModal.open({\r
+                templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html',\r
+                controller: "msoCommitModalController",\r
+                backdrop: false,\r
+                resolve: {\r
+                    msoType: function () {\r
+                        return msoType;\r
+                    },\r
+                    requestParams: function () {\r
+                        requestParams.callbackFunction = callbackFunction;\r
+                        return requestParams;\r
+                    },\r
+                    configuration: function () {\r
+                        return configuration;\r
+                    }\r
+                }\r
+            });\r
+        };\r
 \r
-            populate_popup_vfModule(serviceObject, vfModule, vnf);\r
+        var openVfModuleWithHomingDataModal = function(action, vfModule)  {\r
+            modalInstance = $uibModal.open({\r
+                controller: 'vfModuleActionModalController',\r
+                templateUrl: 'app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html',\r
+                backdrop: false,\r
+                resolve: {\r
+                    action: function () {\r
+                        return action;\r
+                    },\r
+                    vfModule: function() {\r
+                        return vfModule;\r
+                    }\r
+                }\r
+            });\r
 \r
-            $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {\r
-                componentId: COMPONENT.VF_MODULE,\r
-                callbackFunction: deleteOrResumeCallback,\r
-                dialogMethod: COMPONENT.DELETE\r
+            modalInstance.result.then(function (data) {\r
+                if (data.msoType && data.requestParams) {\r
+                    openMsoModal(data.msoType, data.requestParams, deleteOrResumeCallback, null);\r
+                }\r
             });\r
+        };\r
 \r
-            return;\r
+        function getLcpCloudRegionTenantList() {\r
+            AaiService.getLcpCloudRegionTenantList(DataService\r
+                .getGlobalCustomerId(), DataService.getServiceType(), function(\r
+                response) {\r
+                $scope.lcpAndTenant = response;\r
+                $scope.isFeatureFlagCloudOwner = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST);\r
+                $scope.lcpRegionList = _.uniqBy(response, 'cloudRegionId');\r
+            });\r
+        }\r
 \r
+        $scope.deleteVfModule = function (serviceObject, vfModule, vnf) {\r
+            $scope.isSoftDeleteEnabled = true;\r
+\r
+            populate_popup_vfModule(serviceObject, vfModule, vnf);\r
+\r
+            if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE))  {\r
+\r
+                if (DataService.getLoggedInUserId())  {\r
+                    openVfModuleWithHomingDataModal(COMPONENT.DELETE, vfModule);\r
+                }\r
+                else {\r
+                    AaiService.getLoggedInUserID(function (response) {\r
+                        var userID = response.data;\r
+                        DataService.setLoggedInUserId(userID);\r
+                        openVfModuleWithHomingDataModal(COMPONENT.DELETE, vfModule);\r
+                    });\r
+                }\r
+            }\r
+            else {\r
+                $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {\r
+                    componentId: COMPONENT.VF_MODULE,\r
+                    callbackFunction: deleteOrResumeCallback,\r
+                    dialogMethod: COMPONENT.DELETE\r
+                });\r
+            }\r
+            console.log("Removing VF-Module", vfModule);\r
         };\r
 \r
         function setCurrentServiceModelInfoFromScope() {\r
             setCurrentVNFModelInfo(vnfModel);\r
             DataService.setVfModuleInstanceName(vfModule.object[FIELD.ID.VF_MODULE_NAME]);\r
             setCurrentServiceModelInfoFromScope();\r
-            $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {\r
-                componentId: COMPONENT.VF_MODULE,\r
-                callbackFunction: deleteOrResumeCallback,\r
-                dialogMethod: COMPONENT.RESUME\r
-            });\r
+\r
+            if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE))  {\r
+\r
+                if (DataService.getLoggedInUserId())  {\r
+                    openVfModuleWithHomingDataModal(COMPONENT.RESUME, vfModule);\r
+                }\r
+                else {\r
+                    AaiService.getLoggedInUserID(function (response) {\r
+                        var userID = response.data;\r
+                        DataService.setLoggedInUserId(userID);\r
+                        openVfModuleWithHomingDataModal(COMPONENT.RESUME, vfModule);\r
+                    });\r
+                }\r
+            }\r
+            else {\r
+                $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {\r
+                    componentId: COMPONENT.VF_MODULE,\r
+                    callbackFunction: deleteOrResumeCallback,\r
+                    dialogMethod: COMPONENT.RESUME\r
+                });\r
+            }\r
         };\r
 \r
         $scope.deleteConfiguration = function (serviceObject, configuration) {\r