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('modelAttributeDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_MicroServiceAttributeData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.microServiceAttributeDictionaryDatas = JSON.parse($scope.data.microServiceAttributeDictionaryDatas);
28 console.log($scope.microServiceAttributeDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataByName').then(function (data) {
35 $scope.data = JSON.parse(j.data);
36 console.log($scope.data);
37 $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
38 console.log($scope.microServiceModelsDictionaryDatas);
40 console.log("failed");
43 PolicyAppService.getData('get_LockDownData').then(function(data){
45 $scope.data = JSON.parse(j.data);
46 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
47 if($scope.lockdowndata[0].lockdown == true){
48 $scope.modelAttributeDictionaryGrid.columnDefs[0].visible = false;
49 $scope.gridApi.grid.refresh();
51 $scope.modelAttributeDictionaryGrid.columnDefs[0].visible = true;
52 $scope.gridApi.grid.refresh();
55 console.log("failed");
58 $scope.modelAttributeDictionaryGrid = {
59 data : 'microServiceAttributeDictionaryDatas',
60 enableFiltering: true,
62 field: 'id', enableFiltering: false, headerCellTemplate: '' +
63 '<button id=\'New\' ng-click="grid.appScope.createNewModelAttributeWindow()" class="btn btn-success">' + 'Create</button>',
65 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editModelAttributeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
66 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteModelAttribute(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
67 },{ field: 'name', displayName :'Name', sort: { direction: 'asc', priority: 0 }},
68 { field: 'value'}, {field: 'modelName' , displayName :'MicroService' }
72 $scope.editModelAttribute = null;
73 $scope.createNewModelAttributeWindow = function(){
74 $scope.editModelAttribute = null;
75 var modalInstance = $modal.open({
76 backdrop: 'static', keyboard: false,
77 templateUrl : 'add_modelAttribute_popup.html',
78 controller: 'editModelAttributeController',
80 message: function () {
82 microServiceAttributeDictionaryDatas: $scope.editModelAttribute
88 modalInstance.result.then(function(response){
89 console.log('response', response);
90 $scope.microServiceAttributeDictionaryDatas=response.microServiceAttributeDictionaryDatas;
94 $scope.editModelAttributeWindow = function(modelAttributeDictionaryData) {
95 $scope.editModelAttribute = modelAttributeDictionaryData;
96 var modalInstance = $modal.open({
97 backdrop: 'static', keyboard: false,
98 templateUrl : 'add_modelAttribute_popup.html',
99 controller: 'editModelAttributeController',
101 message: function () {
103 modelAttributeDictionaryData: $scope.editModelAttribute
109 modalInstance.result.then(function(response){
110 console.log('response', response);
111 $scope.microServiceAttributeDictionaryDatas = response.microServiceAttributeDictionaryDatas;
115 $scope.deleteModelAttribute = function(data) {
116 modalService.popupConfirmWin("Confirm","You are about to delete the Model Attribute : "+data.name+". Do you want to continue?",
118 var uuu = "deleteDictionary/ms_dictionary/remove_modelAttribute";
119 var postData={data: data};
124 contentType: 'application/json',
125 data: JSON.stringify(postData),
126 success : function(data){
127 $scope.$apply(function(){$scope.microServiceAttributeDictionaryDatas=data.microServiceAttributeDictionaryDatas;});
129 error : function(data){
131 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);