Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / controller / dashboard_Logging_Controller.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP 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
21 app.controller('policyDashboardController', function ($scope,DashboardService,modalService, $modal, uiGridConstants,Grid){
22         $( "#dialog" ).hide();
23
24         $scope.loading = true;
25         DashboardService.getData().then(function(data){
26                 $scope.loading = false;
27                 var j = data;
28                 $scope.data = JSON.parse(j.data);
29                 console.log($scope.data);
30                 $scope.availableLoggingDatas =JSON.parse($scope.data.availableLoggingDatas);
31                 console.log($scope.availableLoggingDatas);
32         },function(error){
33                 console.log("failed");
34                 //reloadPageOnce();
35         });
36
37         $scope.availableGridLoggingDatas = {
38                         data : 'availableLoggingDatas',
39                         enableFiltering: true,
40                         columnDefs: [{ field: 'id'},
41                                      { field: 'type'},
42                                      { field: 'system'},
43                                      {field: 'logtype'},
44                                      {field : 'date' ,type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' },
45                                      {field : 'description'}
46                                      ],
47                                      enableGridMenu: true,
48                                      enableSelectAll: true,
49                                      exporterCsvFilename: 'DashboardLogging.csv',
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;
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