From 55d9feec6e353b6bc31f0ecce4774230e8856fd3 Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Thu, 6 Jul 2023 13:36:46 -0700 Subject: [PATCH 01/21] Remove downdown for download (button only now) --- install/cws-ui/deployments.ftl | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/install/cws-ui/deployments.ftl b/install/cws-ui/deployments.ftl index a9388a8d..fefb099b 100644 --- a/install/cws-ui/deployments.ftl +++ b/install/cws-ui/deployments.ftl @@ -11,8 +11,9 @@ - - - @@ -497,7 +494,7 @@ selectedRows.every( function ( rowIdx, tableLoop, rowLoop ) { var data = this.data(); - switch (data[6]) { + switch (data[4]) { case 'disabled': numDisabledSelected++; break; @@ -589,7 +586,7 @@ $("#action_mark_as_resolved_atag").attr("href", "javascript:action_mark_as_resolved();"); } - if ((numSelected > 0 && numPendingSelected === 0)) { + if ((numSelected > 0)) { $("#action_download_selected_list").removeClass("disabled"); $("#action_download_selected_list_atag").attr("href", "javascript:downloadListJSON();"); if (numPendingSelected === 0) { @@ -613,7 +610,7 @@ var selectedRows = table.rows( { selected: true } ); selectedRows.every( function ( rowIdx, tableLoop, rowLoop ) { var data = this.data(); - window.open("/${base}/history?procInstId=" + data[5], "_blank"); + window.open("/${base}/history?procInstId=" + data[3], "_blank"); } ); } @@ -625,7 +622,7 @@ var links = ""; selectedRows.every( function ( rowIdx, tableLoop, rowLoop ) { var data = this.data(); - links += protocol + "://" + host + "/${base}/history?procInstId=" + data[5] + "\n"; + links += protocol + "://" + host + "/${base}/history?procInstId=" + data[3] + "\n"; } ); navigator.clipboard.writeText(links); } From ab15113b9efe538998f45d232235bbad3e250c2d Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Fri, 7 Jul 2023 13:08:13 -0700 Subject: [PATCH 04/21] Add ability to hide/show columns --- install/cws-ui/processes.ftl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install/cws-ui/processes.ftl b/install/cws-ui/processes.ftl index b91197e0..db917335 100644 --- a/install/cws-ui/processes.ftl +++ b/install/cws-ui/processes.ftl @@ -203,11 +203,12 @@ columnDefs: [ { orderable: false, - className: 'select-checkbox', + className: 'select-checkbox noVis', targets: 0 }, { orderable: false, + className: 'noVis', searchable: false, targets: 1 }, @@ -215,11 +216,19 @@ orderable: false, searchable: false, targets: 2 + }, + { + targets: [ 6 ], + visible: false } ], stateSave: true, dom: "Q<'row'<'col-sm-auto buttons'B>><'row'<'col-sm-1 action-button'><'col-sm-5 length'l><'col-sm-6 filter'f>>" + "tip", buttons: [ + { + extend: 'colvis', + columns: ':not(.noVis)' + }, { text: "Select all on page", action: function () { @@ -247,7 +256,7 @@ $("#processes-table").DataTable().rows().deselect(); updateActionList(); } - } + }, ], searchBuilder: { columns: [3,4,5,6,7,8,9,10], From ad2511d8b9b79905f54e7c7e631f9846dd8e564b Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Fri, 7 Jul 2023 14:12:55 -0700 Subject: [PATCH 05/21] Update width of input variables --- .../src/main/java/jpl/cws/service/CwsConsoleService.java | 2 +- install/cws-ui/processes.ftl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java b/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java index bef32a67..3828dd79 100644 --- a/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java +++ b/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java @@ -632,7 +632,7 @@ public String getInputVariablesForProcess(String processInstanceId) { String varName = message.substring(message.indexOf(")")+2); varName = varName.substring(0, varName.indexOf("=")-1) + " " + varType; String varValue = message.substring(message.indexOf("=")+2); - String temp = "
" + varName + ": " + varValue + "
" + String temp = "
" + varName + ": " + varValue + "
" + "

"; if (varName.contains("workerId")) { - after = after + temp; + } else if (varName.contains("startedOnWorkerId")) { after = after + temp; putAllAfter = 1; From a6589de2f4339345650095c845f7c4891ae857be Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Mon, 10 Jul 2023 10:04:28 -0700 Subject: [PATCH 08/21] Fix infinite refresh if page not visited before --- install/cws-ui/deployments.ftl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/cws-ui/deployments.ftl b/install/cws-ui/deployments.ftl index fefb099b..93121de2 100644 --- a/install/cws-ui/deployments.ftl +++ b/install/cws-ui/deployments.ftl @@ -352,11 +352,13 @@ if (localStorage.getItem(refreshRateVar) !== null) { $("#refresh-rate").val(localStorage.getItem(refreshRateVar)/1000); } else { + localStorage.setItem(refreshRateVar, 5000); $("#refresh-rate").val("5"); } if (localStorage.getItem(lastNumHoursVar) !== null) { $("#stats-last-num-hours").val(localStorage.getItem(lastNumHoursVar)); } else { + localStorage.setItem(lastNumHoursVar, 24); $("#stats-last-num-hours").val(24); } From b4085a730ddfd89b6fe6b367dbb0c3c47d1147eb Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Mon, 10 Jul 2023 15:26:56 -0700 Subject: [PATCH 09/21] Update process parsing methods to speedup loading --- .../jpl/cws/core/db/SchedulerDbService.java | 15 +- .../java/jpl/cws/controller/RestService.java | 18 +- .../jpl/cws/scheduler/CwsProcessInstance.java | 9 +- .../jpl/cws/service/CwsConsoleService.java | 47 +- install/cws-ui/processes.ftl | 544 +++++++++--------- 5 files changed, 300 insertions(+), 333 deletions(-) diff --git a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java index 184a2f5f..6e210138 100644 --- a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java +++ b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java @@ -908,13 +908,20 @@ public List> getFilteredProcessInstances( String dateOrderBy, int page ) - { + { List whereObjs = new ArrayList(); + + Integer offset = page*PROCESSES_PAGE_SIZE; + Integer size = PROCESSES_PAGE_SIZE; + if (procInstId != null) { whereObjs.add(procInstId); } if (procDefKey != null) { whereObjs.add(procDefKey); } if (minDate != null) { whereObjs.add(minDate); } if (maxDate != null) { whereObjs.add(maxDate); } + whereObjs.add(offset); + whereObjs.add(size); + String pattern = PENDING + "|" + DISABLED + "|" + FAILED_TO_START + "|" + FAILED_TO_SCHEDULE + "|" + CLAIMED_BY_WORKER + "|" + RUNNING + "|" + COMPLETE + "|" + RESOLVED + "|" + FAIL + "|" + INCIDENT; @@ -936,7 +943,8 @@ public List> getFilteredProcessInstances( (maxDate != null ? "created_time <= ? AND " : "") + (statusList != null ? "status IN "+statusClause+" AND " : "") + " proc_inst_id IS NULL " + // don't get any started processes - "ORDER BY created_time " + dateOrderBy + " "; + "ORDER BY created_time " + dateOrderBy + " " + + "LIMIT ?,?"; List> cwsRows = jdbcTemplate.queryForList(cwsQuery, whereObjs.toArray()); @@ -968,7 +976,8 @@ public List> getFilteredProcessInstances( (minDate != null ? "PI.start_time >= ? AND " : "") + (maxDate != null ? "PI.start_time <= ? AND " : "") + " 1=1 " + - "ORDER BY PI.start_time " + dateOrderBy + " "; + "ORDER BY PI.start_time " + dateOrderBy + " " + + "LIMIT ?,?"; List> camundaRows = jdbcTemplate.queryForList(camundaQuery, whereObjs.toArray()); 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 12cd6d70..65e79da6 100644 --- a/cws-service/src/main/java/jpl/cws/controller/RestService.java +++ b/cws-service/src/main/java/jpl/cws/controller/RestService.java @@ -1126,14 +1126,13 @@ public GsonUTCDateAdapter() { @PathVariable String procInstId) { List instances = null; instances = cwsConsoleService.getFilteredProcessInstancesCamunda( - null, procInstId, null, null, null, null, "DESC", 1); + null, procInstId, null, null, null, null, "DESC", 0); if (instances.size() == 0) { return null; } else { return instances.get(0).getStatus(); } } - /** * REST method used to get Processes table JSON @@ -1148,14 +1147,14 @@ public GsonUTCDateAdapter() { @RequestParam(value = "minDate", required=false) String minDate, @RequestParam(value = "maxDate", required=false) String maxDate, @RequestParam(value = "dateOrderBy", required=false, defaultValue="DESC") String dateOrderBy, - @RequestParam(value = "page", required=false, defaultValue="0") String page + @RequestParam(value = "page", required=false, defaultValue="0") String page ) { List instances = null; - int recordsToReturn = 0; - Integer pageNum = Integer.parseInt(page); try { + Integer pageNum = Integer.parseInt(page); + dateOrderBy = dateOrderBy.toUpperCase(); if (!dateOrderBy.equals("DESC") && !dateOrderBy.equals("ASC")) { log.error("Invalid dateOrderBy of " + dateOrderBy + "! Forcing to be 'DESC'"); @@ -1166,22 +1165,17 @@ public GsonUTCDateAdapter() { "', procInstId='" + procInstId + "', procDefKey='"+procDefKey+ "', status='"+status+"', minDate="+minDate+", maxDate="+maxDate+ - ", dateOrderBy="+dateOrderBy+", page="+page+")"); + ", dateOrderBy="+dateOrderBy+")"); instances = cwsConsoleService.getFilteredProcessInstancesCamunda( superProcInstId, procInstId, procDefKey, status, minDate, maxDate, dateOrderBy, pageNum); - if (pageNum > instances.size()) { - recordsToReturn = instances.size(); - } else { - recordsToReturn = pageNum; - } } catch (Exception e) { log.error("Problem getting process instance information!", e); // return an empty set return new GsonBuilder().setPrettyPrinting().create().toJson(new ArrayList()); } - return new GsonBuilder().setPrettyPrinting().create().toJson(instances.subList(0,recordsToReturn)); + return new GsonBuilder().serializeNulls().create().toJson(instances); } diff --git a/cws-service/src/main/java/jpl/cws/scheduler/CwsProcessInstance.java b/cws-service/src/main/java/jpl/cws/scheduler/CwsProcessInstance.java index 16e18938..4596a263 100644 --- a/cws-service/src/main/java/jpl/cws/scheduler/CwsProcessInstance.java +++ b/cws-service/src/main/java/jpl/cws/scheduler/CwsProcessInstance.java @@ -1,6 +1,7 @@ package jpl.cws.scheduler; import java.sql.Timestamp; +import java.util.Map; public class CwsProcessInstance { @@ -22,7 +23,7 @@ public class CwsProcessInstance { private Timestamp procStartTime; // from Camunda ACT_HI_PROCINST_ table private Timestamp procEndTime; // from Camunda ACT_HI_PROCINST_ table - private String inputVariables; + private Map inputVariables; public CwsProcessInstance( String uuid, @@ -37,7 +38,7 @@ public CwsProcessInstance( String startedByWorker, Timestamp procStartTime, Timestamp procEndTime, - String inputVariables) { + Map inputVariables) { super(); this.uuid = uuid; this.procDefKey = procDefKey; @@ -86,11 +87,11 @@ public String getStatus() { public void setStatus(String status) { this.status = status; } - public void setInputVariables(String input) { + public void setInputVariables(Map input) { this.inputVariables = input; } - public String getInputVariables() { + public Map getInputVariables() { return inputVariables; } diff --git a/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java b/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java index e658255f..0ab1d8dd 100644 --- a/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java +++ b/cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java @@ -612,50 +612,31 @@ public LogHistory getHistoryForProcess(String processInstanceId) { return history; } - public String getInputVariablesForProcess(String processInstanceId) { + public Map getInputVariablesForProcess(String processInstanceId) { + Map inputVarMap = new HashMap(); List historyDetails = new ArrayList(); getHistoryVarDetails(historyDetails, processInstanceId); - - String output = ""; - String before = ""; - String after = ""; - int putAllAfter = 0; - int count = 0; + + if (processInstanceId == null) { + return inputVarMap; + } for (HistoryDetail historyDetail : historyDetails) { if (historyDetail.type.equals("VarUpdate") && historyDetail.activity.equals(processInstanceId)) { - if (count > 3) { - putAllAfter = 1; - } String message = historyDetail.message; String varType = message.substring(message.indexOf("("), message.indexOf(")")+1); String varName = message.substring(message.indexOf(")")+2); varName = varName.substring(0, varName.indexOf("=")-1) + " " + varType; String varValue = message.substring(message.indexOf("=")+2); - String temp = "
" + varName + ": " + varValue + "
" - + "

"; - if (varName.contains("workerId")) { - - } else if (varName.contains("startedOnWorkerId")) { - after = after + temp; - putAllAfter = 1; - } else if (putAllAfter == 0) { - before = before + temp; + + if (inputVarMap.containsKey(varName)) { } else { - after = after + temp; + inputVarMap.put(varName, varValue); } - count++; + } } - if (after.isEmpty()) { - output = before; - } else { - output = before + "
Show All" + after + "
"; - } - return output; + return inputVarMap; } public List getExternalWorkersUiDTO() { @@ -1081,9 +1062,11 @@ public List getFilteredProcessInstancesCamunda(String superP String startedByWorker = (String) row.get("started_by_worker"); Timestamp procStartTime = (Timestamp) row.get("proc_start_time"); Timestamp procEndTime = (Timestamp) row.get("proc_end_time"); - String inputVars = ""; + Map inputVars; if (procInstIdObj != null) { - inputVars = getInputVariablesForProcess(procInstIdObj.toString()); + inputVars = getInputVariablesForProcess(procInstIdObj.toString()); + } else { + inputVars = new HashMap(); } CwsProcessInstance instance = new CwsProcessInstance(uuidObj == null ? null : uuidObj.toString(), procDefKeyObj == null ? null : procDefKeyObj.toString(), diff --git a/install/cws-ui/processes.ftl b/install/cws-ui/processes.ftl index 24197a50..615831e1 100644 --- a/install/cws-ui/processes.ftl +++ b/install/cws-ui/processes.ftl @@ -37,18 +37,6 @@ details[open] summary::before { transform: rotate(90deg); } - - - - - - - - - + + + + + + + - <#include "navbar.ftl">
@@ -103,13 +100,6 @@

Processes

-
- By default, the 5000 most recent processes are loaded. - - - -
-
@@ -135,6 +125,8 @@ Process Start Process End Input Variables + Superprocess ID + UUID @@ -147,33 +139,24 @@ +