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 editSafePolicyWarningController = function ($scope, $modalInstance, message, SafePolicyService, PapUrlService, UserInfoService, Notification){
25 if(message.safePolicyWarningData==null)
26 $scope.label='Add New Safe Policy Warning'
28 $scope.label='Edit Safe Policy Warning'
29 $scope.disableCd=true;
34 PapUrlService.getPapUrl().then(function(data) {
36 papUrl = config.PAP_URL;
39 SafePolicyService.getSafePolicyWarningDictionaryDataByName(papUrl).then(function (data) {
41 $scope.data = JSON.parse(j.data);
42 console.log($scope.data);
43 $scope.safePolicyWarningDatas = JSON.parse($scope.data.safePolicyWarningDatas);
44 console.log($scope.safePolicyWarningDatas);
46 console.log("failed");
48 SafePolicyService.getRiskTypeDictionaryDataByName(papUrl).then(function (data) {
50 $scope.data = JSON.parse(j.data);
51 console.log($scope.data);
52 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
53 console.log($scope.riskTypeDictionaryDatas);
55 console.log("failed");
59 /*getting user info from session*/
61 UserInfoService.getFunctionalMenuStaticDetailSession()
62 .then(function (response) {
63 loginId = response.userid;
66 $scope.editSafePolicyWarning = message.safePolicyWarningData;
67 $scope.editSafePolicyWarning1 = {resource: [], type:[], service: [], closedloop: []};
69 if(message.safePolicyWarningData.groupList != null){
70 var splitValue = message.safePolicyWarningData.groupList.split(",");
71 console.log(splitValue);
72 $scope.splittedGroupListValues = [];
73 var splitResource = splitValue[0].split("=");
74 $scope.editSafePolicyWarningScope1.riskType.push(splitResource[1]);
78 $scope.saveSafePolicyWarning = function(safePolicyWarningData) {
79 console.log(safePolicyWarningData);
80 var uuu = papUrl + "/ecomp/sp_dictionary/save_safePolicyWarning.htm";
81 var postData={safePolicyWarningData: safePolicyWarningData, loginId: loginId};
86 contentType: 'application/json',
87 data: JSON.stringify(postData),
88 success : function(data){
89 $scope.$apply(function(){
90 $scope.safePolicyWarningDatas=data.safePolicyWarningDatas;});
91 if($scope.safePolicyWarningDatas == "Duplicate"){
92 Notification.error("Safe Policy Dictionary exists with Same Name.")
94 console.log($scope.safePolicyWarningDatas);
95 $modalInstance.close({safePolicyWarningDatas:$scope.safePolicyWarningDatas});
98 error : function(data){
99 alert("Error while saving.");
104 $scope.close = function() {
105 $modalInstance.close();