summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.service.ts
blob: 6e44a6981f97b1dc9c8d4dbed06daacf5db485b1 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { retry, catchError } from 'rxjs/operators';
import { environment } from '../../../../../../environments/environment';
import { HtmlParser } from '@angular/compiler';

@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): 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');
    }

    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): 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', { 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', { responseType: 'blob' });
        }
    }

    downloadSinglePageReport(reportId: string, type: string): Observable<Blob> {
        return this._http.get(environment.baseUrl + 'raptor.htm?c_master=' + reportId + '&r_action=report.download.excel.session&page_download=true', { 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' });
    }

    proceedWithLoad(object: Object) {
        const headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });
        return this._http.post(environment.baseUrl + 'proceed-with-load', object, { headers });
    }

    onDeleteFromUploadedReport(object: Object): Observable<any> {
        const headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });
        return this._http.post(environment.baseUrl + "delete-upload", object, { headers });
    }
    onResubmitUnplannedLTEUploadedReport(object: Object): Observable<any> {
        const headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });
        return this._http.post(environment.baseUrl + "resubmit-unplanned-lte-upload", object, { headers })
        .pipe(retry(1),
         catchError(this.handleError)
        );
    }

    onAutomaticUploadedReport(): Observable<any> {
        const headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });
        return this._http.post(environment.baseUrl + 'automated-upload?'+'parentReportId=25633'+'&templateName=SUPER_E911_4G',{headers})
        .pipe(
            retry(1),
            catchError(this.handleError)
        );

    }
    
    onSubmitApproved(object:Object):Observable<any>{
        const headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });    

        return this._http.post(environment.baseUrl + 'submit-approval',object,{headers})
        .pipe(
            retry(1),
            catchError(this.handleError)
        );
    }
    
    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);
    }
}