1 import { Injectable } from '@angular/core';
2 import { HttpClient, HttpHeaders } from '@angular/common/http';
3 import { Observable, throwError } from 'rxjs';
4 import { retry, catchError } from 'rxjs/operators';
5 import { environment } from '../../../../../../environments/environment';
6 import { HtmlParser } from '@angular/compiler';
11 export class RunService {
13 finalResponseArr: any;
15 constructor(private _http: HttpClient) {
20 getReportData(reportId: string): Observable<any> {
21 return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master=' + reportId + '&refresh=Y');
24 getReportDataWithFormFields(queryString: string, reportId: string): Observable<any> {
25 return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master=' + reportId + queryString + '&refresh=Y&display_content=Y&r_page=0');
28 getReportDataWithPageNo(reportId: string, pageNo: string): Observable<any> {
29 if (!pageNo || pageNo === null) {
32 return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master='
33 + reportId + '&refresh=Ydisplay_content=Y&r_page=' + pageNo);
36 getReportDataWithFormFieldsWithPageNo(queryString: string, reportId: string, pageNo: string): Observable<any> {
37 if (!pageNo || pageNo === null) {
40 return this._http.get(environment.baseUrl + 'raptor.htm?action=report.run.container&c_master='
41 + reportId + queryString + '&refresh=Y&display_content=Y&r_page=' + pageNo);
44 getDefinitionPageDetails(IncomingReportId: number): Observable<any> {
45 return this._http.get(environment.baseUrl + 'report/wizard/retrieve_def_tab_wise_data/' + IncomingReportId, { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) });
48 refreshFormFields(reportId: string, queryString: string): Observable<any> {
49 return this._http.get(environment.baseUrl + 'raptor.htm?action=report.formfields.run.container&c_master=' + reportId + queryString);
52 getFormFieldGroupsData(reportId: string): Observable<any> {
53 return this._http.get(environment.baseUrl + 'report/wizard/get_formfield_groups_data/' + reportId);
56 downloadReportExcel(reportId: string): Observable<Blob> {
57 return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_dowload=true', { responseType: 'blob' });
60 downloadReport(reportId: string, type: string): Observable<Blob> {
61 if (type === 'xlsx') {
62 return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=false', { responseType: 'blob' });
63 } else if (type === 'pdf') {
64 return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.pdf.session&page_download=false', { responseType: 'blob' });
68 downloadSinglePageReport(reportId: string, type: string): Observable<Blob> {
69 return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=true', { responseType: 'blob' });
74 getDashboardReportFormFields(reportId: string): Observable<any> {
75 return this._http.get(environment.baseUrl + 'raptor/dashboard/run/' + reportId);
78 runDashboardReport(reportId: string, queryString: string) {
79 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' });
82 downloadDashboardReportExcel(reportId: string): Observable<Blob> {
83 return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session', { responseType: 'blob' });
86 proceedWithLoad(object: Object) {
87 const headers = new HttpHeaders({
88 'Content-Type': 'application/json'
90 return this._http.post(environment.baseUrl + 'proceed-with-load', object, { headers });
93 onDeleteFromUploadedReport(object: Object): Observable<any> {
94 const headers = new HttpHeaders({
95 'Content-Type': 'application/json'
97 return this._http.post(environment.baseUrl + "delete-upload", object, { headers });
99 onResubmitUnplannedLTEUploadedReport(object: Object): Observable<any> {
100 const headers = new HttpHeaders({
101 'Content-Type': 'application/json'
103 return this._http.post(environment.baseUrl + "resubmit-unplanned-lte-upload", object, { headers })
105 catchError(this.handleError)
109 onAutomaticUploadedReport(): Observable<any> {
110 const headers = new HttpHeaders({
111 'Content-Type': 'application/json'
113 return this._http.post(environment.baseUrl + 'automated-upload?'+'parentReportId=25633'+'&templateName=SUPER_E911_4G',{headers})
116 catchError(this.handleError)
121 onSubmitApproved(object:Object):Observable<any>{
122 const headers = new HttpHeaders({
123 'Content-Type': 'application/json'
126 return this._http.post(environment.baseUrl + 'submit-approval',object,{headers})
129 catchError(this.handleError)
134 let errorMessage = '';
135 if (error.error instanceof ErrorEvent) {
137 errorMessage = `Error: ${error.error.message}`;
140 errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
142 window.alert(errorMessage);
143 return throwError(errorMessage);