Merge "identify macro services without instantiation type in BE by feature flag"
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / aaiSubscriberController.js
index 16ec01d..110f24e 100755 (executable)
 appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "$uibModal", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService", "OwningEntityService", "AsdcService","featureFlags", "$q", "_",\r
     function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, AsdcService, featureFlags, $q, _) {\r
 \r
+        $scope.showReportWindow = function() {\r
+            let GuiMessage;\r
+\r
+            if ($scope.errorMsg !== undefined && $scope.errorMsg !== null) {\r
+                GuiMessage = $scope.errorMsg;\r
+            } else {\r
+                GuiMessage = $scope.status;\r
+            }\r
+\r
+            const modalWindow = $uibModal.open({\r
+                templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',\r
+                controller: 'reportModalController',\r
+                controllerAs: 'vm',\r
+                resolve: {\r
+                    errorMsg: function () {\r
+                        return GuiMessage;\r
+                    }\r
+                }\r
+            });\r
+        };\r
+\r
         $scope.showVnfDetails = function (vnf) {\r
             console.log("showVnfDetails");\r
             DataService.setVnfInstanceId(COMPONENT.VNF_INSTANCE_ID);\r
@@ -34,7 +55,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 componentId: COMPONENT.VNF,\r
                 callbackFunction: callbackFunction\r
             });\r
-        }\r
+        };\r
         $scope.popup = new Object();\r
 \r
 \r
@@ -64,18 +85,18 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
 \r
         $scope.getServiceTypes = function (globalCustomerId) {\r
             DataService.setGlobalCustomerId(globalCustomerId);\r
-            DataService.setServiceIdList($scope.customerList)\r
+            DataService.setServiceIdList($scope.customerList);\r
 \r
             if (globalCustomerId !== "" && globalCustomerId !== undefined) {\r
                 window.location.href = COMPONENT.SERVICE_TYPE_LIST_PATH + $scope.serviceTypeList;\r
             }\r
-        }\r
+        };\r
 \r
         $scope.refreshServiceTypes = function (globalCustomerId) {\r
             DataService.setGlobalCustomerId(globalCustomerId);\r
 \r
             $scope.getServiceTypesList();\r
-        }\r
+        };\r
 \r
         $scope.subId = "";\r
         $scope.createSubscriberName = "";\r
@@ -117,7 +138,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
         $scope.subList = [];\r
         $scope.getAaiServiceModels = function (selectedServicetype, subName) {\r
             DataService.setGlobalCustomerId(selectedServicetype);\r
-            DataService.setServiceIdList($scope.serviceTypeList)\r
+            DataService.setServiceIdList($scope.serviceTypeList);\r
             DataService.setSubscriberName(subName);\r
 \r
             DataService.setSubscribers($scope.custSubList);\r
@@ -326,12 +347,12 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 callbackFunction: function (response) {\r
                 }\r
             });\r
-        }\r
+        };\r
         $scope.cancelCreateSIType = function () {\r
 \r
             window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH;\r
 \r
-        }\r
+        };\r
 \r
         $scope.fetchServices = function () {\r
             var serviceIdList = [];\r
@@ -374,12 +395,12 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 $scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status;\r
                 $scope.errorDetails = response.data;\r
             });\r
-        }\r
+        };\r
 \r
         $scope.getPermitted = function (item) {\r
             return item.isPermitted || item[FIELD.ID.IS_PERMITTED];\r
 \r
-        }\r
+        };\r
 \r
 \r
         $scope.getSubDetails = function () {\r
@@ -461,15 +482,14 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
             $scope.enableCloseButton(false);\r
             $scope.resetProgress();\r
             $scope.setProgress(2); // Show "a little" progress\r
-        }\r
+        };\r
 \r
         function getRelatedInstanceGroupsByVnfId(genericVnf) {\r
             var model = vidService.getModel();\r
             if (model && model.vnfs && !_.isEmpty(model.vnfs)) {\r
                 Object.keys(model.vnfs).forEach(function (key) {\r
                     var vnf = model.vnfs[key];\r
-                    if (vnf.vfcInstanceGroups && !_.isEmpty(vnf.vfcInstanceGroups)) {\r
-                        if (vnf.uuid === genericVnf.modelVersionId) {\r
+                    if (vnf.vfcInstanceGroups && !_.isEmpty(vnf.vfcInstanceGroups) && vnf.uuid === genericVnf.modelVersionId) {\r
                             AaiService.getInstanceGroupsByVNFInstanceId(genericVnf.nodeId,\r
                                 function (response) { //success\r
                                     handleGetRelatedInstanceGroupsResponseForVnf(response, genericVnf);\r
@@ -481,8 +501,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                                 }\r
                             )\r
                         }\r
-                    }\r
-                })\r
+                });\r
             }\r
         }\r
 \r
