1 app.controller("reportSearchController", ['$scope','$rootScope','$http','$timeout',function ($scope,$rootScope,$http,$timeout) {
3 $http.get('raptor.htm?action=report.search.execute&r_page=0').then(
4 function(result){$scope.searchdData = result.data;
7 $scope.runReport = function(){
9 if($scope.reportId && $scope.reportId!=''){
10 searchParams = '&rep_id='+$scope.reportId+'&rep_id_options='+$scope.operatorRepId.index;
12 if($scope.reportName && $scope.reportName!=''){
13 searchParams = searchParams+'&rep_name='+$scope.reportName+'&rep_name_options='+$scope.operatorRepName.index;
16 console.log('raptor.htm?action=report.search.execute&r_page='+(paginationOptions.pageNumber-1)+searchParams);
17 $http.get('raptor.htm?action=report.search.execute&r_page='+(paginationOptions.pageNumber-1)+searchParams).then(
18 function(result){$scope.searchdData = result.data;
20 //quantum/raptor.htm?action=report.search.execute&rep_id=1000&rep_id_options=2&rep_name=cross&rep_name_options=2
24 var paginationOptions = {
30 $scope.gridOptions = {
31 paginationPageSizes: [5],
32 paginationPageSize: 5,
33 useExternalPagination: true,
37 enableSelectAll: true,
38 exporterMenuPdf: false,
39 exporterMenuCsv: false,
40 exporterCsvFilename: 'myFile.csv',
41 exporterPdfDefaultStyle: {fontSize: 9},
42 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
43 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
44 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
45 exporterPdfFooter: function ( currentPage, pageCount ) {
46 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
48 exporterPdfCustomFormatter: function ( docDefinition ) {
49 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
50 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
53 exporterPdfOrientation: 'portrait',
54 exporterPdfPageSize: 'LETTER',
55 exporterPdfMaxGridWidth: 500,
56 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
57 onRegisterApi: function(gridApi) {
58 $scope.gridApi = gridApi;
59 gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
60 paginationOptions.pageNumber = newPage;
61 paginationOptions.pageSize = pageSize;
68 var getPage = function() {
69 $scope.gridOptions.columnDefs = [];
70 $scope.searchdData.columns[0].forEach(function(entry) {
71 if(entry.columnTitle=='Run'){
72 $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==drillDownLink', enableSorting: false,
73 cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="#/report_run/{{COL_FIELD.substr(39)}}" class="ion-arrow-right-b" style="font-size:20px;"></a></div>'
75 } else if(entry.columnTitle=='Edit'){
76 $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==drillDownLink', enableSorting: false,
77 cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD}}" class="ion-edit" style="font-size:20px;"></a></div>'
79 } else if(entry.columnTitle=='Delete'){
80 $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==drillDownLink', enableSorting: false,
81 cellTemplate: '<div class="ui-grid-cell-contents"><a href="" ng-click="grid.appScope.deleteReport(COL_FIELD,row)" class="ion-trash-b" style="font-size:20px;"></a></div>'
83 } else if(entry.columnTitle=='Copy'){
84 $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==drillDownLink', enableSorting: false,
85 cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD}}" class="ion-document-text" style="font-size:20px;"></a></div>'
87 } else if(entry.columnTitle=='Schedule'){
88 //$scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==drillDownLink',
89 // cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD}}" class="full-linear-icon-calendar" style="font-size:20px;font-weight: bold;"></a></div>'
91 } else if(entry.columnTitle=='No'){
93 $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId+'==displayValue'});
96 $scope.gridOptions.data = $scope.searchdData.rows[0];
97 $scope.gridOptions.paginationPageSizes= [$scope.searchdData.metaReport.pageSize];
98 $scope.gridOptions.paginationPageSize= $scope.searchdData.metaReport.pageSize;
99 $scope.gridOptions.totalItems = $scope.searchdData.metaReport.totalSize;
102 $scope.$watch("searchdData",function(newValue,oldValue) {
103 if($scope.searchdData){
108 $scope.operatorsRepId = [{index: 0, value: 'Equal To', title: 'Equal To', alias:'Equal To'},
109 {index: 1, value: 'Less Than', title: 'Less Than', alias:'Less Than'},
110 {index: 2, value: 'Greater Than', title: 'Greater Than', alias:'Greater Than'}];
111 $scope.operatorsRepName = [{index: 0, value: 'Starts With', title: 'Starts With', alias:'Starts With'},
112 {index:1, value: 'Ends With', title: 'Ends With', alias:'Ends With'},
113 {index: 2, value: 'Contains', title: 'Contains', alias:'Contains'}];
115 $scope.deleteReport = function(reportDeleteUrl,row) {
116 if (confirm("Please confirm: Are you sure you want to delete report #" + reportDeleteUrl.substr(41) + "?")) {
117 $http.get(reportDeleteUrl).then(
119 if(result.data=='deleted:true'){
120 var index = $scope.gridOptions.data.indexOf(row.entity);
121 $scope.gridOptions.data.splice(index, 1);
122 alert("Report deleted.");
124 alert("Report not deleted.");
131 $timeout(function() {
132 $rootScope.isViewRendering = false;