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 editFWTermListController = function ($scope, $modalInstance, message, FWDictionaryService, PapUrlService, UserInfoService, Notification){
24 $scope.fromZonechoices = [];
25 $scope.toZonechoices = [];
26 $scope.sourceListchoices = [];
27 $scope.destinationListchoices = [];
28 $scope.sourceServicechoices = [];
29 $scope.destinationServicechoices = [];
30 $scope.actionListchoices = [];
31 if(message.termListDictionaryData==null){
32 $scope.label='Add Term List Name'
34 $scope.label='Edit Term List Name'
35 $scope.disableCd=true;
36 var fromZoneheaders = message.termListDictionaryData.fromZone;
37 var splitFromZone = ',';
38 if(fromZoneheaders != null){
39 if (fromZoneheaders.indexOf(splitFromZone) >= 0) {
40 var splitFromZoneValue = fromZoneheaders.split(splitFromZone);
41 for(i = 0; i < splitFromZoneValue.length; i++){
42 var key = splitFromZoneValue[i];
43 $scope.fromZonechoices.push({'id':'choice'+i+1, 'option': key});
46 var key = fromZoneheaders;
47 $scope.fromZonechoices.push({'id':'choice'+1, 'option': key});
51 var toZoneheaders = message.termListDictionaryData.toZone;
52 var splitToZone = ',';
53 if(toZoneheaders != null){
54 if (toZoneheaders.indexOf(splitToZone) >= 0) {
55 var splitToZoneValue = toZoneheaders.split(splitToZone);
56 for(i = 0; i < splitToZoneValue.length; i++){
57 var key = splitToZoneValue[i];
58 $scope.toZonechoices.push({'id':'choice'+i+1, 'option': key});
61 var key = toZoneheaders;
62 $scope.toZonechoices.push({'id':'choice'+1, 'option': key});
66 var srcIPheaders = message.termListDictionaryData.srcIPList;
68 if(srcIPheaders != null){
69 if (srcIPheaders.indexOf(splitSrcIP) >= 0) {
70 var splitSrcIPValue = srcIPheaders.split(splitSrcIP);
71 for(i = 0; i < splitSrcIPValue.length; i++){
72 var key = splitSrcIPValue[i];
73 $scope.sourceListchoices.push({'id':'choice'+i+1, 'option': key});
76 var key = srcIPheaders;
77 $scope.sourceListchoices.push({'id':'choice'+1, 'option': key});
81 var desIPheaders = message.termListDictionaryData.destIPList;
83 if(desIPheaders != null){
84 if (desIPheaders.indexOf(splitDesIP) >= 0) {
85 var splitDestIPValue = desIPheaders.split(splitDesIP);
86 for(i = 0; i < splitDestIPValue.length; i++){
87 var key = splitDestIPValue[i];
88 $scope.destinationListchoices.push({'id':'choice'+i+1, 'option': key});
91 var key = desIPheaders;
92 $scope.destinationListchoices.push({'id':'choice'+1, 'option': key});
96 var srcServheaders = message.termListDictionaryData.srcPortList;
97 var splitSrcServ = ',';
98 if(srcServheaders != null){
99 if (srcServheaders.indexOf(splitSrcServ) >= 0) {
100 var splitSrcServValue = srcServheaders.split(splitSrcServ);
101 for(i = 0; i < splitSrcServValue.length; i++){
102 var key = splitSrcServValue[i];
103 $scope.sourceServicechoices.push({'id':'choice'+i+1, 'option': key});
106 var key = srcServheaders;
107 $scope.sourceServicechoices.push({'id':'choice'+1, 'option': key});
111 var desServheaders = message.termListDictionaryData.destPortList;
112 var splitdesSer = ',';
113 if(desServheaders != null){
114 if (desServheaders.indexOf(splitdesSer) >= 0) {
115 var splitDesSerValue = desServheaders.split(splitdesSer);
116 for(i = 0; i < splitDesSerValue.length; i++){
117 var key = splitDesSerValue[i];
118 $scope.destinationServicechoices.push({'id':'choice'+i+1, 'option': key});
121 var key = desServheaders;
122 $scope.destinationServicechoices.push({'id':'choice'+1, 'option': key});
126 var actionheaders = message.termListDictionaryData.action;
127 var splitAction = ',';
128 if(actionheaders != null){
129 if (actionheaders.indexOf(splitAction) >= 0) {
130 var splitActionValue = actionheaders.split(splitAction);
131 for(i = 0; i < splitActionValue.length; i++){
132 var key = splitActionValue[i];
133 $scope.actionListchoices.push({'id':'choice'+i+1, 'option': key});
136 var key = actionheaders;
137 $scope.actionListchoices.push({'id':'choice'+1, 'option': key});
143 PapUrlService.getPapUrl().then(function(data) {
145 papUrl = config.PAP_URL;
148 FWDictionaryService.getPrefixListDictionaryDataByName(papUrl).then(function (data) {
150 $scope.data = JSON.parse(j.data);
151 console.log($scope.data);
152 $scope.prefixListDictionaryDatas = JSON.parse($scope.data.prefixListDictionaryDatas);
153 console.log($scope.prefixListDictionaryDatas);
154 }, function (error) {
155 console.log("failed");
158 FWDictionaryService.getZoneDictionaryDataByName(papUrl).then(function (data) {
160 $scope.data = JSON.parse(j.data);
161 console.log($scope.data);
162 $scope.zoneDictionaryDatas = JSON.parse($scope.data.zoneDictionaryDatas);
163 console.log($scope.zoneDictionaryDatas);
164 }, function (error) {
165 console.log("failed");
168 FWDictionaryService.getAddressGroupDictionaryDataByName(papUrl).then(function (data) {
170 $scope.data = JSON.parse(j.data);
171 console.log($scope.data);
172 $scope.addressGroupDictionaryDatas = JSON.parse($scope.data.addressGroupDictionaryDatas);
173 console.log($scope.addressGroupDictionaryDatas);
174 }, function (error) {
175 console.log("failed");
178 FWDictionaryService.getServiceListDictionaryDataByName(papUrl).then(function (data) {
180 $scope.data = JSON.parse(j.data);
181 console.log($scope.data);
182 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
183 console.log($scope.serviceListDictionaryDatas);
184 }, function (error) {
185 console.log("failed");
188 FWDictionaryService.getServiceGroupDictionaryDataByName(papUrl).then(function (data) {
190 $scope.data = JSON.parse(j.data);
191 console.log($scope.data);
192 $scope.serviceGroupDictionaryDatas = JSON.parse($scope.data.serviceGroupDictionaryDatas);
193 console.log($scope.serviceGroupDictionaryDatas);
194 }, function (error) {
195 console.log("failed");
198 FWDictionaryService.getActionListDictionaryDataByName(papUrl).then(function (data) {
200 $scope.data = JSON.parse(j.data);
201 console.log($scope.data);
202 $scope.actionListDictionaryDatas = JSON.parse($scope.data.actionListDictionaryDatas);
203 console.log($scope.actionListDictionaryDatas);
204 }, function (error) {
205 console.log("failed");
209 /*getting user info from session*/
211 UserInfoService.getFunctionalMenuStaticDetailSession()
212 .then(function (response) {
213 loginId = response.userid;
216 $scope.editTermList = message.termListDictionaryData;
218 $scope.saveTermName = function(termListDictionaryData) {
219 var mergeFromZoneData = extend(termListDictionaryData, $scope.fromZoneDatas[0]);
220 var mergeToData = extend(mergeFromZoneData, $scope.toZoneDatas[0]);
221 var mergeSourceListData = extend(mergeToData, $scope.sourceListDatas[0]);
222 var mergeDListData = extend(mergeSourceListData, $scope.destinationListDatas[0]);
223 var mergeSServicesData = extend(mergeDListData, $scope.sourceServicesDatas[0]);
224 var mergeDServicesData = extend(mergeSServicesData, $scope.destinationServicesDatas[0]);
225 var finalData = extend(mergeDServicesData, $scope.actionListDatas[0]);
226 var uuu = papUrl + "/ecomp/fw_dictionary/save_termList.htm";
227 var postData={termListDictionaryData: finalData, loginId: loginId};
232 contentType: 'application/json',
233 data: JSON.stringify(postData),
234 success : function(data){
235 $scope.$apply(function(){
236 $scope.termListDictionaryDatas=data.termListDictionaryDatas;});
237 if($scope.termListDictionaryDatas == "Duplicate"){
238 Notification.error("FW TermList Dictionary exists with Same Term Name.")
240 console.log($scope.termListDictionaryDatas);
241 $modalInstance.close({termListDictionaryDatas:$scope.termListDictionaryDatas});
244 error : function(data){
245 alert("Error while saving.");
250 $scope.close = function() {
251 $modalInstance.close();
255 function extend(obj, src) {
256 for (var key in src) {
257 if (src.hasOwnProperty(key)) obj[key] = src[key];
262 $scope.fromZoneDatas = [{"fromZoneDatas" : $scope.fromZonechoices}];
263 $scope.addFromZoneNewChoice = function() {
264 var newItemNo = $scope.fromZonechoices.length+1;
265 $scope.fromZonechoices.push({'id':'choice'+newItemNo});
267 $scope.removeFromZoneChoice = function() {
268 var lastItem = $scope.fromZonechoices.length-1;
269 $scope.fromZonechoices.splice(lastItem);
272 $scope.toZoneDatas = [{"toZoneDatas" : $scope.toZonechoices}];
273 $scope.addToZoneNewChoice = function() {
274 var newItemNo = $scope.toZonechoices.length+1;
275 $scope.toZonechoices.push({'id':'choice'+newItemNo});
277 $scope.removeToZoneChoice = function() {
278 var lastItem = $scope.toZonechoices.length-1;
279 $scope.toZonechoices.splice(lastItem);
282 $scope.sourceListDatas = [{"sourceListDatas" : $scope.sourceListchoices}];
283 $scope.addSourceListNewChoice = function() {
284 var newItemNo = $scope.sourceListchoices.length+1;
285 $scope.sourceListchoices.push({'id':'choice'+newItemNo});
287 $scope.removeSourceListChoice = function() {
288 var lastItem = $scope.sourceListchoices.length-1;
289 $scope.sourceListchoices.splice(lastItem);
292 $scope.destinationListDatas = [{"destinationListDatas" : $scope.destinationListchoices}];
293 $scope.addDListNewChoice = function() {
294 var newItemNo = $scope.destinationListchoices.length+1;
295 $scope.destinationListchoices.push({'id':'choice'+newItemNo});
297 $scope.removeDlistChoice = function() {
298 var lastItem = $scope.destinationListchoices.length-1;
299 $scope.destinationListchoices.splice(lastItem);
302 $scope.sourceServicesDatas = [{"sourceServiceDatas" : $scope.sourceServicechoices}];
303 $scope.addSourceServiceNewChoice = function() {
304 var newItemNo = $scope.sourceServicechoices.length+1;
305 $scope.sourceServicechoices.push({'id':'choice'+newItemNo});
307 $scope.removeSourceServiceChoice = function() {
308 var lastItem = $scope.sourceServicechoices.length-1;
309 $scope.sourceServicechoices.splice(lastItem);
312 $scope.destinationServicesDatas = [{"destinationServiceDatas" : $scope.destinationServicechoices}];
313 $scope.addDServicesNewChoice = function() {
314 var newItemNo = $scope.destinationServicechoices.length+1;
315 $scope.destinationServicechoices.push({'id':'choice'+newItemNo});
317 $scope.removeDServicesChoice = function() {
318 var lastItem = $scope.destinationServicechoices.length-1;
319 $scope.destinationServicechoices.splice(lastItem);
322 $scope.actionListDatas = [{"actionListDatas" : $scope.actionListchoices}];
323 $scope.addActionListNewChoice = function() {
324 var newItemNo = $scope.actionListchoices.length+1;
325 $scope.actionListchoices.push({'id':'choice'+newItemNo});
327 $scope.removeActionListChoice = function() {
328 var lastItem = $scope.actionListchoices.length-1;
329 $scope.actionListchoices.splice(lastItem);