2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 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' ,
21 function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
23 if(message.groupPolicyScopeListData==null)
24 $scope.label='Add New Group Policy Scope'
26 $scope.label='Edit Group Policy Scope'
27 $scope.disableCd=true;
31 PolicyAppService.getData('getDictionary/get_PSServiceDataByName').then(function (data) {
33 $scope.data = JSON.parse(j.data);
34 $scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
37 PolicyAppService.getData('getDictionary/get_PSTypeDataByName').then(function (data) {
39 $scope.data = JSON.parse(j.data);
40 $scope.psTypeDictionaryDatas = JSON.parse($scope.data.psTypeDictionaryDatas);
43 PolicyAppService.getData('getDictionary/get_PSResourceDataByName').then(function (data) {
45 $scope.data = JSON.parse(j.data);
46 $scope.psResourceDictionaryDatas = JSON.parse($scope.data.psResourceDictionaryDatas);
49 PolicyAppService.getData('getDictionary/get_PSClosedLoopDataByName').then(function (data) {
51 $scope.data = JSON.parse(j.data);
52 $scope.psClosedLoopDictionaryDatas = JSON.parse($scope.data.psClosedLoopDictionaryDatas);
55 /*getting user info from session*/
57 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
58 .then(function (response) {
59 userid = response.userid;
62 $scope.editPSGroupPolicyScope = message.groupPolicyScopeListData;
63 $scope.editPSGroupPolicyScope1 = {resource: [], type:[], service: [], closedloop: []};
65 if(message.groupPolicyScopeListData.groupList != null){
66 var splitValue = message.groupPolicyScopeListData.groupList.split(",");
67 $scope.splittedGroupListValues = [];
68 var splitResource = splitValue[0].split("=");
69 $scope.editPSGroupPolicyScope1.resource.push(splitResource[1]);
70 var splitType = splitValue[1].split("=");
71 $scope.editPSGroupPolicyScope1.type.push(splitType[1]);
72 var splitService = splitValue[2].split("=");
73 $scope.editPSGroupPolicyScope1.service.push(splitService[1]);
74 var splitCloop = splitValue[3].split("=");
75 $scope.editPSGroupPolicyScope1.closedloop.push(splitCloop[1]);
79 $scope.savePSGroupPolicyScope = function(groupPolicyScopeListData, groupPolicyScopeListData1) {
80 var regex = new RegExp("^[a-zA-Z0-9_]*$");
81 if(!regex.test(groupPolicyScopeListData.groupName)) {
82 Notification.error("Enter Valid Policy Scope Group Name without spaces or special characters");
84 if(groupPolicyScopeListData1.resource[0] != undefined && groupPolicyScopeListData1.type[0] != undefined && groupPolicyScopeListData1.service[0] != undefined && groupPolicyScopeListData1.closedloop[0] != undefined){
85 var uuu = "saveDictionary/ps_dictionary/save_psGroupPolicyScope";
86 var postData={groupPolicyScopeListData: groupPolicyScopeListData,
87 groupPolicyScopeListData1: groupPolicyScopeListData1, userid: userid};
92 contentType: 'application/json',
93 data: JSON.stringify(postData),
94 success : function(data){
95 $scope.$apply(function(){
96 $scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
97 if($scope.groupPolicyScopeListDatas == "Duplicate"){
98 Notification.error("GroupPolicyScope Dictionary exists with Same Group Name.")
99 }else if($scope.groupPolicyScopeListDatas == "DuplicateGroup"){
100 Notification.error("GroupPolicyScope Dictionary exists with Same Group List.")
102 $modalInstance.close({groupPolicyScopeListDatas:$scope.groupPolicyScopeListDatas});
105 error : function(data){
106 Notification.error("Error while saving.");
110 Notification.error("Please Select all the required fields to Save");
115 $scope.close = function() {
116 $modalInstance.close();