diff --git a/ayanova/src/components/report-selector-control.vue b/ayanova/src/components/report-selector-control.vue index a0632805..358fbe44 100644 --- a/ayanova/src/components/report-selector-control.vue +++ b/ayanova/src/components/report-selector-control.vue @@ -152,7 +152,7 @@ export default { //Meta data from client for use by report script reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData(); this.rendering = true; - + const reportUrl = null; try { let jobId = await window.$gz.api.upsert( "report/render-job", @@ -184,17 +184,52 @@ export default { const jobLogRes = await window.$gz.api.get( `job-operations/logs/${jobId}` ); - console.log(jobLogRes); + //console.log(jobLogRes); //todo:look for reportfilename property in job log here and then put in reportUrl - + //debugger; + if (Array.isArray(jobLogRes.data)) { + //walk the array backwards as it's probably the final entry in the log + for (var i = jobLogRes.data.length - 1; i >= 0; i--) { + var v = jobLogRes.data[i].statusText; + //console.log("value type is:", typeof v); + if (v.includes("reportfilename")) { + console.log("Parsing:", v); + const o = JSON.parse(v); + reportUrl = window.$gz.api.reportDownloadUrl( + o.reportFileName + ); + } + } + } + /* +[ + { + "created": "2021-12-27T20:23:54.145758Z", + "statusText": "LT:ProcessingJob \"LT:Report id: \"60\" LT:WorkOrder (1) LT:User AyaNova SuperUser - RenderReport\"", + "jobId": "62f78eb6-7744-4bbc-bd93-00848110219c" + }, + { + "created": "2021-12-27T20:23:54.156294Z", + "statusText": "LT:StartJob RenderReport", + "jobId": "62f78eb6-7744-4bbc-bd93-00848110219c" + }, + { + "created": "2021-12-27T20:23:55.820618Z", + "statusText": "{reportfilename:\"4jpsvserib2.pdf\"}", + "jobId": "62f78eb6-7744-4bbc-bd93-00848110219c" + } +] +*/ 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" - ); + if (reportUrl) { + 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) { @@ -204,7 +239,7 @@ export default { } } catch (error) { this.jobActive = false; - this.reject(res); + this.reject(error); //window.$gz.errorHandler.handleFormError(error, this); //window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed")); }