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('editModelAttributeController' , function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
21 if(message.modelAttributeDictionaryData==null)
22 $scope.label='Add New Dictionary Entry'
24 $scope.label='Edit Dictionary Entry'
25 $scope.disableCd=true;
28 PolicyAppService.getData('getDictionary/get_MicroServiceAttributeData').then(function (data) {
30 $scope.data = JSON.parse(j.data);
31 console.log($scope.data);
32 $scope.microServiceAttributeDictionaryDatas = JSON.parse($scope.data.microServiceAttributeDictionaryDatas);
33 console.log($scope.microServiceAttributeDictionaryDatas);
35 console.log("failed");
38 PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataServiceVersion').then(function (data) {
40 $scope.data = JSON.parse(j.data);
41 console.log($scope.data);
42 $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
43 console.log($scope.microServiceModelsDictionaryDatas);
45 console.log("failed");
48 /*getting user info from session*/
50 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
51 .then(function (response) {
52 userid = response.userid;
55 $scope.editModelAttribute = message.modelAttributeDictionaryData;
56 $scope.editModelAttribute1 = {microservice: []};
58 if(message.modelAttributeDictionaryData.groupList != null){
59 var splitValue = message.modelAttributeDictionaryData.groupList.split(",");
60 console.log(splitValue);
63 $scope.saveModelAttribute = function(modelAttributeDictionaryData) {
64 var regex = new RegExp("^[a-zA-Z0-9_]*$");
65 if(!regex.test(modelAttributeDictionaryData.name)) {
66 Notification.error("Enter Valid Micro Service Name without spaces or special characters");
68 var uuu = "saveDictionary/ms_dictionary/save_modelAttribute";
69 var postData={modelAttributeDictionaryData: modelAttributeDictionaryData, userid: userid};
74 contentType: 'application/json',
75 data: JSON.stringify(postData),
76 success : function(data){
77 $scope.$apply(function(){
78 $scope.microServiceAttributeDictionaryDatas=data.microServiceAttributeDictionaryDatas;});
79 if($scope.microServiceAttributeDictionaryDatas == "Duplicate"){
80 Notification.error("Model Attribute Dictionary exists with Same Attribute Name.")
82 console.log($scope.microServiceAttributeDictionaryDatas);
83 $modalInstance.close({microServiceAttributeDictionaryDatas:$scope.microServiceAttributeDictionaryDatas});
86 error : function(data){
87 alert("Error while saving.");
93 $scope.close = function() {
94 $modalInstance.close();