2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 app.controller('editPDPGrouppopupController' , function ($scope, $modalInstance, message, modalService, $modal, Notification){
21 if(message.pdpGroupData==null){
22 $scope.label='Add New PDP Group'
24 $scope.label='Edit PDP Group'
25 $scope.disableCd=true;
26 $scope.policies = message.pdpGroupData.policies;
27 $scope.pdps = message.pdpGroupData.pdps;
28 $scope.selectedPdp = message.pdpGroupData;
31 $scope.editPDPGroup = message.pdpGroupData;
33 $scope.policiesGrid = {
35 enableFiltering: true,
37 { field: 'root', displayName : 'Root', width : '10%'},
38 { field: 'name', displayName : 'Name' },
39 { field: 'version' , width : '10%'},
46 enableFiltering: true,
48 field: 'id', enableFiltering: false, headerCellTemplate: '' +
49 '<button id=\'New\' ng-click="grid.appScope.createNewPDPInGroup()" class="btn btn-success">' + 'Create PDP</button>',
51 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editPDPInGroup(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
52 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deletePDPFromGroup(row.entity)" ><i class="fa fa-trash-o"></i></button> '+
53 '<button type="button" class="btn btn-success" ng-click="grid.appScope.statusOfPDP(row.entity.status)" >Status</button>', width: '25%'
55 { field: 'id', displayName : 'PDP URL'},
56 { field: 'jmxPort', displayName : 'JMX Port' , width : '10%' },
57 { field: 'name' , displayName : 'PDP Name'},
58 { field: 'description' }
62 $scope.createNewPDPInGroup = function(pdpInGroup) {
63 $scope.pdpInGroup = null;
64 var modalInstance = $modal.open({
65 backdrop: 'static', keyboard: false,
66 templateUrl : 'create_newPDP_InGroup.html',
67 controller: 'pdpInGroupController',
69 message: function () {
71 data: $scope.pdpInGroup,
72 activePDP : $scope.selectedPdp
78 modalInstance.result.then(function(response){
79 console.log('response', response);
80 refreshPDPGroupDatas(response);
84 $scope.editPDPInGroup = function(pdpInGroup) {
85 $scope.editPDPInGroupData = pdpInGroup;
86 var modalInstance = $modal.open({
87 backdrop: 'static', keyboard: false,
88 templateUrl: 'create_newPDP_InGroup.html',
89 controller: 'pdpInGroupController',
91 message: function () {
93 pdpInGroup : $scope.editPDPInGroupData,
94 activePDP : $scope.selectedPdp
100 modalInstance.result.then(function(response){
101 console.log('response', response);
102 refreshPDPGroupDatas(response);
106 $scope.deletePDPFromGroup = function(data){
107 modalService.popupConfirmWin("Confirm","You are about to delete the PDP Group : "+data.name+". Do you want to continue?",
109 var uuu = "pdp_Group/remove_pdpFromGroup.htm";
110 var postData={data: data,
111 activePDP : $scope.selectedPdp};
116 contentType: 'application/json',
117 data: JSON.stringify(postData),
118 success : function(data){
119 $scope.$apply(function(){
120 refreshPDPGroupDatas(data);
122 Notification.success("PDP Group Deleted Successfully");
124 error : function(data){
126 Notification.error("Error Occured While Deleting a PDP Group");
132 $scope.statusOfPDP = function(status){
133 $scope.pdpStatus = status;
134 console.log($scope.pdpStatus);
135 var modalInstance = $modal.open({
136 backdrop: 'static', keyboard: false,
137 templateUrl: 'pdpGroupStatusWindow.html',
138 controller: 'pdpGroupStatusController',
140 message: function () {
142 status : $scope.pdpStatus,
143 policies : $scope.policies
149 modalInstance.result.then(function(response){
150 console.log('response', response);
151 $scope.data=response.data;
155 $scope.savePDPGroup = function(pdpGroupData) {
156 var uuu = "pdp_Group/save_pdp_group.htm";
157 var postData={pdpGroupData: pdpGroupData};
162 contentType: 'application/json',
163 data: JSON.stringify(postData),
164 success : function(data){
165 $scope.$apply(function(){
166 $scope.data=data.data;});
167 console.log($scope.data);
168 $modalInstance.close({data:$scope.data});
170 error : function(data){
171 Notification.error("Error while saving PDP Group.");
176 function refreshPDPGroupDatas(response){
177 $scope.selectedPDPName = $scope.selectedPdp.id;
178 if(response != undefined){
179 $scope.data = JSON.parse(response.data);
180 for(var i=0; i< $scope.data.length; i++){
181 if($scope.data[i].id === $scope.selectedPDPName){
182 $scope.policies = $scope.data[i].policies;
183 $scope.pdps = $scope.data[i].pdps;
189 $scope.close = function() {
190 $modalInstance.close();