Included Policy GUI Enhancements and validations
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / policy-models / Editor / js / controllers / policySearchManager.js
index 83c3820..42e6796 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * ECOMP Policy Engine
+ * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -58,11 +58,11 @@ app.controller('PolicySearchController', [
                console.log("failed");
         });
 
-        PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function(data){
+        PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function(data){
                var j = data;
                $scope.data = JSON.parse(j.data);
                console.log($scope.data);
-               $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);     
+               $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);       
         }, function (error) {
                console.log("failed");
         });
@@ -157,31 +157,38 @@ app.controller('PolicySearchController', [
             return currentPath.indexOf(path) !== -1;
         };
        
-           $scope.searchPolicy = function(searchContent){
-                   var deferred = $q.defer();
-           var uuu = "searchPolicy";
-           var postData = {searchdata : searchContent};
-           $.ajax({
-               type : 'POST',
-               url : uuu,
-               dataType: 'json',
-               contentType: 'application/json',
-               data: JSON.stringify(postData),
-               success : function(data){
-                   $scope.$apply(function(){
-                      var searchdata = data.result;
-                       if(searchdata.length > 0){
-                          $scope.policyNavigator.searchrefresh(searchdata);
-                       }else{
-                          Notification.info("No Matches Found with your Search");
-                       }
-                   });     
-               },
-               error : function(data){
-                   alert("Error while Searching.");
-               }
-           });
-       };
+        $scope.searchPolicy = function(searchContent){
+               if(searchContent != undefined){
+                       var uuu = "searchPolicy";
+                       var postData = {searchdata : searchContent};
+                       $.ajax({
+                               type : 'POST',
+                               url : uuu,
+                               dataType: 'json',
+                               contentType: 'application/json',
+                               data: JSON.stringify(postData),
+                               success : function(data){
+                                       $scope.$apply(function(){
+                                               var searchdata = data.result;
+                                               if(searchdata.length > 0){
+                                                       if(searchdata[0] == "Exception"){
+                                                               Notification.error(searchdata[1]);
+                                                       }else{
+                                                               $scope.policyNavigator.searchrefresh(searchdata);  
+                                                       }
+                                               }else{
+                                                       Notification.info("No Matches Found with your Search");
+                                               }
+                                       });     
+                               },
+                               error : function(data){
+                                       Notification.error("Error while Searching.");
+                               }
+                       });
+               }else{
+                       Notification.error("No data has been entered or selected to search");
+               }
+        };
        
        $scope.refresh = function(searchData){
           $scope.policyNavigator.searchrefresh(null);