diff --git a/src/app/reports/run-report/run-report.component.html b/src/app/reports/run-report/run-report.component.html index aded44d6f..041b1b24b 100644 --- a/src/app/reports/run-report/run-report.component.html +++ b/src/app/reports/run-report/run-report.component.html @@ -2,7 +2,7 @@ -
+ @@ -78,10 +78,14 @@ - + diff --git a/src/app/reports/run-report/run-report.component.ts b/src/app/reports/run-report/run-report.component.ts index 84f5e7b12..b5ddf3792 100644 --- a/src/app/reports/run-report/run-report.component.ts +++ b/src/app/reports/run-report/run-report.component.ts @@ -12,7 +12,9 @@ import { ReportParameter } from '../common-models/report-parameter.model'; import { SelectOption } from '../common-models/select-option.model'; import { Dates } from 'app/core/utils/dates'; 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. @@ -60,6 +62,8 @@ export class RunReportComponent implements OnInit { exportToS3Repository: string; outputTypeOptions: any[] = []; + isProcessing = false; + /** * Fetches report specifications from route params and retrieves report parameters data from `resolve`. * @param {ActivatedRoute} route ActivatedRoute. @@ -70,8 +74,8 @@ export class RunReportComponent implements OnInit { constructor(private route: ActivatedRoute, private reportsService: ReportsService, private settingsService: SettingsService, - private dateUtils: Dates, - private progressBarService: ProgressBarService) { + private alertService: AlertService, + private dateUtils: Dates) { this.report.name = this.route.snapshot.params['name']; this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => { 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); + } + } diff --git a/src/app/users/view-user/view-user.component.ts b/src/app/users/view-user/view-user.component.ts index 9c1d4c401..9ddfa07bf 100644 --- a/src/app/users/view-user/view-user.component.ts +++ b/src/app/users/view-user/view-user.component.ts @@ -53,7 +53,7 @@ export class ViewUserComponent implements OnInit { if (response.delete) { this.usersService.deleteUser(this.userData.id) .subscribe(() => { - this.router.navigate(['/users']); + this.router.navigate(['/appusers']); }); } }); @@ -74,7 +74,7 @@ export class ViewUserComponent implements OnInit { const firstname = this.userData.firstname; const data = {password: password, repeatPassword: repeatPassword, firstname: firstname}; this.usersService.changePassword(this.userData.id, data).subscribe(() => { - this.router.navigate(['/users']); + this.router.navigate(['/appusers']); }); } }); diff --git a/src/assets/translations/cs-CS.json b/src/assets/translations/cs-CS.json index d8da231ff..69c98508d 100644 --- a/src/assets/translations/cs-CS.json +++ b/src/assets/translations/cs-CS.json @@ -446,6 +446,7 @@ "Reset Password": "Obnovit heslo", "Retrieve": "Načíst", "Revert Transaction": "Vrátit transakci", + "Run and Download Report": "Spusťte a stahujte zprávu", "Run Catch-Up": "Spusťte Catch-Up", "Run Periodic Accruals": "Spusťte periodické časové rozlišení", "Run Report": "Spustit zprávu", diff --git a/src/assets/translations/de-DE.json b/src/assets/translations/de-DE.json index d49ebc918..461e437a7 100644 --- a/src/assets/translations/de-DE.json +++ b/src/assets/translations/de-DE.json @@ -446,6 +446,7 @@ "Reset Password": "Passwort zurücksetzen", "Retrieve": "Abrufen", "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 Periodic Accruals": "Führen Sie periodische Rückstellungen durch", "Run Report": "Bericht ausführen", diff --git a/src/assets/translations/en-US.json b/src/assets/translations/en-US.json index 6616d885d..ac629292e 100644 --- a/src/assets/translations/en-US.json +++ b/src/assets/translations/en-US.json @@ -446,6 +446,7 @@ "Reset Password": "Reset Password", "Retrieve": "Retrieve", "Revert Transaction": "Revert Transaction", + "Run and Download Report": "Run and Download Report", "Run Catch-Up": "Run Catch-Up", "Run Periodic Accruals": "Run Periodic Accruals", "Run Report": "Run Report", diff --git a/src/assets/translations/es-MX.json b/src/assets/translations/es-MX.json index a1a7b4a82..b75efde14 100644 --- a/src/assets/translations/es-MX.json +++ b/src/assets/translations/es-MX.json @@ -446,6 +446,7 @@ "Reset Password": "Restablecer la contraseña", "Retrieve": "Recuperar", "Revert Transaction": "Revertir transacción", + "Run and Download Report": "Ejecutar y descargar informe", "Run Catch-Up": "Correr para ponerse al día", "Run Periodic Accruals": "Ejecutar acumulaciones periódicas", "Run Report": "Sacar un reporte", diff --git a/src/assets/translations/fr-FR.json b/src/assets/translations/fr-FR.json index 4103af9b0..153132060 100644 --- a/src/assets/translations/fr-FR.json +++ b/src/assets/translations/fr-FR.json @@ -446,6 +446,7 @@ "Reset Password": "réinitialiser le mot de passe", "Retrieve": "Récupérer", "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 Periodic Accruals": "Exécuter des régularisations périodiques", "Run Report": "Rapport d'exécution", diff --git a/src/assets/translations/it-IT.json b/src/assets/translations/it-IT.json index 6df4778b0..57726777f 100644 --- a/src/assets/translations/it-IT.json +++ b/src/assets/translations/it-IT.json @@ -446,6 +446,7 @@ "Reset Password": "Resetta la password", "Retrieve": "Recuperare", "Revert Transaction": "Annulla transazione", + "Run and Download Report": "Esegui e scarica il rapporto", "Run Catch-Up": "Esegui il recupero", "Run Periodic Accruals": "Esegui ratei periodici", "Run Report": "Esegui rapporto", diff --git a/src/assets/translations/ko-KO.json b/src/assets/translations/ko-KO.json index 3b22b6026..1d90192c8 100644 --- a/src/assets/translations/ko-KO.json +++ b/src/assets/translations/ko-KO.json @@ -446,6 +446,7 @@ "Reset Password": "암호를 재설정", "Retrieve": "검색하다", "Revert Transaction": "거래 되돌리기", + "Run and Download Report": "보고서를 실행하고 다운로드하십시오", "Run Catch-Up": "따라잡기 실행", "Run Periodic Accruals": "정기적인 발생 실행", "Run Report": "보고서 실행", diff --git a/src/assets/translations/lt-LT.json b/src/assets/translations/lt-LT.json index 438b604db..c49f3090b 100644 --- a/src/assets/translations/lt-LT.json +++ b/src/assets/translations/lt-LT.json @@ -446,6 +446,7 @@ "Reset Password": "Atstatyti slaptažodį", "Retrieve": "Atgauti", "Revert Transaction": "Grąžinti operaciją", + "Run and Download Report": "Paleisti ir atsisiųsti ataskaitą", "Run Catch-Up": "Vykdykite „Catch-Up“.", "Run Periodic Accruals": "Vykdykite periodinius kaupimus", "Run Report": "Vykdyti ataskaitą", diff --git a/src/assets/translations/lv-LV.json b/src/assets/translations/lv-LV.json index 4579bb91b..da52d3670 100644 --- a/src/assets/translations/lv-LV.json +++ b/src/assets/translations/lv-LV.json @@ -446,6 +446,7 @@ "Reset Password": "Atiestatīt paroli", "Retrieve": "Atgūt", "Revert Transaction": "Atsaukt darījumu", + "Run and Download Report": "Palaist un lejupielādēt pārskatu", "Run Catch-Up": "Palaist Catch-Up", "Run Periodic Accruals": "Veiciet periodiskus uzkrājumus", "Run Report": "Palaist ziņojumu", diff --git a/src/assets/translations/ne-NE.json b/src/assets/translations/ne-NE.json index 6e46ea8a5..b69dfc761 100644 --- a/src/assets/translations/ne-NE.json +++ b/src/assets/translations/ne-NE.json @@ -446,6 +446,7 @@ "Reset Password": "पासवर्ड रिसेट", "Retrieve": "पुन: प्राप्त गर्नुहोस्", "Revert Transaction": "लेनदेन उल्टाउनुहोस्", + "Run and Download Report": "रन र डाउनलोड रिपोर्ट डाउनलोड गर्नुहोस्", "Run Catch-Up": "क्याच-अप चलाउनुहोस्", "Run Periodic Accruals": "आवधिक आम्दानी चलाउनुहोस्", "Run Report": "रिपोर्ट चलाउनुहोस्", diff --git a/src/assets/translations/pt-PT.json b/src/assets/translations/pt-PT.json index 16e0ea188..52d21ed93 100644 --- a/src/assets/translations/pt-PT.json +++ b/src/assets/translations/pt-PT.json @@ -446,6 +446,7 @@ "Reset Password": "Redefinir senha", "Retrieve": "Recuperar", "Revert Transaction": "Reverter transação", + "Run and Download Report": "Relatório de execução e download", "Run Catch-Up": "Execute o catch-up", "Run Periodic Accruals": "Executar acumulações periódicas", "Run Report": "Executar relatório", diff --git a/src/assets/translations/sw-SW.json b/src/assets/translations/sw-SW.json index 1e46a8587..8a40d905c 100644 --- a/src/assets/translations/sw-SW.json +++ b/src/assets/translations/sw-SW.json @@ -446,6 +446,7 @@ "Reset Password": "Weka upya Nenosiri", "Retrieve": "Rejesha", "Revert Transaction": "Rejesha Muamala", + "Run and Download Report": "Kukimbia na kupakua ripoti", "Run Catch-Up": "Run Catch-Up", "Run Periodic Accruals": "Endesha Mapato ya Mara kwa Mara", "Run Report": "Endesha Ripoti",