From 4067bb6355427aef6d5a455486e82773730245e9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 27 Dec 2021 20:11:58 +0000 Subject: [PATCH] --- .../components/report-selector-control.vue | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/ayanova/src/components/report-selector-control.vue b/ayanova/src/components/report-selector-control.vue index c4bcfb79..781ad4cf 100644 --- a/ayanova/src/components/report-selector-control.vue +++ b/ayanova/src/components/report-selector-control.vue @@ -139,6 +139,76 @@ export default { this.resolve(null); } }, + async requestRender(reportId, reportName) { + if (this.$route.params.recordid == 0) { + return; + } + + const reportDataOptions = this.reportDataOptions; + if (!reportDataOptions) { + this.reject("Missing report data unable to render report"); + } + reportDataOptions.ReportId = reportId; + //Meta data from client for use by report script + reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData(); + this.rendering = true; + + try { + let jobId = await window.$gz.api.upsert( + "report/render-job", + reportDataOptions + ); + if (jobId.error) { + throw new Error(window.$gz.errorHandler.errorToString(jobId, this)); + } + jobId = jobId.jobId; + this.jobActive = true; + + let jobStatus = 1; + while (this.jobActive == true) { + await window.$gz.util.sleepAsync(500); + jobStatus = await window.$gz.api.get( + `job-operations/status/${jobId}` + ); + if (jobStatus.error) { + throw new Error( + window.$gz.errorHandler.errorToString(jobStatus, this) + ); + } + jobStatus = jobStatus.data; + if (jobStatus == 4 || jobStatus == 0) { + throw new Error("Job failed"); + } + if (jobStatus == 3) { + //success, get the report url name + const jobLogRes = await window.$gz.api.get( + `job-operations/logs/${jobId}` + ); + console.log(jobLogRes); + //todo:look for reportfilename property in job log here and then put in reportUrl + + this.jobActive = false; + } + } + //job ran to completion, get the report file name and fetch it + if (window.open(reportUrl, "Report") == null) { + this.reject( + "Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting" + ); + } + this.isVisible = false; + if (reportName != null) { + this.resolve({ name: reportName, id: reportId }); + } else { + this.resolve(null); + } + } catch (error) { + this.jobActive = false; + this.reject(res); + //window.$gz.errorHandler.handleFormError(error, this); + //window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed")); + } + }, async open(reportDataOptions, preSelectReportId) { const vm = this; if (reportDataOptions == null) {