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=========================================================
24 angular.module("abs").controller('clPMController', function($scope, $window, $timeout, PapUrlService, ClosedLoopPMService, PolicyDictionaryService, modalService, $modal, Notification){
27 $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
29 PapUrlService.getPapUrl().then(function(data) {
31 papUrl = config.PAP_URL;
34 PolicyDictionaryService.getEcompDictionaryData(papUrl).then(function (data) {
36 $scope.data = JSON.parse(j.data);
37 console.log($scope.data);
38 $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
39 console.log($scope.ecompNameDictionaryDatas);
41 console.log("failed");
43 PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).then(function (data) {
45 $scope.data = JSON.parse(j.data);
46 console.log($scope.data);
47 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
48 console.log($scope.riskTypeDictionaryDatas);
50 console.log("failed");
52 PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
54 $scope.data = JSON.parse(j.data);
55 console.log($scope.data);
56 $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
57 console.log($scope.riskLevelDatas);
59 console.log("failed");
61 PolicyDictionaryService.getGuardValueData().then(function (data) {
63 $scope.data = JSON.parse(j.data);
64 console.log($scope.data);
65 $scope.guardDatas = JSON.parse($scope.data.guardDatas);
66 console.log($scope.guardDatas);
68 console.log("failed");
73 ClosedLoopPMService.getPMJSONBodyData().then(function(data){
78 $scope.temp.policy.verticaMetrics = [];
79 $scope.temp.policy.description = [];
80 $scope.temp.policy.attributes = [];
82 $scope.addDataToFields = function(serviceType){
83 if($scope.PMData == undefined){
84 $scope.temp.policy.verticaMetrics = [];
85 $scope.temp.policy.description = [];
86 $scope.temp.policy.attributes = [];
87 ClosedLoopPMService.getPMJSONBodyData().then(function(data){
90 if(serviceType.serviceTypePolicyName == 'Registration Failure(Trinity)'){
91 var myNewData = $scope.PMData[0];
92 }else if(serviceType.serviceTypePolicyName == 'International Fraud(Trinity)'){
93 var myNewData = $scope.PMData[1];
94 }else if(serviceType.serviceTypePolicyName == 'No dial tone(Trinity)'){
95 var myNewData = $scope.PMData[2];
96 }else if(serviceType.serviceTypePolicyName == 'Call storm(Trinity)'){
97 var myNewData = $scope.PMData[3];
98 }else if(serviceType.serviceTypePolicyName == 'Registration storm(Trinity)'){
99 var myNewData = $scope.PMData[4];
102 $scope.temp.policy.verticaMetrics = myNewData;
103 $scope.temp.policy.description = myNewData;
104 $scope.temp.policy.attributeFields = myNewData;
107 var key = $scope.PMData.indexOf(serviceType);
108 var myNewData = $scope.PMData[key];
109 $scope.temp.policy.verticaMetrics = myNewData;
110 $scope.temp.policy.description = myNewData;
111 $scope.temp.policy.attributeFields = myNewData;
116 $scope.saveCLPMPolicy = function(policy){
119 var uuu = "policyController/save_PMPolicy.htm";
120 var postData={policyData: policy};
125 contentType: 'application/json',
126 data: JSON.stringify(postData),
127 success : function(data){
128 $scope.$apply(function(){
129 $scope.data=data.data;
130 $scope.temp.policy.readOnly = 'true';
131 Notification.success("Policy Saved Successfully.");
133 console.log($scope.data);
134 $modalInstance.close();
137 error : function(data){
138 Notification.error("Error Occured while saving Policy.");
143 $scope.validatePolicy = function(policy){
145 var uuu = "policyController/validate_policy.htm";
146 var postData={policyData: policy};
151 contentType: 'application/json',
152 data: JSON.stringify(postData),
153 success : function(data){
154 $scope.$apply(function(){
155 $scope.data=data.data.substring(1,8);
156 var size = data.data.length;
157 if($scope.data == 'success'){
158 Notification.success("Validation Success.");
160 var displayWarning = data.data.substring(19,size);
161 window.alert(displayWarning);
164 Notification.error("Validation Failed.");
168 console.log($scope.data);
169 /*$modalInstance.close();*/
172 error : function(data){
173 Notification.error("Validation Failed.");