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('editPSGroupPolicyScopeController' , function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
22 if(message.groupPolicyScopeListData==null)
23 $scope.label='Add New Group Policy Scope'
25 $scope.label='Edit Group Policy Scope'
26 $scope.disableCd=true;
30 PolicyAppService.getData('getDictionary/get_PSServiceDataByName').then(function (data) {
32 $scope.data = JSON.parse(j.data);
33 console.log($scope.data);
34 $scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
35 console.log($scope.psServiceDictionaryDatas);
37 console.log("failed");
40 PolicyAppService.getData('getDictionary/get_PSTypeDataByName').then(function (data) {
42 $scope.data = JSON.parse(j.data);
43 console.log($scope.data);
44 $scope.psTypeDictionaryDatas = JSON.parse($scope.data.psTypeDictionaryDatas);
45 console.log($scope.psTypeDictionaryDatas);
47 console.log("failed");
50 PolicyAppService.getData('getDictionary/get_PSResourceDataByName').then(function (data) {
52 $scope.data = JSON.parse(j.data);
53 console.log($scope.data);
54 $scope.psResourceDictionaryDatas = JSON.parse($scope.data.psResourceDictionaryDatas);
55 console.log($scope.psResourceDictionaryDatas);
57 console.log("failed");
60 PolicyAppService.getData('getDictionary/get_PSClosedLoopDataByName').then(function (data) {
62 $scope.data = JSON.parse(j.data);
63 console.log($scope.data);
64 $scope.psClosedLoopDictionaryDatas = JSON.parse($scope.data.psClosedLoopDictionaryDatas);
65 console.log($scope.psClosedLoopDictionaryDatas);
67 console.log("failed");
70 /*getting user info from session*/
72 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
73 .then(function (response) {
74 userid = response.userid;
77 $scope.editPSGroupPolicyScope = message.groupPolicyScopeListData;
78 $scope.editPSGroupPolicyScope1 = {resource: [], type:[], service: [], closedloop: []};
80 if(message.groupPolicyScopeListData.groupList != null){
81 var splitValue = message.groupPolicyScopeListData.groupList.split(",");
82 console.log(splitValue);
83 $scope.splittedGroupListValues = [];
84 var splitResource = splitValue[0].split("=");
85 $scope.editPSGroupPolicyScope1.resource.push(splitResource[1]);
86 var splitType = splitValue[1].split("=");
87 $scope.editPSGroupPolicyScope1.type.push(splitType[1]);
88 var splitService = splitValue[2].split("=");
89 $scope.editPSGroupPolicyScope1.service.push(splitService[1]);
90 var splitCloop = splitValue[3].split("=");
91 $scope.editPSGroupPolicyScope1.closedloop.push(splitCloop[1]);
95 $scope.savePSGroupPolicyScope = function(groupPolicyScopeListData, groupPolicyScopeListData1) {
96 var regex = new RegExp("^[a-zA-Z0-9_]*$");
97 if(!regex.test(groupPolicyScopeListData.groupName)) {
98 Notification.error("Enter Valid Policy Scope Group Name without spaces or special characters");
100 console.log(groupPolicyScopeListData1);
101 if(groupPolicyScopeListData1.resource[0] != undefined && groupPolicyScopeListData1.type[0] != undefined && groupPolicyScopeListData1.service[0] != undefined && groupPolicyScopeListData1.closedloop[0] != undefined){
102 var uuu = "saveDictionary/ps_dictionary/save_psGroupPolicyScope";
103 var postData={groupPolicyScopeListData: groupPolicyScopeListData,
104 groupPolicyScopeListData1: groupPolicyScopeListData1, userid: userid};
109 contentType: 'application/json',
110 data: JSON.stringify(postData),
111 success : function(data){
112 $scope.$apply(function(){
113 $scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
114 if($scope.groupPolicyScopeListDatas == "Duplicate"){
115 Notification.error("GroupPolicyScope Dictionary exists with Same Group Name.")
116 }else if($scope.groupPolicyScopeListDatas == "DuplicateGroup"){
117 Notification.error("GroupPolicyScope Dictionary exists with Same Group List.")
119 console.log($scope.groupPolicyScopeListDatas);
120 $modalInstance.close({groupPolicyScopeListDatas:$scope.groupPolicyScopeListDatas});
123 error : function(data){
124 Notification.error("Error while saving.");
128 Notification.error("Please Select all the required fields to Save");
133 $scope.close = function() {
134 $modalInstance.close();