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 app.controller('editFWPrefixListController' ,  function ($scope, $modalInstance, message, Notification, UserInfoServiceDS2, Notification){
 
  21         $scope.validate = 'false';
 
  22     if(message.prefixListDictionaryData==null)
 
  23         $scope.label='Add PrefixList'
 
  25         $scope.label='Edit PrefixList'
 
  26         $scope.disableCd=true;
 
  29         /*getting user info from session*/
 
  31         UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
 
  32                 .then(function (response) {                     
 
  33                         userid = response.userid;               
 
  36     $scope.editPrefixList = message.prefixListDictionaryData;
 
  38     $scope.saveFWPrefixList = function(prefixListDictionaryData) {
 
  39         var regex = new RegExp("^[a-zA-Z0-9_]*$");
 
  40         if(!regex.test(prefixListDictionaryData.prefixListName)) {
 
  41                 Notification.error("Enter Valid PrefixList Name without spaces or special characters");
 
  43                 if($scope.validate == 'true'){
 
  44                         var uuu = "saveDictionary/fw_dictionary/save_prefixList";
 
  45                         var postData={prefixListDictionaryData: prefixListDictionaryData, userid: userid};
 
  50                                 contentType: 'application/json',
 
  51                                 data: JSON.stringify(postData),
 
  52                                 success : function(data){
 
  53                                         $scope.$apply(function(){
 
  54                                                 $scope.prefixListDictionaryDatas=data.prefixListDictionaryDatas;});
 
  55                                         if($scope.prefixListDictionaryDatas == "Duplicate"){
 
  56                                                 Notification.error("FW PrefixList Dictionary exists with Same PrefixList Name.")
 
  58                                                 console.log($scope.prefixListDictionaryDatas);
 
  59                                                 $modalInstance.close({prefixListDictionaryDatas:$scope.prefixListDictionaryDatas});
 
  62                                 error : function(data){
 
  63                                         alert("Error while saving.");
 
  67                         Notification.error('Prefix List Validation is Not Successful');
 
  72     $scope.validateFWPrefixList = function(prefixListDictionaryData) {
 
  73         var uuu = "saveDictionary/fw_dictionary/validate_prefixList";
 
  74         var postData={prefixListDictionaryData: prefixListDictionaryData};
 
  79             contentType: 'application/json',
 
  80             data: JSON.stringify(postData),
 
  81             success : function(data){
 
  82                 $scope.$apply(function(){
 
  83                 $scope.result=data.result;});
 
  84                 console.log($scope.result);
 
  85                 if($scope.result == 'error'){
 
  86                         Notification.error('IP not according to CIDR notation');
 
  88                         $scope.validate = 'true';
 
  89                         Notification.success('Validation Success');
 
  95     $scope.close = function() {
 
  96         $modalInstance.close();