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 angular.module("abs").controller('clPMController', function($scope, $window, $timeout, PolicyAppService, modalService, $modal, Notification){
23 $scope.savebutton = true;
24 $scope.finalPath = null;
26 PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
28 $scope.data = JSON.parse(j.data);
29 console.log($scope.data);
30 $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
31 console.log($scope.ecompNameDictionaryDatas);
33 console.log("failed");
36 PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
38 $scope.data = JSON.parse(j.data);
39 console.log($scope.data);
40 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
41 console.log($scope.riskTypeDictionaryDatas);
43 console.log("failed");
47 PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
52 if($scope.temp.policy.readOnly && $scope.temp.policy.editPolicy){
53 $scope.temp.policy.verticaMetrics = [];
54 $scope.temp.policy.description = [];
55 $scope.temp.policy.attributes = [];
58 $scope.addDataToFields = function(serviceType){
59 if($scope.PMData == undefined){
60 $scope.temp.policy.verticaMetrics = [];
61 $scope.temp.policy.description = [];
62 $scope.temp.policy.attributes = [];
63 PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
66 if(serviceType.serviceTypePolicyName == 'Registration Failure(Trinity)'){
67 var myNewData = $scope.PMData[0];
68 }else if(serviceType.serviceTypePolicyName == 'International Fraud(Trinity)'){
69 var myNewData = $scope.PMData[1];
70 }else if(serviceType.serviceTypePolicyName == 'No dial tone(Trinity)'){
71 var myNewData = $scope.PMData[2];
72 }else if(serviceType.serviceTypePolicyName == 'Call storm(Trinity)'){
73 var myNewData = $scope.PMData[3];
74 }else if(serviceType.serviceTypePolicyName == 'Registration storm(Trinity)'){
75 var myNewData = $scope.PMData[4];
78 $scope.temp.policy.verticaMetrics = myNewData;
79 $scope.temp.policy.description = myNewData;
80 $scope.temp.policy.attributeFields = myNewData;
83 $scope.temp.policy.verticaMetrics = serviceType;
84 $scope.temp.policy.description = serviceType;
85 $scope.temp.policy.attributeFields = serviceType;
90 $scope.saveCLPMPolicy = function(policy){
92 $scope.savebutton = false;
93 var uuu = "policycreation/save_policy";
94 var postData={policyData: policy};
99 contentType: 'application/json',
100 data: JSON.stringify(postData),
101 success : function(data){
102 $scope.$apply(function(){
103 $scope.data=data.policyData;
104 if($scope.data == 'success'){
105 $scope.temp.policy.readOnly = 'true';
106 Notification.success("Policy Saved Successfully.");
107 }else if ($scope.data == 'PolicyExists'){
108 $scope.savebutton = true;
109 Notification.error("Policy Already Exists with Same Name in Scope.");
112 console.log($scope.data);
114 error : function(data){
115 Notification.error("Error Occured while saving Policy.");
120 $scope.validatePolicy = function(policy){
122 document.getElementById("validate").innerHTML = "";
123 var uuu = "policyController/validate_policy.htm";
124 var postData={policyData: policy};
129 contentType: 'application/json',
130 data: JSON.stringify(postData),
131 success : function(data){
132 $scope.$apply(function(){
133 $scope.validateData = data.data.replace(/\"/g, "");
134 $scope.data=data.data.substring(1,8);
135 var size = data.data.length;
136 if($scope.data == 'success'){
137 Notification.success("Validation Success.");
138 $scope.savebutton = false;
140 var displayWarning = data.data.substring(19,size);
141 document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
142 document.getElementById("validate").style.color = "white";
143 document.getElementById("validate").style.backgroundColor = "skyblue";
146 Notification.error("Validation Failed.");
147 document.getElementById("validate").innerHTML = $scope.validateData;
148 document.getElementById("validate").style.color = "white";
149 document.getElementById("validate").style.backgroundColor = "red";
150 $scope.savebutton = true;
154 console.log($scope.data);
156 error : function(data){
157 Notification.error("Validation Failed.");
158 $scope.savebutton = true;