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', ['$scope', '$window', '$timeout', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function($scope, $window, $timeout, PolicyAppService, PolicyNavigator, modalService, $modal, Notification){
23 $scope.policyNavigator;
24 $scope.savebutton = true;
25 $scope.refreshCheck = false;
27 $scope.refresh = function(){
28 if($scope.refreshCheck){
29 $scope.policyNavigator.refresh();
31 $scope.modal('createNewPolicy', true);
34 $scope.modal = function(id, hide) {
35 return $('#' + id).modal(hide ? 'hide' : 'show');
38 PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
40 $scope.data = JSON.parse(j.data);
41 console.log($scope.data);
42 $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
43 console.log($scope.ecompNameDictionaryDatas);
45 console.log("failed");
48 PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').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 PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
64 if($scope.temp.policy.readOnly && $scope.temp.policy.editPolicy){
65 $scope.temp.policy.verticaMetrics = [];
66 $scope.temp.policy.description = [];
67 $scope.temp.policy.attributes = [];
70 $scope.addDataToFields = function(serviceType){
71 if($scope.PMData == undefined){
72 $scope.temp.policy.verticaMetrics = [];
73 $scope.temp.policy.description = [];
74 $scope.temp.policy.attributes = [];
75 PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
78 if(serviceType.serviceTypePolicyName == 'Registration Failure(Trinity)'){
79 var myNewData = $scope.PMData[0];
80 }else if(serviceType.serviceTypePolicyName == 'International Fraud(Trinity)'){
81 var myNewData = $scope.PMData[1];
82 }else if(serviceType.serviceTypePolicyName == 'No dial tone(Trinity)'){
83 var myNewData = $scope.PMData[2];
84 }else if(serviceType.serviceTypePolicyName == 'Call storm(Trinity)'){
85 var myNewData = $scope.PMData[3];
86 }else if(serviceType.serviceTypePolicyName == 'Registration storm(Trinity)'){
87 var myNewData = $scope.PMData[4];
90 $scope.temp.policy.verticaMetrics = myNewData;
91 $scope.temp.policy.description = myNewData;
92 $scope.temp.policy.attributeFields = myNewData;
95 $scope.temp.policy.verticaMetrics = serviceType;
96 $scope.temp.policy.description = serviceType;
97 $scope.temp.policy.attributeFields = serviceType;
102 $scope.saveCLPMPolicy = function(policy){
103 if(policy.itemContent != undefined){
104 $scope.refreshCheck = true;
105 $scope.policyNavigator = policy.itemContent;
106 policy.itemContent = "";
108 $scope.savebutton = false;
109 var uuu = "policycreation/save_policy";
110 var postData={policyData: policy};
115 contentType: 'application/json',
116 data: JSON.stringify(postData),
117 success : function(data){
118 $scope.$apply(function(){
119 $scope.data=data.policyData;
120 if($scope.data == 'success'){
121 $scope.temp.policy.readOnly = 'true';
122 Notification.success("Policy Saved Successfully.");
123 }else if ($scope.data == 'PolicyExists'){
124 $scope.savebutton = true;
125 Notification.error("Policy Already Exists with Same Name in Scope.");
128 console.log($scope.data);
130 error : function(data){
131 Notification.error("Error Occured while saving Policy.");
136 $scope.validatePolicy = function(policy){
138 document.getElementById("validate").innerHTML = "";
139 var uuu = "policyController/validate_policy.htm";
140 var postData={policyData: policy};
145 contentType: 'application/json',
146 data: JSON.stringify(postData),
147 success : function(data){
148 $scope.$apply(function(){
149 $scope.validateData = data.data.replace(/\"/g, "");
150 $scope.data=data.data.substring(1,8);
151 var size = data.data.length;
152 if($scope.data == 'success'){
153 Notification.success("Validation Success.");
154 $scope.savebutton = false;
156 var displayWarning = data.data.substring(19,size);
157 document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
158 document.getElementById("validate").style.color = "white";
159 document.getElementById("validate").style.backgroundColor = "skyblue";
162 Notification.error("Validation Failed.");
163 document.getElementById("validate").innerHTML = $scope.validateData;
164 document.getElementById("validate").style.color = "white";
165 document.getElementById("validate").style.backgroundColor = "red";
166 $scope.savebutton = true;
170 console.log($scope.data);
172 error : function(data){
173 Notification.error("Validation Failed.");
174 $scope.savebutton = true;