[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / dashboard_Logging_Controller.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 app.controller('policyDashboardController', function ($scope, PolicyAppService, modalService, $modal, uiGridConstants,Grid){
21         $( "#dialog" ).hide();
22
23         $scope.loading = true;
24         PolicyAppService.getData('get_DashboardLoggingData').then(function(data){
25                 $scope.loading = false;
26                 var j = data;
27                 $scope.data = JSON.parse(j.data);
28                 console.log($scope.data);
29                 $scope.availableLoggingDatas =JSON.parse($scope.data.availableLoggingDatas);
30                 console.log($scope.availableLoggingDatas);
31         },function(error){
32                 console.log("failed");
33                 //reloadPageOnce();
34         });
35
36         $scope.availableGridLoggingDatas = {
37                         data : 'availableLoggingDatas',
38                         enableFiltering: true,
39                         columnDefs: [{ field: 'id'},
40                                      { field: 'type'},
41                                      { field: 'system'},
42                                      {field: 'logtype'},
43                                      {field : 'date' ,type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' },
44                                      {field : 'description'}
45                                      ],
46                                      enableGridMenu: true,
47                                      enableSelectAll: true,
48                                      exporterCsvFilename: 'DashboardLogging.csv',
49                                      exporterMenuPdf: false,
50                                      exporterPdfDefaultStyle: {fontSize: 9},
51                                      exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
52                                      exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
53                                      exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
54                                      exporterPdfFooter: function ( currentPage, pageCount ) {
55                                          return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
56                                      },
57                                      exporterPdfCustomFormatter: function ( docDefinition ) {
58                                          docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
59                                          docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
60                                          return docDefinition;
61                                      },
62                                      exporterFieldCallback: function(grid, row, col, input) {
63                                          if( col.name == 'date') {
64                                                  var date = new Date(input);
65                                                  return date.toString("yyyy-MM-dd HH:MM:ss a");
66                                          } else {
67                                                  return input;
68                                          }
69                                      },
70                                      exporterPdfOrientation: 'portrait',
71                                      exporterPdfPageSize: 'LETTER',
72                                      exporterPdfMaxGridWidth: 500,
73                                      exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
74                                      onRegisterApi: function(gridApi){
75                                          $scope.gridApi = gridApi;
76                                      }
77
78         };         
79
80 });
81