From 61d344d1249cec06425a678117be25ef91107d34 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Dec 2021 16:24:36 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 3 + ayanova/src/components/report-control.vue | 82 ++++++++++++++++++----- ayanova/src/views/ay-report-edit.vue | 10 +-- 3 files changed, 75 insertions(+), 20 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 76508a72..7c8076b4 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -300,6 +300,9 @@ TESTING INFO: - MUST: Must test a timeout to ensure the error displays correctly in the report-control because only developed against manual cancel so far with new system set to 1m timeout and then run a ginormous report or temp set server to always timeout is probably better for testing purposes - report designer print needs to be fixed to use new system + - Must test error condition due to report template fucked up + - must test timeout error + - must test exception not due to report template bug (i.e. server exception of some kind) - direct print report from url must be tested and fixed up - upload and test on devops - give to Joyce to mangle diff --git a/ayanova/src/components/report-control.vue b/ayanova/src/components/report-control.vue index 048fcffa..528c9cbf 100644 --- a/ayanova/src/components/report-control.vue +++ b/ayanova/src/components/report-control.vue @@ -161,29 +161,79 @@ export default { ); } jobStatus = jobStatus.data; - if (jobStatus == 4 || jobStatus == 0) { - throw new Error("Job failed"); - } - if (jobStatus == 3) { + + /* + Absent = 0, + Sleeping = 1, + Running = 2, + Completed = 3, + Failed = 4 +*/ + //check for any terminal status + if (jobStatus != 1 && jobStatus != 2) { this.jobActive = false; - //success, get the report url name const jobLogRes = await window.$gz.api.get( `job-operations/logs/${jobId}` ); - 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; - if (v.includes("reportfilename")) { - const o = JSON.parse(v); - reportUrl = window.$gz.api.reportDownloadUrl( - o.reportfilename - ); + //get final entry is error or success + var finalEntry = jobLogRes.data[jobLogRes.data.length - 1]; + console.log("final entry:", finalEntry); + + // 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; + // if (v.includes("reportfilename")) { + // const o = JSON.parse(v); + // reportUrl = window.$gz.api.reportDownloadUrl( + // o.reportfilename + // ); + // } + // } + // } + + if (jobStatus == 4 || jobStatus == 0) { + + /* + report template processing error example + { + "created": "2021-12-28T16:13:01.13624Z", + "statusText": "rendererror:exception,\"PuppeteerSharp -> Evaluation failed: TypeError: Assignment to constant variable.\n at ayPrepareData (:7:2)\n at ayPreRender (C:\\data\\code\\raven\\server\\AyaNova\\resource\\rpt\\ay-report.js:8:38)\n at eval (eval at waitForPredicatePageFunction (:3:23), :3:9)\n at onRaf (__puppeteer_evaluation_script__:50:35)\n at pollRaf (__puppeteer_evaluation_script__:43:15)\n at waitForPredicatePageFunction (__puppeteer_evaluation_script__:8:22)\r\n\"", + "jobId": "3deeac20-b49d-46d8-a5f6-891b7d1049f8" +} + + */ + throw new Error("Job failed"); + } + if (jobStatus == 3) { + /* + example success + { + "created": "2021-12-28T16:14:32.184925Z", + "statusText": "{\"reportfilename\":\"tixcxh25aop.pdf\"}", + "jobId": "c251aa88-6763-4065-a1d4-13fdeb947a72" +} + */ + this.jobActive = false; + //success, get the report url name + // const jobLogRes = await window.$gz.api.get( + // `job-operations/logs/${jobId}` + // ); + 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; + if (v.includes("reportfilename")) { + const o = JSON.parse(v); + reportUrl = window.$gz.api.reportDownloadUrl( + o.reportfilename + ); + } } } - } - this.jobActive = false; + this.jobActive = false; + } } } //job ran to completion, get the report file name and fetch it diff --git a/ayanova/src/views/ay-report-edit.vue b/ayanova/src/views/ay-report-edit.vue index 4aa735db..65490c87 100644 --- a/ayanova/src/views/ay-report-edit.vue +++ b/ayanova/src/views/ay-report-edit.vue @@ -867,10 +867,12 @@ export default { reportDataOptions.ReportId = vm.obj.id; //Meta data from client for use by report script reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData(); - const res = await vm.$refs.reportSelector.open( - reportDataOptions, - vm.obj.id - ); + try { + await vm.$refs.reportSelector.open(reportDataOptions, vm.obj.id); + } catch (ex) { + vm.rendering = false; + window.$gz.errorHandler.handleFormError(ex, vm); + } }, async xxrender() { const vm = this;