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=========================================================
23 app.controller('ecompNameDictGridController', function ($scope, DictionaryService,modalService,PapUrlService, $modal, uiGridConstants,Grid){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 DictionaryService.getEcompDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
37 console.log($scope.ecompNameDictionaryDatas);
39 console.log("failed");
43 $scope.ecompNameDictionaryGrid = {
44 data : 'ecompNameDictionaryDatas',
45 enableFiltering: true,
46 exporterCsvFilename: 'EcompName.csv',
48 enableSelectAll: true,
50 field: 'id', enableFiltering: false, headerCellTemplate: '' +
51 '<button id=\'New\' ng-click="grid.appScope.createNewEcompName()" class="btn btn-success">' + 'Create</button>',
53 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editEcompNameWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
54 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteEcompName(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
56 { field: 'ecompName', displayName : 'Ecomp Name' },
57 { field: 'description', width: '20%' },
58 {field: 'userCreatedBy.userName', displayName : 'Created By'},
59 {field: 'userModifiedBy.userName', displayName : 'Modified By' },
60 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''},
61 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''}
63 enableColumnResize : true,
64 exporterPdfDefaultStyle: {fontSize: 9},
65 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
66 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
67 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
68 exporterPdfFooter: function ( currentPage, pageCount ) {
69 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
71 exporterPdfCustomFormatter: function ( docDefinition ) {
72 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
73 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
76 exporterPdfOrientation: 'portrait',
77 exporterPdfPageSize: 'LETTER',
78 exporterPdfMaxGridWidth: 500,
79 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
80 onRegisterApi: function(gridApi){
81 $scope.gridApi = gridApi;
86 $scope.editEcompName = null;
87 $scope.createNewEcompName = function(){
88 $scope.editEcompName = null;
89 var modalInstance = $modal.open({
90 backdrop: 'static', keyboard: false,
91 templateUrl : 'add_ecompName_popup.html',
92 controller: 'editEcompNameController',
94 message: function () {
96 ecompNameDictionaryDatas: $scope.editEcompName
102 modalInstance.result.then(function(response){
103 console.log('response', response);
104 $scope.ecompNameDictionaryDatas=response.ecompNameDictionaryDatas;
108 $scope.editEcompNameWindow = function(ecompNameDictionaryData) {
109 $scope.editEcompName = ecompNameDictionaryData;
110 var modalInstance = $modal.open({
111 backdrop: 'static', keyboard: false,
112 templateUrl : 'add_ecompName_popup.html',
113 controller: 'editEcompNameController',
115 message: function () {
117 ecompNameDictionaryData: $scope.editEcompName
123 modalInstance.result.then(function(response){
124 console.log('response', response);
125 $scope.ecompNameDictionaryDatas = response.ecompNameDictionaryDatas;
129 $scope.deleteEcompName = function(data) {
130 modalService.popupConfirmWin("Confirm","You are about to delete the Ecomp Name "+data.ecompName+". Do you want to continue?",
132 var uuu = papUrl + "/ecomp/ecomp_dictionary/remove_ecomp.htm";
133 var postData={data: data};
138 contentType: 'application/json',
139 data: JSON.stringify(postData),
140 success : function(data){
141 $scope.$apply(function(){$scope.ecompNameDictionaryDatas=data.ecompNameDictionaryDatas;});
143 error : function(data){
145 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);