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=========================================================
23 app.controller('psGroupPolicyScopeDictGridController', function ($scope, PolicyScopeService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 PolicyScopeService.getPSGroupPolicyScopeDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.groupPolicyScopeListDatas = JSON.parse($scope.data.groupPolicyScopeListDatas);
37 console.log($scope.groupPolicyScopeListDatas);
39 console.log("failed");
44 $scope.psGroupPolicyScopeDictionaryGrid = {
45 data : 'groupPolicyScopeListDatas',
46 enableFiltering: true,
48 field: 'id', enableFiltering: false, headerCellTemplate: '' +
49 '<button id=\'New\' ng-click="grid.appScope.createNewGroupPolicyScopeWindow()" class="btn btn-success">' + 'Create</button>',
51 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editGroupPolicyScopeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
52 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteGroupPolicyScope(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
53 },{ field: 'groupName', displayName : 'Policy Scope Group Name'},
54 { field: 'groupList', displayName : 'Policy Scope List'}
56 onRegisterApi: function(gridApi){
57 $scope.gridApi = gridApi;
58 $scope.gridApi.core.refresh();
62 $scope.editPSGroupPolicyScope = null;
63 $scope.createNewGroupPolicyScopeWindow = function(){
64 $scope.editPSGroupPolicyScope = null;
65 var modalInstance = $modal.open({
66 backdrop: 'static', keyboard: false,
67 templateUrl : 'add_PSGroupPolicyScope_popup.html',
68 controller: 'editPSGroupPolicyScopeController',
70 message: function () {
72 groupPolicyScopeListDatas: $scope.editPSGroupPolicyScope
78 modalInstance.result.then(function(response){
79 console.log('response', response);
80 $scope.groupPolicyScopeListDatas=response.groupPolicyScopeListDatas;
84 $scope.editGroupPolicyScopeWindow = function(groupPolicyScopeListData) {
85 $scope.editPSGroupPolicyScope = groupPolicyScopeListData;
86 var modalInstance = $modal.open({
87 backdrop: 'static', keyboard: false,
88 templateUrl : 'add_PSGroupPolicyScope_popup.html',
89 controller: 'editPSGroupPolicyScopeController',
91 message: function () {
93 groupPolicyScopeListData: $scope.editPSGroupPolicyScope
99 modalInstance.result.then(function(response){
100 console.log('response', response);
101 $scope.groupPolicyScopeListDatas = response.groupPolicyScopeListDatas;
105 $scope.deleteGroupPolicyScope = function(data) {
106 modalService.popupConfirmWin("Confirm","You are about to delete the Group Policy Scope "+data.name+". Do you want to continue?",
108 var uuu = papUrl + "/ecomp/ps_dictionary/remove_GroupPolicyScope.htm";
109 var postData={data: data};
114 contentType: 'application/json',
115 data: JSON.stringify(postData),
116 success : function(data){
117 $scope.$apply(function(){$scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
119 error : function(data){
121 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);