From 976d3617a54430895d0987197c1eca739e14c26b Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Wed, 5 Jul 2023 15:29:07 -0700 Subject: [PATCH] Display more detail on status on history page --- .../java/jpl/cws/controller/RestService.java | 15 ++++- install/cws-ui/history.ftl | 67 ++++++++++++++++--- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/cws-service/src/main/java/jpl/cws/controller/RestService.java b/cws-service/src/main/java/jpl/cws/controller/RestService.java index 79325599..8e019887 100644 --- a/cws-service/src/main/java/jpl/cws/controller/RestService.java +++ b/cws-service/src/main/java/jpl/cws/controller/RestService.java @@ -1120,7 +1120,20 @@ public GsonUTCDateAdapter() { } return size; } - + + @RequestMapping(value="/history/getStatus/{procInstId}", method = GET) + public @ResponseBody String getStatusByProcInstId( + @PathVariable String procInstId) { + List instances = null; + instances = cwsConsoleService.getFilteredProcessInstancesCamunda( + null, procInstId, null, null, null, null, "DESC", 1); + if (instances.size() == 0) { + return null; + } else { + return instances.get(0).getStatus(); + } + } + /** * REST method used to get Processes table JSON diff --git a/install/cws-ui/history.ftl b/install/cws-ui/history.ftl index d13ad6dd..5ccad3f1 100644 --- a/install/cws-ui/history.ftl +++ b/install/cws-ui/history.ftl @@ -214,16 +214,63 @@ $('#procDuration').html(convertMillis(data.duration)); } - var status = data.state; - - if (data.state === "COMPLETED") { - status = "Complete"; - } - else if (data.state === "ACTIVE") { - status = "Running"; + $.ajax({ + type: "GET", + url: "/${base}/rest/history/getStatus/" + data.procInstId, + success: function(data) { + var status = data; + switch (data) { + case "pending": + status = "Pending"; + $("#procStatus").css("color", "blue"); + break; + case "disabled": + status = "Disabled"; + $("#procStatus").css("color", "red"); + break; + case "failedToSchedule": + status = "Failed to schedule"; + $("#procStatus").css("color", "red"); + break; + case "claimedByWorker": + status = "Claimed by Worker"; + $("#procStatus").css("color", "blue"); + break; + case "failedToStart": + status = "Failed to start"; + $("#procStatus").css("color", "red"); + break; + case "running": + status = "Running"; + $("#procStatus").css("color", "blue"); + break; + case "complete": + status = "Complete"; + $("#procStatus").css("color", "green"); + break; + case "resolved": + status = "Resolved"; + $("#procStatus").css("color", "green"); + break; + case "fail": + status = "Failed"; + $("#procStatus").css("color", "red"); + break; + case "incident": + status = "Incident"; + $("#procStatus").css("color", "red"); + break; + default: + status = "Unknown"; + $("#procStatus").css("color", "red"); + break; + } + $('#procStatus').html(status); + }, + error: function(e) { + $("procStatus").html("Error fetching status - please try again later."); } - - $('#procStatus').html(status); + }); } return tableRows; @@ -512,7 +559,7 @@ DurationN/A - StatusUnknown + Status