1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Observable, throwError} from 'rxjs';
import {retry, catchError} from 'rxjs/operators';
import {HtmlParser} from '@angular/compiler';
import {environment} from '../../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class RunService {
finalArr: any;
finalResponseArr: any;
constructor(private _http: HttpClient) {
}
getReportData(reportId: string): Observable<any> {
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master=' + reportId + '&refresh=Y');
}
getReportDataWithFormFields(queryString: string, reportId: string, groupSelectValue: string): Observable<any> {
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master=' + reportId + queryString +
'&refresh=Y&display_content=Y&r_page=0&groupSelectValue='+groupSelectValue);
}
getReportDataWithPageNo(reportId: string, pageNo: string): Observable<any> {
if (!pageNo || pageNo === null) {
pageNo = '0';
}
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master='
+ reportId + '&refresh=Ydisplay_content=Y&r_page=' + pageNo);
}
getReportDataWithFormFieldsWithPageNo(queryString: string, reportId: string, pageNo: string): Observable<any> {
if (!pageNo || pageNo === null) {
pageNo = '0';
}
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master='
+ reportId + queryString + '&refresh=Y&display_content=Y&r_page=' + pageNo);
}
getDefinitionPageDetails(IncomingReportId: number): Observable<any> {
return this._http.get(environment.baseUrl + 'report/wizard/retrieve_def_tab_wise_data/' + IncomingReportId, {headers: new HttpHeaders({'Content-Type': 'application/json'})});
}
refreshFormFields(reportId: string, queryString: string): Observable<any> {
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.formfields.run.container&c_master=' + reportId + queryString);
}
getFormFieldGroupsData(reportId: string): Observable<any> {
return this._http.get(environment.baseUrl + 'report/wizard/get_formfield_groups_data/' + reportId);
}
downloadReportExcel(reportId: string): Observable<Blob> {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_dowload=true', {responseType: 'blob'});
}
downloadReport(reportId: string, type: string, isGoBack: string): Observable<Blob> {
if (type === 'xlsx') {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=false&go_back=' + isGoBack, {responseType: 'blob'});
} else if (type === 'pdf') {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.pdf.session&page_download=false&go_back=' + isGoBack, {responseType: 'blob'});
} else if (type === 'zip') {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.csv.session&page_download=false&go_back=' + isGoBack, {responseType: 'blob'});
} else {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=false&go_back=' + isGoBack, {responseType: 'blob'});
}
}
downloadSinglePageReport(reportId: string, type: string, isGoBack: string): Observable<Blob> {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=true&go_back=' + isGoBack, {responseType: 'blob'});
}
getDashboardReportFormFields(reportId: string): Observable<any> {
return this._http.get(environment.baseUrl + 'raptor/dashboard/run/' + reportId);
}
runDashboardReport(reportId: string, queryString: string) {
return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master=' + reportId + queryString + '&refresh=Y&display_content=Y&r_page=0', {responseType: 'text'});
}
downloadDashboardReportExcel(reportId: string): Observable<Blob> {
return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session', {responseType: 'blob'});
}
handleError(error) {
let errorMessage = '';
if (error.error instanceof ErrorEvent) {
// client-side error
errorMessage = `Error: ${error.error.message}`;
} else {
// server-side error
errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
}
window.alert(errorMessage);
return throwError(errorMessage);
}
}
|