Run and Download direct table reports as XLS file
This commit is contained in:
committed by
Adam Saghy
parent
780c469ee4
commit
ba7a5dbca9
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<mat-card *ngIf="!isCollapsed">
|
<mat-card *ngIf="!isCollapsed">
|
||||||
|
|
||||||
<form [formGroup]="reportForm" (ngSubmit)="run()">
|
<form [formGroup]="reportForm">
|
||||||
|
|
||||||
<mat-card-content fxLayout="column">
|
<mat-card-content fxLayout="column">
|
||||||
|
|
||||||
@@ -78,10 +78,14 @@
|
|||||||
|
|
||||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||||
<button type="button" mat-raised-button [routerLink]="['/reports']">{{"labels.buttons.Cancel" | translate}}</button>
|
<button type="button" mat-raised-button [routerLink]="['/reports']">{{"labels.buttons.Cancel" | translate}}</button>
|
||||||
<button mat-raised-button color="primary" [disabled]="!reportForm.valid" id="runreport">
|
<button mat-raised-button color="primary" [disabled]="!reportForm.valid || isProcessing" id="runreport" (click)="run()">
|
||||||
<fa-icon icon="file-export" class="m-r-10"></fa-icon>
|
<fa-icon icon="file-export" class="m-r-10"></fa-icon>
|
||||||
{{"labels.buttons.Run Report" | translate}}
|
{{"labels.buttons.Run Report" | translate}}
|
||||||
</button>
|
</button>
|
||||||
|
<button *ngIf="isTableReport()" mat-raised-button color="primary" [disabled]="!reportForm.valid || isProcessing" (click)="runReportAndExport($event)">
|
||||||
|
<fa-icon icon="download" class="m-r-10"></fa-icon>
|
||||||
|
{{"labels.buttons.Run and Download Report" | translate}}
|
||||||
|
</button>
|
||||||
</mat-card-actions>
|
</mat-card-actions>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import { ReportParameter } from '../common-models/report-parameter.model';
|
|||||||
import { SelectOption } from '../common-models/select-option.model';
|
import { SelectOption } from '../common-models/select-option.model';
|
||||||
import { Dates } from 'app/core/utils/dates';
|
import { Dates } from 'app/core/utils/dates';
|
||||||
import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model';
|
import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model';
|
||||||
import { ProgressBarService } from 'app/core/progress-bar/progress-bar.service';
|
|
||||||
|
import * as XLSX from 'xlsx';
|
||||||
|
import { AlertService } from 'app/core/alert/alert.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run report component.
|
* Run report component.
|
||||||
@@ -60,6 +62,8 @@ export class RunReportComponent implements OnInit {
|
|||||||
exportToS3Repository: string;
|
exportToS3Repository: string;
|
||||||
outputTypeOptions: any[] = [];
|
outputTypeOptions: any[] = [];
|
||||||
|
|
||||||
|
isProcessing = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches report specifications from route params and retrieves report parameters data from `resolve`.
|
* Fetches report specifications from route params and retrieves report parameters data from `resolve`.
|
||||||
* @param {ActivatedRoute} route ActivatedRoute.
|
* @param {ActivatedRoute} route ActivatedRoute.
|
||||||
@@ -70,8 +74,8 @@ export class RunReportComponent implements OnInit {
|
|||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private reportsService: ReportsService,
|
private reportsService: ReportsService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
private dateUtils: Dates,
|
private alertService: AlertService,
|
||||||
private progressBarService: ProgressBarService) {
|
private dateUtils: Dates) {
|
||||||
this.report.name = this.route.snapshot.params['name'];
|
this.report.name = this.route.snapshot.params['name'];
|
||||||
this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => {
|
this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => {
|
||||||
this.report.type = queryParams.type;
|
this.report.type = queryParams.type;
|
||||||
@@ -290,4 +294,48 @@ export class RunReportComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runReportAndExport($event: Event): void {
|
||||||
|
$event.stopPropagation();
|
||||||
|
this.isProcessing = true;
|
||||||
|
const userResponseValues = this.formatUserResponse(this.reportForm.value);
|
||||||
|
|
||||||
|
const reportName = this.report.name;
|
||||||
|
const payload = {
|
||||||
|
...userResponseValues,
|
||||||
|
decimalChoice: this.decimalChoice.value,
|
||||||
|
// exportCSV: true
|
||||||
|
};
|
||||||
|
this.reportsService.getRunReportData(reportName, payload)
|
||||||
|
.subscribe( (res: any) => {
|
||||||
|
if (res.data.length > 0) {
|
||||||
|
this.alertService.alert({type: 'Report generation', message: `Report: ${reportName} data generated`});
|
||||||
|
|
||||||
|
const displayedColumns: string[] = [];
|
||||||
|
res.columnHeaders.forEach((header: any) => {
|
||||||
|
displayedColumns.push(header.columnName);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.exportToXLS(reportName, res.data, displayedColumns);
|
||||||
|
} else {
|
||||||
|
this.alertService.alert({type: 'Report generation', message: `Report: ${reportName} without data generated`});
|
||||||
|
}
|
||||||
|
this.isProcessing = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exportToXLS(reportName: string, csvData: any, displayedColumns: string[]): void {
|
||||||
|
const fileName = `${reportName}.xlsx`;
|
||||||
|
const data = csvData.map((object: any) => {
|
||||||
|
const row = {};
|
||||||
|
for (let i = 0; i < displayedColumns.length; i++) {
|
||||||
|
row[displayedColumns[i]] = object.row[i];
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
});
|
||||||
|
const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(data, {header: displayedColumns});
|
||||||
|
const wb: XLSX.WorkBook = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(wb, ws, 'report');
|
||||||
|
XLSX.writeFile(wb, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class ViewUserComponent implements OnInit {
|
|||||||
if (response.delete) {
|
if (response.delete) {
|
||||||
this.usersService.deleteUser(this.userData.id)
|
this.usersService.deleteUser(this.userData.id)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.router.navigate(['/users']);
|
this.router.navigate(['/appusers']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -74,7 +74,7 @@ export class ViewUserComponent implements OnInit {
|
|||||||
const firstname = this.userData.firstname;
|
const firstname = this.userData.firstname;
|
||||||
const data = {password: password, repeatPassword: repeatPassword, firstname: firstname};
|
const data = {password: password, repeatPassword: repeatPassword, firstname: firstname};
|
||||||
this.usersService.changePassword(this.userData.id, data).subscribe(() => {
|
this.usersService.changePassword(this.userData.id, data).subscribe(() => {
|
||||||
this.router.navigate(['/users']);
|
this.router.navigate(['/appusers']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Obnovit heslo",
|
"Reset Password": "Obnovit heslo",
|
||||||
"Retrieve": "Načíst",
|
"Retrieve": "Načíst",
|
||||||
"Revert Transaction": "Vrátit transakci",
|
"Revert Transaction": "Vrátit transakci",
|
||||||
|
"Run and Download Report": "Spusťte a stahujte zprávu",
|
||||||
"Run Catch-Up": "Spusťte Catch-Up",
|
"Run Catch-Up": "Spusťte Catch-Up",
|
||||||
"Run Periodic Accruals": "Spusťte periodické časové rozlišení",
|
"Run Periodic Accruals": "Spusťte periodické časové rozlišení",
|
||||||
"Run Report": "Spustit zprávu",
|
"Run Report": "Spustit zprávu",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Passwort zurücksetzen",
|
"Reset Password": "Passwort zurücksetzen",
|
||||||
"Retrieve": "Abrufen",
|
"Retrieve": "Abrufen",
|
||||||
"Revert Transaction": "Transaktion rückgängig machen",
|
"Revert Transaction": "Transaktion rückgängig machen",
|
||||||
|
"Run and Download Report": "Bericht ausführen und herunterladen",
|
||||||
"Run Catch-Up": "Führen Sie Catch-Up durch",
|
"Run Catch-Up": "Führen Sie Catch-Up durch",
|
||||||
"Run Periodic Accruals": "Führen Sie periodische Rückstellungen durch",
|
"Run Periodic Accruals": "Führen Sie periodische Rückstellungen durch",
|
||||||
"Run Report": "Bericht ausführen",
|
"Run Report": "Bericht ausführen",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Reset Password",
|
"Reset Password": "Reset Password",
|
||||||
"Retrieve": "Retrieve",
|
"Retrieve": "Retrieve",
|
||||||
"Revert Transaction": "Revert Transaction",
|
"Revert Transaction": "Revert Transaction",
|
||||||
|
"Run and Download Report": "Run and Download Report",
|
||||||
"Run Catch-Up": "Run Catch-Up",
|
"Run Catch-Up": "Run Catch-Up",
|
||||||
"Run Periodic Accruals": "Run Periodic Accruals",
|
"Run Periodic Accruals": "Run Periodic Accruals",
|
||||||
"Run Report": "Run Report",
|
"Run Report": "Run Report",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Restablecer la contraseña",
|
"Reset Password": "Restablecer la contraseña",
|
||||||
"Retrieve": "Recuperar",
|
"Retrieve": "Recuperar",
|
||||||
"Revert Transaction": "Revertir transacción",
|
"Revert Transaction": "Revertir transacción",
|
||||||
|
"Run and Download Report": "Ejecutar y descargar informe",
|
||||||
"Run Catch-Up": "Correr para ponerse al día",
|
"Run Catch-Up": "Correr para ponerse al día",
|
||||||
"Run Periodic Accruals": "Ejecutar acumulaciones periódicas",
|
"Run Periodic Accruals": "Ejecutar acumulaciones periódicas",
|
||||||
"Run Report": "Sacar un reporte",
|
"Run Report": "Sacar un reporte",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "réinitialiser le mot de passe",
|
"Reset Password": "réinitialiser le mot de passe",
|
||||||
"Retrieve": "Récupérer",
|
"Retrieve": "Récupérer",
|
||||||
"Revert Transaction": "Annuler la transaction",
|
"Revert Transaction": "Annuler la transaction",
|
||||||
|
"Run and Download Report": "Rapport d'exécution et de téléchargement",
|
||||||
"Run Catch-Up": "Exécuter un rattrapage",
|
"Run Catch-Up": "Exécuter un rattrapage",
|
||||||
"Run Periodic Accruals": "Exécuter des régularisations périodiques",
|
"Run Periodic Accruals": "Exécuter des régularisations périodiques",
|
||||||
"Run Report": "Rapport d'exécution",
|
"Run Report": "Rapport d'exécution",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Resetta la password",
|
"Reset Password": "Resetta la password",
|
||||||
"Retrieve": "Recuperare",
|
"Retrieve": "Recuperare",
|
||||||
"Revert Transaction": "Annulla transazione",
|
"Revert Transaction": "Annulla transazione",
|
||||||
|
"Run and Download Report": "Esegui e scarica il rapporto",
|
||||||
"Run Catch-Up": "Esegui il recupero",
|
"Run Catch-Up": "Esegui il recupero",
|
||||||
"Run Periodic Accruals": "Esegui ratei periodici",
|
"Run Periodic Accruals": "Esegui ratei periodici",
|
||||||
"Run Report": "Esegui rapporto",
|
"Run Report": "Esegui rapporto",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "암호를 재설정",
|
"Reset Password": "암호를 재설정",
|
||||||
"Retrieve": "검색하다",
|
"Retrieve": "검색하다",
|
||||||
"Revert Transaction": "거래 되돌리기",
|
"Revert Transaction": "거래 되돌리기",
|
||||||
|
"Run and Download Report": "보고서를 실행하고 다운로드하십시오",
|
||||||
"Run Catch-Up": "따라잡기 실행",
|
"Run Catch-Up": "따라잡기 실행",
|
||||||
"Run Periodic Accruals": "정기적인 발생 실행",
|
"Run Periodic Accruals": "정기적인 발생 실행",
|
||||||
"Run Report": "보고서 실행",
|
"Run Report": "보고서 실행",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Atstatyti slaptažodį",
|
"Reset Password": "Atstatyti slaptažodį",
|
||||||
"Retrieve": "Atgauti",
|
"Retrieve": "Atgauti",
|
||||||
"Revert Transaction": "Grąžinti operaciją",
|
"Revert Transaction": "Grąžinti operaciją",
|
||||||
|
"Run and Download Report": "Paleisti ir atsisiųsti ataskaitą",
|
||||||
"Run Catch-Up": "Vykdykite „Catch-Up“.",
|
"Run Catch-Up": "Vykdykite „Catch-Up“.",
|
||||||
"Run Periodic Accruals": "Vykdykite periodinius kaupimus",
|
"Run Periodic Accruals": "Vykdykite periodinius kaupimus",
|
||||||
"Run Report": "Vykdyti ataskaitą",
|
"Run Report": "Vykdyti ataskaitą",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Atiestatīt paroli",
|
"Reset Password": "Atiestatīt paroli",
|
||||||
"Retrieve": "Atgūt",
|
"Retrieve": "Atgūt",
|
||||||
"Revert Transaction": "Atsaukt darījumu",
|
"Revert Transaction": "Atsaukt darījumu",
|
||||||
|
"Run and Download Report": "Palaist un lejupielādēt pārskatu",
|
||||||
"Run Catch-Up": "Palaist Catch-Up",
|
"Run Catch-Up": "Palaist Catch-Up",
|
||||||
"Run Periodic Accruals": "Veiciet periodiskus uzkrājumus",
|
"Run Periodic Accruals": "Veiciet periodiskus uzkrājumus",
|
||||||
"Run Report": "Palaist ziņojumu",
|
"Run Report": "Palaist ziņojumu",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "पासवर्ड रिसेट",
|
"Reset Password": "पासवर्ड रिसेट",
|
||||||
"Retrieve": "पुन: प्राप्त गर्नुहोस्",
|
"Retrieve": "पुन: प्राप्त गर्नुहोस्",
|
||||||
"Revert Transaction": "लेनदेन उल्टाउनुहोस्",
|
"Revert Transaction": "लेनदेन उल्टाउनुहोस्",
|
||||||
|
"Run and Download Report": "रन र डाउनलोड रिपोर्ट डाउनलोड गर्नुहोस्",
|
||||||
"Run Catch-Up": "क्याच-अप चलाउनुहोस्",
|
"Run Catch-Up": "क्याच-अप चलाउनुहोस्",
|
||||||
"Run Periodic Accruals": "आवधिक आम्दानी चलाउनुहोस्",
|
"Run Periodic Accruals": "आवधिक आम्दानी चलाउनुहोस्",
|
||||||
"Run Report": "रिपोर्ट चलाउनुहोस्",
|
"Run Report": "रिपोर्ट चलाउनुहोस्",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Redefinir senha",
|
"Reset Password": "Redefinir senha",
|
||||||
"Retrieve": "Recuperar",
|
"Retrieve": "Recuperar",
|
||||||
"Revert Transaction": "Reverter transação",
|
"Revert Transaction": "Reverter transação",
|
||||||
|
"Run and Download Report": "Relatório de execução e download",
|
||||||
"Run Catch-Up": "Execute o catch-up",
|
"Run Catch-Up": "Execute o catch-up",
|
||||||
"Run Periodic Accruals": "Executar acumulações periódicas",
|
"Run Periodic Accruals": "Executar acumulações periódicas",
|
||||||
"Run Report": "Executar relatório",
|
"Run Report": "Executar relatório",
|
||||||
|
|||||||
@@ -446,6 +446,7 @@
|
|||||||
"Reset Password": "Weka upya Nenosiri",
|
"Reset Password": "Weka upya Nenosiri",
|
||||||
"Retrieve": "Rejesha",
|
"Retrieve": "Rejesha",
|
||||||
"Revert Transaction": "Rejesha Muamala",
|
"Revert Transaction": "Rejesha Muamala",
|
||||||
|
"Run and Download Report": "Kukimbia na kupakua ripoti",
|
||||||
"Run Catch-Up": "Run Catch-Up",
|
"Run Catch-Up": "Run Catch-Up",
|
||||||
"Run Periodic Accruals": "Endesha Mapato ya Mara kwa Mara",
|
"Run Periodic Accruals": "Endesha Mapato ya Mara kwa Mara",
|
||||||
"Run Report": "Endesha Ripoti",
|
"Run Report": "Endesha Ripoti",
|
||||||
|
|||||||
Reference in New Issue
Block a user