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 appDS2.controller('brmsControllerDictGridController', function ($scope, PolicyAppService,modalService, $modal){
21 $( "#dialog" ).hide();
24 PolicyAppService.getData('getDictionary/get_BRMSControllerData').then(function (data) {
26 $scope.data = JSON.parse(j.data);
27 console.log($scope.data);
28 $scope.brmsControllerDictionaryDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
29 console.log($scope.brmsControllerDictionaryDatas);
31 console.log("failed");
35 PolicyAppService.getData('get_LockDownData').then(function(data){
37 $scope.data = JSON.parse(j.data);
38 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
39 if($scope.lockdowndata[0].lockdown == true){
40 $scope.brmsControllerDictionaryGrid.columnDefs[0].visible = false;
41 $scope.gridApi.grid.refresh();
43 $scope.brmsControllerDictionaryGrid.columnDefs[0].visible = true;
44 $scope.gridApi.grid.refresh();
47 console.log("failed");
50 $scope.brmsControllerDictionaryGrid = {
51 data : 'brmsControllerDictionaryDatas',
52 enableFiltering: true,
53 exporterCsvFilename: 'BRMSControllerDictionary.csv',
55 enableSelectAll: true,
57 field: 'id', enableFiltering: false, headerCellTemplate: '' +
58 '<button id=\'New\' ng-click="grid.appScope.createNewBRMSControllerWindow()" class="btn btn-success">' + 'Create</button>',
60 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.viewBRMSControllerWindow(row.entity)"><i class="glyphicon glyphicon-eye-open"></i></button> ' +
61 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editBRMSControllerWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
62 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteBRMSController(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '12%'
64 { field: 'controllerName', displayName : 'Controller Name', sort: { direction: 'asc', priority: 0 }},
65 { field: 'description'},
66 {field: 'userCreatedBy.userName', displayName : 'Created By'},
67 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
68 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
69 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
71 exporterMenuPdf: false,
72 exporterPdfDefaultStyle: {fontSize: 9},
73 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
74 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
75 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
76 exporterPdfFooter: function ( currentPage, pageCount ) {
77 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
79 exporterPdfCustomFormatter: function ( docDefinition ) {
80 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
81 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
84 exporterPdfOrientation: 'portrait',
85 exporterPdfPageSize: 'LETTER',
86 exporterPdfMaxGridWidth: 500,
87 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
88 onRegisterApi: function(gridApi){
89 $scope.gridApi = gridApi;
93 $scope.editBRMSController = null;
94 $scope.createNewBRMSControllerWindow = function(){
95 $scope.editBRMSController = null;
96 var modalInstance = $modal.open({
97 backdrop: 'static', keyboard: false,
98 templateUrl : 'add_brmsController_popup.html',
99 controller: 'editBRMSControllerController',
101 message: function () {
103 brmsControllerDictionaryDatas: $scope.editBRMSController,
110 modalInstance.result.then(function(response){
111 console.log('response', response);
112 $scope.brmsControllerDictionaryDatas=response.brmsControllerDictionaryDatas;
116 $scope.viewBRMSControllerWindow = function(brmsControllerDictionaryData) {
117 $scope.editBRMSController = brmsControllerDictionaryData;
118 var modalInstance = $modal.open({
119 backdrop: 'static', keyboard: false,
120 templateUrl : 'add_brmsController_popup.html',
121 controller: 'editBRMSControllerController',
123 message: function () {
125 brmsControllerDictionaryDatas: $scope.editBRMSController,
132 modalInstance.result.then(function(response){
133 console.log('response', response);
134 $scope.brmsControllerDictionaryDatas=response.brmsControllerDictionaryDatas;
138 $scope.editBRMSControllerWindow = function(brmsControllerDictionaryData) {
139 $scope.editBRMSController = brmsControllerDictionaryData;
140 var modalInstance = $modal.open({
141 backdrop: 'static', keyboard: false,
142 templateUrl : 'add_brmsController_popup.html',
143 controller: 'editBRMSControllerController',
145 message: function () {
147 brmsControllerDictionaryDatas: $scope.editBRMSController,
154 modalInstance.result.then(function(response){
155 console.log('response', response);
156 $scope.brmsControllerDictionaryDatas=response.brmsControllerDictionaryDatas;
160 $scope.deleteBRMSController = function(data) {
161 modalService.popupConfirmWin("Confirm","You are about to delete the BRMS Controller "+data.controllerName+". Do you want to continue?",
163 var uuu = "deleteDictionary/brms_dictionary/remove_brmsController";
164 var postData={data: data};
169 contentType: 'application/json',
170 data: JSON.stringify(postData),
171 success : function(data){
172 $scope.$apply(function(){$scope.brmsControllerDictionaryDatas=data.brmsControllerDictionaryDatas;});
174 error : function(data){
176 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);