2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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('MSModelDictionaryDataController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_MicroServiceDictData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.microServiceDictionaryDatas = JSON.parse($scope.data.microServiceDictionaryDatas);
28 console.log($scope.microServiceDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('get_LockDownData').then(function(data){
35 $scope.data = JSON.parse(j.data);
36 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
37 $scope.msModelsDictionaryDataGrid.columnDefs[0].visible = !$scope.lockdowndata[0].lockdown;
38 $scope.gridApi.grid.refresh();
40 console.log("failed");
43 $scope.msModelsDictionaryDataGrid = {
44 data : 'microServiceDictionaryDatas',
45 enableFiltering: true,
47 field: 'id', enableFiltering: false, headerCellTemplate: '' +
48 '<button id=\'New\' ng-click="grid.appScope.createNewMSDictNameWindow()" class="btn btn-success">' + 'Create</button>',
50 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editMSDictNameWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
51 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteMSDictName(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
52 },{ field: 'dictionaryName', displayName : 'Dictionary Name', sort: { direction: 'asc', priority: 0 }},
53 { field: 'dictionaryUrl', displayName : 'URL' },
54 {field: 'dictionaryDataByName', displayName : 'Dictionary Data Name'}
56 onRegisterApi: function(gridApi){
57 $scope.gridApi = gridApi;
61 $scope.editMSDictData = null;
62 $scope.createNewMSDictNameWindow = function(){
63 $scope.editMSDictData = null;
64 var modalInstance = $modal.open({
65 backdrop: 'static', keyboard: false,
66 templateUrl : 'add_dictionaryData_popup.html',
67 controller: 'editMSDictController',
69 message: function () {
71 microServiceDictionaryDatas: $scope.editMSDictData
77 modalInstance.result.then(function(response){
78 console.log('response', response);
79 $scope.microServiceDictionaryDatas=response.microServiceDictionaryDatas;
83 $scope.editMSDictNameWindow = function(microServiceDictionaryDatas) {
84 $scope.editMSDictData = microServiceDictionaryDatas;
85 var modalInstance = $modal.open({
86 backdrop: 'static', keyboard: false,
87 templateUrl : 'add_dictionaryData_popup.html',
88 controller: 'editMSDictController',
90 message: function () {
92 microServiceDictionaryDatas: $scope.editMSDictData
98 modalInstance.result.then(function(response){
99 console.log('response', response);
100 $scope.microServiceDictionaryDatas = response.microServiceDictionaryDatas;
104 $scope.deleteMSDictName = function(data) {
105 modalService.popupConfirmWin("Confirm","You are about to delete the Micro Service Config Name "+data.name+". Do you want to continue?",
107 var uuu = "deleteDictionary/ms_dictionary/remove_msDictionaryData";
108 var postData={data: data};
113 contentType: 'application/json',
114 data: JSON.stringify(postData),
115 success : function(data){
116 $scope.$apply(function(){$scope.microServiceDictionaryDatas=data.microServiceDictionaryDatas;});
118 error : function(data){
120 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);