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('editOnapNameController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){
21 if(message.onapNameDictionaryData==null)
22 $scope.label='Add New Onap Name'
24 $scope.label='Edit Onap Name'
25 $scope.disableCd=true;
27 $scope.editOnapName = message.onapNameDictionaryData;
30 /*getting user info from session*/
32 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
33 .then(function (response) {
34 userid = response.userid;
37 $scope.saveOnapName = function(onapNameDictionaryData) {
38 var regex = new RegExp("^[a-zA-Z0-9_]*$");
39 if(!regex.test(onapNameDictionaryData.onapName)) {
40 Notification.error("Enter Valid Onap Name without spaces or special characters");
42 var uuu = "saveDictionary/onap_dictionary/save_onapName";
43 var postData={onapNameDictionaryData: onapNameDictionaryData, userid: userid};
48 contentType: 'application/json',
49 data: JSON.stringify(postData),
50 success : function(data){
51 $scope.$apply(function(){
52 $scope.onapNameDictionaryDatas=data.onapNameDictionaryDatas;});
53 if($scope.onapNameDictionaryDatas == "Duplicate"){
54 Notification.error("OnapName Dictionary exists with Same Onap Name.")
56 console.log($scope.onapNameDictionaryDatas);
57 $modalInstance.close({onapNameDictionaryDatas:$scope.onapNameDictionaryDatas});
60 error : function(data){
61 alert("Error while saving.");
67 $scope.close = function() {
68 $modalInstance.close();