removing unused db file
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / controller / dictionaryController / ecompNameEditorController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 /**
22  */
23 var editEcompNameController =  function ($scope, $modalInstance, message, PapUrlService, UserInfoService, Notification){
24     if(message.ecompNameDictionaryData==null)
25         $scope.label='Add New Ecomp Name'
26     else{
27         $scope.label='Edit Ecomp Name'
28         $scope.disableCd=true;
29     }
30     $scope.editEcompName = message.ecompNameDictionaryData;
31     
32         var papUrl;
33         PapUrlService.getPapUrl().then(function(data) {
34                 var config = data;
35                 papUrl = config.PAP_URL;
36                 console.log(papUrl);
37         });
38         
39         /*getting user info from session*/
40         var loginId = null;
41         UserInfoService.getFunctionalMenuStaticDetailSession()
42                 .then(function (response) {                     
43                         loginId = response.userid;              
44          });
45    
46     $scope.saveEcompName = function(ecompNameDictionaryData) {
47         var uuu = papUrl + "/ecomp/ecomp_dictionary/save_ecompName.htm";
48         var postData={ecompNameDictionaryData: ecompNameDictionaryData, loginId: loginId};
49         $.ajax({
50             type : 'POST',
51             url : uuu,
52             dataType: 'json',
53             contentType: 'application/json',
54             data: JSON.stringify(postData),
55             success : function(data){
56                 $scope.$apply(function(){
57                     $scope.ecompNameDictionaryDatas=data.ecompNameDictionaryDatas;});
58                 if($scope.ecompNameDictionaryDatas == "Duplicate"){
59                         Notification.error("EcompName Dictionary exists with Same Ecomp Name.")
60                 }else{      
61                         console.log($scope.ecompNameDictionaryDatas);
62                     $modalInstance.close({ecompNameDictionaryDatas:$scope.ecompNameDictionaryDatas});
63                 }
64             },
65             error : function(data){
66                 alert("Error while saving.");
67             }
68         });
69     };
70
71     $scope.close = function() {
72         $modalInstance.close();
73     };
74 }