From 83f721922035c4e60b444f6b36d1fe1b792200c6 Mon Sep 17 00:00:00 2001 From: Joshua Rodriguez Date: Mon, 4 Nov 2024 09:01:18 -0800 Subject: [PATCH] Fixes to Processes and Deployments pages --- install/cws-ui/deployments.ftl | 31 ++++++++++++++++++++++++------- install/cws-ui/processes.ftl | 7 ++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/install/cws-ui/deployments.ftl b/install/cws-ui/deployments.ftl index 047cc6fb..b968342a 100644 --- a/install/cws-ui/deployments.ftl +++ b/install/cws-ui/deployments.ftl @@ -489,7 +489,7 @@ if (type !== 'display') { return ""; } else { - var html = ``; return html; } @@ -794,7 +794,21 @@ $("#btn-suspend-" + procDefKey).attr("onclick", "suspendProcDef('" + procDefId + "', '" + procDefKey + "')"); $("#status-txt-" + procDefKey).html("Active"); $("#" + procDefKey).removeClass("disabled"); - $("#pv-" + procDefKey).removeClass("disabled").removeClass("btn-outline-dark").addClass("btn").text("enable"); + $.get("/${base}/rest/processes/getProcDefWorkerCount", function(data) { + var rows = JSON.parse(data); + var hasWorker = false; + for (i in rows) { + if (rows[i].pdk === procDefKey && rows[i].workers > 0) { + hasWorker = true; + break; + } + } + if (hasWorker) { + $("#pv-" + procDefKey).removeClass("disabled btn-danger").addClass("btn-outline-dark").text("view"); + } else { + $("#pv-" + procDefKey).removeClass("disabled btn-outline-dark").addClass("btn-danger").text("enable"); + } + }); }, error: function (data) { console.log("error activating"); @@ -1227,12 +1241,15 @@ $.get("/${base}/rest/processes/getProcDefWorkerCount", function (data) { var rows = JSON.parse(data) for (i in rows) { - if (rows[i].workers == 0) { - $("#pv-" + rows[i].pdk).removeClass("btn-default").addClass("btn-danger"); - $("#pv-" + rows[i].pdk).text("enable"); + const table = $("#process-table").DataTable(); + const rowData = table.row("#" + rows[i].pdk).data(); + + if (rowData && rowData.suspended === "true") { + $("#pv-" + rows[i].pdk).removeClass("btn-danger").addClass("btn-outline-dark").text("view"); + } else if (rows[i].workers == 0) { + $("#pv-" + rows[i].pdk).removeClass("btn-default").addClass("btn-danger").text("enable").removeClass("btn-outline-dark"); } else { - $("#pv-" + rows[i].pdk).removeClass("btn-danger").addClass("btn-outline-dark"); - $("#pv-" + rows[i].pdk).text("view"); + $("#pv-" + rows[i].pdk).removeClass("btn-danger").addClass("btn-outline-dark").text("view").addClass("btn-outline-dark"); } } }); diff --git a/install/cws-ui/processes.ftl b/install/cws-ui/processes.ftl index 9a113500..7f144a0f 100644 --- a/install/cws-ui/processes.ftl +++ b/install/cws-ui/processes.ftl @@ -1554,11 +1554,8 @@ contentType: "application/json", data: JSON.stringify(procInstIds), success: function (msg) { - //clear table - table.clear().draw(); - //reload table - fetchAndDisplayProcesses(); - } + fetchAndDisplayProcesses(); + } }) .fail(function (xhr, err) { console.error(xhr.responseTextmsg);