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