2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 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('editBRMSParamController' , function ($scope, $modalInstance, message, $http, UserInfoServiceDS2, Notification){
21 if(message.brmsParamDictionaryData==null)
22 $scope.label='Add BRMS Rule'
24 $scope.label='Edit BRMS Rule'
25 $scope.disableCd=true;
29 /*getting user info from session*/
31 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
32 .then(function (response) {
33 userid = response.userid;
37 $scope.editBRMSParam = message.brmsParamDictionaryData;
39 $scope.uploadFile = function(files) {
40 var extn = files[0].name.substr(files[0].name.lastIndexOf('.')+1);
43 var fd = new FormData();
44 fd.append("file", files[0]);
45 $http.post("saveDictionary/brms_dictionary/set_BRMSParamData", fd, {
46 withCredentials: false,
47 headers: {'Content-Type': undefined },
48 transformRequest: angular.identity
49 }).success().error( );
51 Notification.error("BRMS Dictionary Upload file should ends with .drl extension");
57 $scope.saveBRMSParam = function(brmsParamDictionaryData) {
59 var regex = new RegExp("^[a-zA-Z0-9_]*$");
60 if(!regex.test(brmsParamDictionaryData.ruleName)) {
61 Notification.error("Enter Valid Rule Name without spaces or special characters");
63 var uuu = "saveDictionary/brms_dictionary/save_BRMSParam";
64 var postData={brmsParamDictionaryData: brmsParamDictionaryData, userid: userid};
69 contentType: 'application/json',
70 data: JSON.stringify(postData),
71 success : function(data){
72 $scope.$apply(function(){
73 $scope.brmsParamDictionaryDatas=data.brmsParamDictionaryDatas;});
74 if($scope.brmsParamDictionaryDatas == "Duplicate"){
75 Notification.error("BRMSParan Dictionary exists with Same Name.")
76 }else if($scope.brmsParamDictionaryDatas == "Validation"){
77 Notification.error("BRMSParan Dictionary failed rule Validation.")
79 console.log($scope.brmsParamDictionaryDatas);
80 $modalInstance.close({brmsParamDictionaryDatas:$scope.brmsParamDictionaryDatas});
83 error : function(data){
84 Notification.error("Error while saving.");
89 Notification.error("Please check BRMS Rule Upload file format.");
93 $scope.close = function() {
94 $modalInstance.close();