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 var editPSGroupPolicyScopeController = function ($scope, $modalInstance, message, PolicyScopeService, PapUrlService, UserInfoService, Notification){
25 if(message.groupPolicyScopeListData==null)
26 $scope.label='Add New Group Policy Scope'
28 $scope.label='Edit Group Policy Scope'
29 $scope.disableCd=true;
34 PapUrlService.getPapUrl().then(function(data) {
36 papUrl = config.PAP_URL;
39 PolicyScopeService.getPSServiceDictionaryDataByName(papUrl).then(function (data) {
41 $scope.data = JSON.parse(j.data);
42 console.log($scope.data);
43 $scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
44 console.log($scope.psServiceDictionaryDatas);
46 console.log("failed");
49 PolicyScopeService.getPSTypeDictionaryDataByName(papUrl).then(function (data) {
51 $scope.data = JSON.parse(j.data);
52 console.log($scope.data);
53 $scope.psTypeDictionaryDatas = JSON.parse($scope.data.psTypeDictionaryDatas);
54 console.log($scope.psTypeDictionaryDatas);
56 console.log("failed");
59 PolicyScopeService.getPSResourceDictionaryDataByName(papUrl).then(function (data) {
61 $scope.data = JSON.parse(j.data);
62 console.log($scope.data);
63 $scope.psResourceDictionaryDatas = JSON.parse($scope.data.psResourceDictionaryDatas);
64 console.log($scope.psResourceDictionaryDatas);
66 console.log("failed");
69 PolicyScopeService.getPSClosedLoopDictionaryDataByName(papUrl).then(function (data) {
71 $scope.data = JSON.parse(j.data);
72 console.log($scope.data);
73 $scope.psClosedLoopDictionaryDatas = JSON.parse($scope.data.psClosedLoopDictionaryDatas);
74 console.log($scope.psClosedLoopDictionaryDatas);
76 console.log("failed");
80 /*getting user info from session*/
82 UserInfoService.getFunctionalMenuStaticDetailSession()
83 .then(function (response) {
84 loginId = response.userid;
87 $scope.editPSGroupPolicyScope = message.groupPolicyScopeListData;
88 $scope.editPSGroupPolicyScope1 = {resource: [], type:[], service: [], closedloop: []};
90 if(message.groupPolicyScopeListData.groupList != null){
91 var splitValue = message.groupPolicyScopeListData.groupList.split(",");
92 console.log(splitValue);
93 $scope.splittedGroupListValues = [];
94 var splitResource = splitValue[0].split("=");
95 $scope.editPSGroupPolicyScope1.resource.push(splitResource[1]);
96 var splitType = splitValue[1].split("=");
97 $scope.editPSGroupPolicyScope1.type.push(splitType[1]);
98 var splitService = splitValue[2].split("=");
99 $scope.editPSGroupPolicyScope1.service.push(splitService[1]);
100 var splitCloop = splitValue[3].split("=");
101 $scope.editPSGroupPolicyScope1.closedloop.push(splitCloop[1]);
105 $scope.savePSGroupPolicyScope = function(groupPolicyScopeListData, groupPolicyScopeListData1) {
106 console.log(groupPolicyScopeListData1);
107 var uuu = papUrl + "/ecomp/ps_dictionary/save_psGroupPolicyScope.htm";
108 var postData={groupPolicyScopeListData: groupPolicyScopeListData,
109 groupPolicyScopeListData1: groupPolicyScopeListData1, loginId: loginId};
114 contentType: 'application/json',
115 data: JSON.stringify(postData),
116 success : function(data){
117 $scope.$apply(function(){
118 $scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
119 if($scope.groupPolicyScopeListDatas == "Duplicate"){
120 Notification.error("GroupPolicyScope Dictionary exists with Same Group Name.")
121 }else if($scope.groupPolicyScopeListDatas == "DuplicateGroup"){
122 Notification.error("GroupPolicyScope Dictionary exists with Same Group List.")
124 console.log($scope.groupPolicyScopeListDatas);
125 $modalInstance.close({groupPolicyScopeListDatas:$scope.groupPolicyScopeListDatas});
128 error : function(data){
129 alert("Error while saving.");
134 $scope.close = function() {
135 $modalInstance.close();