diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run.service.ts')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run.service.ts | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run.service.ts new file mode 100644 index 00000000..21f94831 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run.service.ts @@ -0,0 +1,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); + } +} |