Fixed SonarIssues Alerts to Bootstrap Notification
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / dictionaryController / EnforcerDictController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 var editEnforcerTypeController =  function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){
21     if(message.enforcerDictionaryData==null)
22         $scope.label='Add Enforcing Type'
23     else{
24         $scope.label='Edit Enforcing Type'
25         $scope.disableCd=true;
26     }
27     $scope.editEnforcerType = message.enforcerDictionaryData;
28     
29     /*getting user info from session*/
30     var userid = null;
31     UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
32           .then(function (response) {              
33               userid = response.userid;          
34      });
35     
36     $scope.saveEnforcerType = function(enforcerDictionaryData) {
37         var uuu = "saveDictionary/enforcer_dictionary/save_enforcerType";
38         var postData={enforcerDictionaryData: enforcerDictionaryData, userid: userid};
39         $.ajax({
40             type : 'POST',
41             url : uuu,
42             dataType: 'json',
43             contentType: 'application/json',
44             data: JSON.stringify(postData),
45             success : function(data){
46                 $scope.$apply(function(){
47                     $scope.enforcerDictionaryDatas=data.enforcerDictionaryDatas;});
48                 console.log($scope.enforcerDictionaryDatas);
49                 $modalInstance.close({enforcerDictionaryDatas:$scope.enforcerDictionaryDatas});
50             },
51             error : function(data){
52                 Notification.error("Error while saving.");
53             }
54         });
55     };
56
57     $scope.close = function() {
58         $modalInstance.close();
59     };
60 }