@@ -495,7 +514,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 return resolveIfIsPermitted()\r
                     .then(function() {\r
                         return getAsdcModelByVersionId(modelVersionId);\r
-                    })\r
+                    });\r
             }\r
         }\r
 \r
@@ -510,7 +529,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                         $scope.isPermitted = first.isPermitted;\r
                         deferred.resolve(first.isPermitted);\r
                     } else {\r
-                        deferred.reject("some error while resolveIfIsPermitted")\r
+                        deferred.reject("some error while resolveIfIsPermitted");\r
                     }\r
                 });\r
 \r
@@ -668,7 +687,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                     // the response is erroneous\r
                     console.log("aaiSubscriber getAsdcModel BAD RESPONSE");\r
                     errorCallback(response);\r
-                    return $q.reject()\r
+                    return $q.reject();\r
                 }\r
             }, errorCallback);\r
 \r
@@ -685,9 +704,9 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 if (item[FIELD.ID.SERVICE_INSTANCES] != null) {\r
                     item[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE].forEach(function (service) {\r
                         if (service[FIELD.ID.SERVICE_INSTANCE_ID] === serviceId) {\r
-                            orchStatus = service['orchestration-status']\r
+                            orchStatus = service['orchestration-status'];\r
                         }\r
-                    })\r
+                    });\r
                 }\r
             });\r
             return orchStatus;\r
@@ -701,12 +720,22 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 }, function (response) {\r
                     //TODO\r
                 });\r
-        }\r
+        };\r
 \r
         $scope.isConfigurationDataAvailiable = function (configuration) {\r
             $log.debug(configuration);\r
             return configuration.configData && (!configuration.configData.errorDescription);\r
-        }\r
+        };\r
+\r
+        $scope.allowConfigurationActions = function (configuration) {\r
+            $log.debug(configuration);\r
+            return configuration.nodeStatus &&\r
+                _.some(\r
+                    [FIELD.STATUS.AAI_ACTIVE, FIELD.STATUS.AAI_INACTIVE, FIELD.STATUS.AAI_CREATED],\r
+                    function (s) {\r
+                        return s.toLowerCase() === configuration.nodeStatus.toLowerCase();\r
+                    });\r
+        };\r
 \r
         $scope.isActivateDeactivateEnabled = function(btnType) {\r
             if ($scope.serviceOrchestrationStatus) {\r
@@ -728,6 +757,10 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
             return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_VERIFY_SERVICE);\r
         }\r
 \r
+        $scope.isShowErrorReport = function() {\r
+            return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);\r
+        }\r
+\r
         $scope.isEnableVerifyService = function () {\r
             //Button should only be enabled when the service type is A la carte\r
             if (DataService.getALaCarte()) {\r
@@ -762,11 +795,9 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
         };\r
 \r
         $scope.isShowAssignmentsEnabled = function () {\r
-            if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS)) {\r
-                if ($scope.serviceOrchestrationStatus) {\r
+            if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS) && $scope.serviceOrchestrationStatus) {\r
                     return $scope.serviceOrchestrationStatus.toLowerCase() === 'assigned';\r
                 }\r
-            }\r
             return false;\r
         };\r
 \r
@@ -782,8 +813,11 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
 \r
         $scope.isResumeShown = function (status) {\r
             var vfModuleStatus = status.toLowerCase();\r
-            var serviceStatus = $scope.serviceOrchestrationStatus && $scope.serviceOrchestrationStatus.toLowerCase();\r
-            return _.includes(['pendingactivation', 'assigned'], vfModuleStatus) && !$scope.isActivateDeactivateEnabled("activate");\r
+            var vfModuleStatusHasAllowedResume = ['pendingactivation', 'assigned'];\r
+            if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_VF_MODULE_RESUME_STATUS_CREATE)) {\r
+                vfModuleStatusHasAllowedResume.push('created');\r
+            }\r
+            return _.includes(vfModuleStatusHasAllowedResume, vfModuleStatus) && !$scope.isActivateDeactivateEnabled("activate");\r
         };\r
 \r
         $scope.handleInitialResponseInventoryItems = function (response) {\r
@@ -1021,7 +1055,6 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                                 if( !$scope.hasFabricConfigurations ) {\r
                                 portMirroringConfigurationIds.push(configObject[FIELD.ID.CONFIGURATION_ID]);\r
                                     $scope.service.instance[FIELD.ID.CONFIGURATIONS].push(config);\r
-                                $scope.allowConfigurationActions = [FIELD.STATUS.AAI_ACTIVE, FIELD.STATUS.AAI_INACTIVE, FIELD.STATUS.AAI_CREATED].indexOf(config.nodeStatus) != -1;\r
                                 } else {\r
                                    if (config.nodeStatus.toLowerCase() !== FIELD.STATUS.ASSIGNED.toLowerCase()) {\r
                                        $scope.allConfigurationsAssigned = false;\r