BP 766: switched to dto request on generating reports
diff --git a/src/app/reporting/components/standby-reporting/standby-reporting.component.ts b/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
index 3ec0c59..676372a 100644
--- a/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
+++ b/src/app/reporting/components/standby-reporting/standby-reporting.component.ts
@@ -29,6 +29,14 @@
styleUrls: ['./standby-reporting.component.scss']
})
export class StandbyReportingComponent extends AbstractFormComponent implements OnInit, OnDestroy {
+ standbylistSelectionData = [];
+ userSelectionData = [];
+ reportSelectionData = [];
+
+ isSearchingPerson = false;
+ standbyListData$: Subscription;
+ userData$: Subscription;
+ reportData$: Subscription;
constructor(
private masterDataService: MasterdataService,
@@ -38,14 +46,21 @@
super(injector);
}
- standbylistSelectionData = [];
- userSelectionData = [];
- reportSelectionData = [];
-
- isSearchingPerson = false;
- standbyListData$: Subscription;
- userData$: Subscription;
- reportData$: Subscription;
+ createForm() {
+ this.form = this.fb.group({
+ standById: ['', Validators.required],
+ reportName: ['', Validators.required],
+ date: this.fb.group({
+ validFrom: ['', Validators.required],
+ validTo: ['', Validators.required],
+ }, { validator: [DatepickerValidator.dateRangeTo('')] }),
+ validFromTime: { hour: 12, minute: 0 },
+ validToTime: { hour: 8, minute: 0 },
+ printFormat: ['', Validators.required],
+ reportLevel: ['Ist-Ebene', Validators.required],
+ statusId: 1
+ });
+ }
getFormData() {
this.standbyListData$ = this.masterDataService.getStandbyListSelection().subscribe((standbylistRes: StandbylistObject[]) => {
@@ -64,52 +79,41 @@
const formValue = this.form.getRawValue();
FormUtil.formatDates(formValue, ['validFrom', 'validTo']);
FormUtil.addTimeToDates(formValue);
- const object = {
- validFrom: formValue.validFrom,
- validTo: formValue.validTo,
- };
+ delete formValue.validFromTime;
+ delete formValue.validToTime;
if (this.isSearchingPerson) {
- object['userId'] = formValue['standById'];
+ formValue.userId = formValue.standById;
} else {
- object['standByListId'] = formValue['standById'];
+ formValue.standByListId = formValue.standById;
+ }
+ delete formValue.standById;
+
+ if (this.isSearchingPerson) {
+ delete formValue.standByListId;
+ } else {
+ delete formValue.userId;
}
- this.reportingService.generateReport(object, formValue).subscribe(response => {
+ this.reportingService.generateReport(formValue).subscribe(response => {
let mimeType = '';
- if (formValue['printFormat'] === 'pdf') {
+ if (formValue.printFormat === 'pdf') {
mimeType = 'application/pdf';
- } else if (formValue['printFormat'] === 'xlsx') {
+ } else if (formValue.printFormat === 'xlsx') {
mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
}
- this.downLoadFile
- (response,
- mimeType,
- formValue['reportName'],
- formValue['printFormat']);
- }
- );
+ this.downLoadFile(
+ response,
+ mimeType,
+ formValue.reportName,
+ formValue.printFormat
+ );
+ });
}
}
- createForm() {
- this.form = this.fb.group({
- standById: ['', Validators.required],
- reportName: ['', Validators.required],
- date: this.fb.group({
- validFrom: ['', Validators.required],
- validTo: ['', Validators.required],
- }, { validator: [DatepickerValidator.dateRangeTo('')] }),
- validFromTime: { hour: 12, minute: 0 },
- validToTime: { hour: 8, minute: 0 },
- printFormat: ['', Validators.required],
- reportLevel: ['Ist-Ebene', Validators.required],
- statusId: 1
- });
- }
-
ngOnDestroy() {
if (this.standbyListData$) {
this.standbyListData$.unsubscribe();
diff --git a/src/app/reporting/services/reporting.service.ts b/src/app/reporting/services/reporting.service.ts
index bd069fd..9f94ed2 100644
--- a/src/app/reporting/services/reporting.service.ts
+++ b/src/app/reporting/services/reporting.service.ts
@@ -28,26 +28,9 @@
return this.http.get<ReportObject[]>(`${this.utilService.readConfig('basePath')}/report/list`);
}
- generateReport(paramaterObject: Object, parameter: Object) {
-
- const printFormat = parameter['printFormat'].toLowerCase();
- const reportName = parameter['reportName'];
- const userId = paramaterObject['userId'];
- const standByListId = paramaterObject['standByListId'];
- const fromDate = paramaterObject['validFrom'];
- const toDate = paramaterObject['validTo'];
- const reportLevel = parameter['reportLevel'];
-
- let GETParameter: String = `?printFormat=${printFormat}&fromDate=${fromDate}&toDate=${toDate}&reportLevel=${reportLevel}`;
-
- if (userId != null) {
- GETParameter += `&userId=${userId}`;
- } else if (standByListId != null) {
- GETParameter += `&standByListId=${standByListId}`;
- }
-
- return this.http.get(
- `${this.utilService.readConfig('basePath')}/report/generate/${reportName}${GETParameter}`,
+ generateReport(formValue: Object) {
+ return this.http.put(
+ `${this.utilService.readConfig('basePath')}/report/generate`, formValue,
{ responseType: 'arraybuffer' }
);
}