[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / PDPTabController / AddorEditPdpInGroup.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('pdpInGroupController' ,  function ($scope, $modalInstance, message, Notification){
21         $scope.edit = 'false';
22     if(message.pdpInGroup==null)
23         $scope.label='Add PDP to Group'
24     else{
25         $scope.label='Edit PDP In Group'
26         $scope.disableCd=true;
27         $scope.edit = 'true';
28     }
29     $scope.editPDPInGroup = message.pdpInGroup;
30     $scope.editActivePDP = message.activePDP;
31     
32     $scope.savePDPInGroup = function(pdpInGroup) {
33         var uuu = "pdp_Group/save_pdpTogroup.htm";
34         var postData={pdpInGroup: pdpInGroup,
35                         activePDP: $scope.editActivePDP,
36                         update : $scope.edit};
37         $.ajax({
38             type : 'POST',
39             url : uuu,
40             dataType: 'json',
41             contentType: 'application/json',
42             data: JSON.stringify(postData),
43             success : function(data){
44                 $scope.$apply(function(){
45                     $scope.data=data.data;});
46                 console.log($scope.data);
47                 $modalInstance.close({data:$scope.data});
48             },
49             error : function(data){
50                Notification.error("Error Occured while Creating/Updating a PDP Group");
51             }
52         });
53     };
54
55     $scope.close = function() {
56         $modalInstance.close();
57     };
58 });
59