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('editSafePolicyWarningController' , function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
22 if(message.safePolicyWarningData==null)
23 $scope.label='Add New Safe Policy Warning'
25 $scope.label='Edit Safe Policy Warning'
26 $scope.disableCd=true;
30 PolicyAppService.getData('getDictionary/get_SafePolicyWarningDataByName').then(function (data) {
32 $scope.data = JSON.parse(j.data);
33 console.log($scope.data);
34 $scope.safePolicyWarningDatas = JSON.parse($scope.data.safePolicyWarningDatas);
35 console.log($scope.safePolicyWarningDatas);
37 console.log("failed");
40 PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
42 $scope.data = JSON.parse(j.data);
43 console.log($scope.data);
44 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
45 console.log($scope.riskTypeDictionaryDatas);
47 console.log("failed");
50 /*getting user info from session*/
52 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
53 .then(function (response) {
54 userid = response.userid;
57 $scope.editSafePolicyWarning = message.safePolicyWarningData;
58 $scope.editSafePolicyWarning1 = {resource: [], type:[], service: [], closedloop: []};
60 if(message.safePolicyWarningData.groupList != null){
61 var splitValue = message.safePolicyWarningData.groupList.split(",");
62 console.log(splitValue);
63 $scope.splittedGroupListValues = [];
64 var splitResource = splitValue[0].split("=");
65 $scope.editSafePolicyWarningScope1.riskType.push(splitResource[1]);
69 $scope.saveSafePolicyWarning = function(safePolicyWarningData) {
70 var regex = new RegExp("^[a-zA-Z0-9_]*$");
71 if(!regex.test(safePolicyWarningData.name)) {
72 Notification.error("Enter Valid Safe Policy Warning Name without spaces or special characters");
74 console.log(safePolicyWarningData);
75 var uuu = "saveDictionary/sp_dictionary/save_safePolicyWarning";
76 var postData={safePolicyWarningData: safePolicyWarningData, userid: userid};
81 contentType: 'application/json',
82 data: JSON.stringify(postData),
83 success : function(data){
84 $scope.$apply(function(){
85 $scope.safePolicyWarningDatas=data.safePolicyWarningDatas;});
86 if($scope.safePolicyWarningDatas == "Duplicate"){
87 Notification.error("Safe Policy Dictionary exists with Same Name.")
89 console.log($scope.safePolicyWarningDatas);
90 $modalInstance.close({safePolicyWarningDatas:$scope.safePolicyWarningDatas});
93 error : function(data){
94 alert("Error while saving.");
100 $scope.close = function() {
101 $modalInstance.close();