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('msModelsDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_MicroServiceModelsData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
28 console.log($scope.microServiceModelsDictionaryDatas);
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 if($scope.lockdowndata[0].lockdown == true){
38 $scope.msModelsDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.msModelsDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.msModelsDictionaryGrid = {
49 data : 'microServiceModelsDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'MSPolicyDictionary.csv',
53 enableSelectAll: true,
56 enableFiltering: false, headerCellTemplate: '' +
57 '<button id=\'New\' ng-click="grid.appScope.createNewMSModelsWindow()" class="btn btn-success">' + 'Create</button>',
59 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteMSModels(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
60 },{ field: 'modelName', displayName : 'Micro Service Model', sort: { direction: 'asc', priority: 0 }},
61 { field: 'description' },
62 { field: 'version', displayName : 'Model Version' },
63 {field: 'userCreatedBy.userName', displayName : 'Imported By' },
64 {field: 'dependency', visible: false},
65 {field: 'attributes', visible: false},
66 {field: 'enumValues', visible: false},
67 {field: 'ref_attributes',visible: false},
68 {field: 'sub_attributes', visible: false}
70 exporterMenuPdf: false,
71 exporterPdfDefaultStyle: {fontSize: 9},
72 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
73 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
74 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
75 exporterPdfFooter: function ( currentPage, pageCount ) {
76 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
78 exporterPdfCustomFormatter: function ( docDefinition ) {
79 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
80 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
83 exporterFieldCallback: function(grid, row, col, input) {
84 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
85 var date = new Date(input);
86 return date.toString("yyyy-MM-dd HH:MM:ss a");
91 exporterPdfOrientation: 'portrait',
92 exporterPdfPageSize: 'LETTER',
93 exporterPdfMaxGridWidth: 500,
94 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
95 onRegisterApi: function(gridApi){
96 $scope.gridApi = gridApi;
100 $scope.editMSmodelName = null;
101 $scope.createNewMSModelsWindow = function(){
102 $scope.editMSmodelName = null;
103 var modalInstance = $modal.open({
104 backdrop: 'static', keyboard: false,
105 templateUrl : 'add_msModel_popup.html',
106 controller: 'editMSModelController',
108 message: function () {
110 microServiceModelsDictionaryDatas: $scope.editMSmodelName
116 modalInstance.result.then(function(response){
117 console.log('response', response);
118 $scope.microServiceModelsDictionaryDatas=response.microServiceModelsDictionaryDatas;
122 $scope.editMSModelsWindow = function(microServiceModelsDictionaryData) {
123 $scope.editMSmodelName = microServiceModelsDictionaryData;
124 var modalInstance = $modal.open({
125 backdrop: 'static', keyboard: false,
126 templateUrl : 'add_msModel_popup.html',
127 controller: 'editMSModelController',
129 message: function () {
131 microServiceModelsDictionaryData: $scope.editMSmodelName
137 modalInstance.result.then(function(response){
138 console.log('response', response);
139 $scope.microServiceModelsDictionaryDatas = response.microServiceModelsDictionaryDatas;
143 $scope.deleteMSModels = function(data) {
144 modalService.popupConfirmWin("Confirm","You are about to delete the MicroService Model : "+data.modelName+". Do you want to continue?",
146 var uuu = "deleteDictionary/ms_dictionary/remove_msModel";
147 var postData={data: data};
152 contentType: 'application/json',
153 data: JSON.stringify(postData),
154 success : function(data){
155 $scope.$apply(function(){$scope.microServiceModelsDictionaryDatas=data.microServiceModelsDictionaryDatas;});
157 error : function(data){
159 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);