From 7edaeb93da8bebebb6839d0c0976660410ad2676 Mon Sep 17 00:00:00 2001 From: Matthias Stein Date: Tue, 15 Mar 2022 12:52:22 +0100 Subject: [PATCH] Fix _fetchTemplateInfosAsync method in PrintingInfosAnalyzer.js --- .../PrintingInfosAnalyzer.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingInfosAnalyzer.js b/src/main/js/bundles/dn_printingenhanced/PrintingInfosAnalyzer.js index ab5c772..8c50245 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingInfosAnalyzer.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingInfosAnalyzer.js @@ -74,13 +74,23 @@ export default class PrintingInfosAnalyzer { const outputParamName = properties.layoutTemplatesInfoTaskResultParameter || "Output_JSON"; return new Promise((resolve, reject) => { gp.submitJob({}).then((jobInfo) => { - if (jobInfo.jobStatus === "job-succeeded") { - gp.getResultData(jobInfo.jobId, outputParamName).then((results) => { - resolve(results.value); - }); - } else if (jobInfo.jobStatus === "job-failed") { - reject(jobInfo.messages[0]); - } + const jobId = jobInfo.jobId; + const options = { + interval: 1000, + statusCallback: (j) => { + console.info("Get Layout Templates Info Task Job Status: ", j.jobStatus); + } + }; + + gp.waitForJobCompletion(jobId, options).then((jobInfo) => { + if (jobInfo.jobStatus === "job-succeeded") { + gp.getResultData(jobInfo.jobId, outputParamName).then((results) => { + resolve(results.value); + }); + } else if (jobInfo.jobStatus === "job-failed") { + reject(jobInfo.messages[0]); + } + }); }); }); }