Skip to content

Commit

Permalink
Display more detail on status on history page
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgunter committed Jul 5, 2023
1 parent d3a0b72 commit 976d361
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 11 deletions.
15 changes: 14 additions & 1 deletion cws-service/src/main/java/jpl/cws/controller/RestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,20 @@ public GsonUTCDateAdapter() {
}
return size;
}


@RequestMapping(value="/history/getStatus/{procInstId}", method = GET)
public @ResponseBody String getStatusByProcInstId(
@PathVariable String procInstId) {
List<CwsProcessInstance> 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
Expand Down
67 changes: 57 additions & 10 deletions install/cws-ui/history.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<b>Disabled</b>";
$("#procStatus").css("color", "red");
break;
case "failedToSchedule":
status = "<b>Failed to schedule</b>";
$("#procStatus").css("color", "red");
break;
case "claimedByWorker":
status = "Claimed by Worker";
$("#procStatus").css("color", "blue");
break;
case "failedToStart":
status = "<b>Failed to start</b>";
$("#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 = "<b>Failed</b>";
$("#procStatus").css("color", "red");
break;
case "incident":
status = "<b>Incident</b>";
$("#procStatus").css("color", "red");
break;
default:
status = "<b>Unknown</b>";
$("#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;
Expand Down Expand Up @@ -512,7 +559,7 @@
<td style="font-weight:bold;">Duration</td><td id="procDuration">N/A</td>
</tr>
<tr>
<td style="font-weight:bold;">Status</td><td id="procStatus">Unknown</td>
<td style="font-weight:bold;">Status</td><td id="procStatus"></td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 976d361

Please sign in to comment.