[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / policyAdminTabController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 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 app.controller("policyAdminController", function($scope, PolicyAppService, modalService, $modal, Notification){
21         $( "#dialog" ).hide();
22         
23         $scope.isDisabled = true;
24         PolicyAppService.getData('get_LockDownData').then(function(data){
25                 var j = data;
26                 $scope.data = JSON.parse(j.data);
27                 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
28                  if($scope.lockdowndata[0].lockdown == true){
29                          $scope.isDisabled = true;
30                  }else{
31                          $scope.isDisabled = false;
32                  }
33                 console.log($scope.data);
34         },function(error){
35                 console.log("failed");
36         });
37         
38          $scope.saveLockDownValue = function(lockdownValue){
39                 console.log(lockdownValue);
40                         if(lockdownValue == true){
41                                 Notification.success("Policy Application has been Locked Successfully");
42                                  $scope.isDisabled = true;
43                         }else{
44                                 Notification.success("Policy Application has been UnLocked Successfully");
45                                 $scope.isDisabled = false;
46                         }
47                 var uuu = "adminTabController/save_LockDownValue.htm";
48                         var postData={lockdowndata: {lockdown : lockdownValue}};
49                         $.ajax({
50                                 type : 'POST',
51                                 url : uuu,
52                                 dataType: 'json',
53                                 contentType: 'application/json',
54                                 data: JSON.stringify(postData),
55                                 success : function(data){
56                                         $scope.$apply(function(){
57                                                         $scope.data=data.data;
58                                         });
59                                         console.log($scope.data);
60                                 },
61                                 error : function(data){
62                                         alert("Error Occured while saving Lockdown Value.");
63                                 }
64                         });
65             };
66 });