Commit 908833ff by chamath

Download summary report PDF.

parent 8163f7e3
......@@ -97,7 +97,7 @@
</div>
<div class="d-flex justify-content-between" style="margin: 20px 30px;">
<button pButton label="Download" class="ui-button-info">
<button pButton label="Download" class="ui-button-info" (click)="downloadSummaryReport()">
</button>
......
import { Component, OnInit } from '@angular/core';
import { BaseComponent } from '../../base/base.component';
import { HelperService } from '../../services/helper.service';
import { AssessmentService } from '../../services/assessment.service';
import * as FileSaver from 'file-saver';
import { takeUntil } from 'rxjs/operators';
import { UtilsService } from '../../../oneit/services/utils.service';
import { BaseComponent } from '../../base/base.component';
import { SummaryReportModel } from '../../models/summary-report.model';
import { AssessmentService } from '../../services/assessment.service';
import { HelperService } from '../../services/helper.service';
@Component({
selector: 'app-summary-report',
......@@ -59,4 +60,17 @@ export class SummaryReportComponent extends BaseComponent implements OnInit {
});
}
downloadSummaryReport() {
this.isLoading = true;
this.assessmentService.downloadSummaryReport()
.pipe(takeUntil(this.componentInView))
.subscribe((response) => {
this.isLoading = false;
FileSaver.saveAs(response.content, 'Summary Report.pdf');
}, err => {
this.utilsService.handleError(err);
this.isLoading = false;
});
}
}
......@@ -49,9 +49,20 @@ export class AssessmentService {
)
}
saveWorkStyle(params): Observable<any> {
return this.utilsService.processObjects('SaveWorkStyle', params);
}
downloadSummaryReport(): Observable<any> {
return this.searchService.getObjectsWithDocument('SummaryReport', 'All', {}, [], null, null, null, null, 'SummaryReportPDF', false)
.map(
data => {
if (data !== undefined && data !== '') {
return data;
}
}
);
}
saveWorkStyle(params): Observable<any> {
return this.utilsService.processObjects('SaveWorkStyle', params);
}
saveWorkPreferences(params): Observable<any> {
return this.utilsService.processObjects('SaveWorkPreferences', params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment