Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI - Bug Fixes #1 & Restoring Server Side Filtering (Processes) #160

Merged
merged 22 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,025 changes: 526 additions & 499 deletions cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions cws-service/src/main/java/jpl/cws/controller/RestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,12 @@ public GsonUTCDateAdapter() {
@RequestParam(value = "procDefKey", required=false) String procDefKey,
@RequestParam(value = "status", required=false) String status,
@RequestParam(value = "minDate", required=false) String minDate,
@RequestParam(value = "maxDate", required=false) String maxDate
@RequestParam(value = "maxDate", required=false) String maxDate,
@RequestParam(value = "maxReturn", required=false, defaultValue="5000") String maxReturn
) {

Integer intMaxReturn = Integer.parseInt(maxReturn);

log.debug("REST: getProcessInstancesSize (superProcInstId='" + superProcInstId +
"', procInstId='" + procInstId +
"', procDefKey='"+procDefKey+
Expand All @@ -1114,6 +1118,9 @@ public GsonUTCDateAdapter() {
try {
size = dbService.getFilteredProcessInstancesSize(
superProcInstId, procInstId, procDefKey, status, minDate, maxDate);
if (intMaxReturn > 0 && intMaxReturn < size) {
size = intMaxReturn;
}
}
catch (Exception e) {
log.error("Problem while getFilteredProcessInstancesSize", e);
Expand All @@ -1126,14 +1133,13 @@ public GsonUTCDateAdapter() {
@PathVariable String procInstId) {
List<CwsProcessInstance> 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
Expand All @@ -1148,14 +1154,16 @@ 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,
@RequestParam(value = "maxReturn", required=false, defaultValue="5000") String maxReturn
) {

List<CwsProcessInstance> instances = null;
int recordsToReturn = 0;
Integer pageNum = Integer.parseInt(page);
try {

Integer pageNum = Integer.parseInt(page);
Integer intMaxReturn = Integer.parseInt(maxReturn);

dateOrderBy = dateOrderBy.toUpperCase();
if (!dateOrderBy.equals("DESC") && !dateOrderBy.equals("ASC")) {
log.error("Invalid dateOrderBy of " + dateOrderBy + "! Forcing to be 'DESC'");
Expand All @@ -1166,22 +1174,22 @@ 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;

if ((intMaxReturn != -1) && (instances.size() > intMaxReturn)) {
instances = instances.subList(0, intMaxReturn);
}

}
catch (Exception e) {
log.error("Problem getting process instance information!", e);
// return an empty set
return new GsonBuilder().setPrettyPrinting().create().toJson(new ArrayList<CwsProcessInstance>());
}
return new GsonBuilder().setPrettyPrinting().create().toJson(instances.subList(0,recordsToReturn));
return new GsonBuilder().serializeNulls().create().toJson(instances);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jpl.cws.scheduler;

import java.sql.Timestamp;
import java.util.Map;

public class CwsProcessInstance {

Expand All @@ -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<String, String> inputVariables;

public CwsProcessInstance(
String uuid,
Expand All @@ -37,7 +38,7 @@ public CwsProcessInstance(
String startedByWorker,
Timestamp procStartTime,
Timestamp procEndTime,
String inputVariables) {
Map<String, String> inputVariables) {
super();
this.uuid = uuid;
this.procDefKey = procDefKey;
Expand Down Expand Up @@ -86,11 +87,11 @@ public String getStatus() {
public void setStatus(String status) {
this.status = status;
}
public void setInputVariables(String input) {
public void setInputVariables(Map<String, String> input) {
this.inputVariables = input;
}

public String getInputVariables() {
public Map<String, String> getInputVariables() {
return inputVariables;
}

Expand Down
47 changes: 15 additions & 32 deletions cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,50 +612,31 @@ public LogHistory getHistoryForProcess(String processInstanceId) {
return history;
}

public String getInputVariablesForProcess(String processInstanceId) {
public Map<String, String> getInputVariablesForProcess(String processInstanceId) {
Map<String, String> inputVarMap = new HashMap<String, String>();
List<HistoryDetail> historyDetails = new ArrayList<HistoryDetail>();
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 = "<div><div style=\"width: 85%; min-height: 25px; float:left; overflow-wrap: break-word;\"><b>" + varName + ":</b> " + varValue + "</div><div style=\"width: 15%; float:right\">"
+ "<button class=\"copy\" onClick='copyInput(\"" + varValue + "\")'>"
+ "<span data-text-end=\"Copied!\" data-text-initial=\"Copy to clipboard\" class=\"tooltip\"></span>"
+ "<img src=\"images/copy.svg\" class=\"copy-icon clipboard\">"
+ "</button></div></div><br>";
if (varName.contains("workerId")) {
after = after + temp;
} 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 + "<details><summary><b>Show All</b></summary>" + after + "</details>";
}
return output;
return inputVarMap;
}

public List<ExternalWorker> getExternalWorkersUiDTO() {
Expand Down Expand Up @@ -1081,9 +1062,11 @@ public List<CwsProcessInstance> 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<String, String> inputVars;
if (procInstIdObj != null) {
inputVars = getInputVariablesForProcess(procInstIdObj.toString());
inputVars = getInputVariablesForProcess(procInstIdObj.toString());
} else {
inputVars = new HashMap<String, String>();
}
CwsProcessInstance instance = new CwsProcessInstance(uuidObj == null ? null : uuidObj.toString(),
procDefKeyObj == null ? null : procDefKeyObj.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ public void runResultsTest() throws IOException {

goToPage("processes");

log.info("Filtering Test History Page results.");
waitForElementXPath("//div[@id=\'processes-table_filter\']/label/input");

sleep(5000);

driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).click();
driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).sendKeys("test_history_page");
driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).sendKeys(Keys.ENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;

import org.junit.Test;
import org.openqa.selenium.By;
Expand All @@ -15,6 +18,9 @@
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogEntry;
import org.openqa.selenium.logging.LogType;

import jpl.cws.test.WebTestUtil;

Expand Down Expand Up @@ -191,6 +197,16 @@ public void runVariableProcTest() throws IOException {
log.info("Filtering results for Test Initiators Page test.");
waitForElementXPath("//div[@id=\'processes-table_filter\']/label/input");

Set<String> logtyp = driver.manage().logs().getAvailableLogTypes();
for (String s : logtyp) {
log.info("BROWSER: " + logtyp);
}
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
List<LogEntry> lg = logEntries.getAll();
for(LogEntry logEntry : lg) {
log.info("BROWSER: " + logEntry);
}

driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).click();
driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).sendKeys("test_initiators_page");
driver.findElement(By.xpath("//div[@id=\'processes-table_filter\']/label/input")).sendKeys(Keys.ENTER);
Expand Down
58 changes: 0 additions & 58 deletions cws-ui/src/main/webapp/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,6 @@ div[class*="bar-"]{
--button-diameter: 25px;
--button-outline-width: 1px;
--button-outline-color: rgb(141, 141, 141);
/* tooltip */
--tooltip-bg: #f4f3f3;
--toolptip-border-radius: 4px;
--tooltip-font-family: Menlo, Roboto Mono, monospace;
--tooltip-font-size: 12px;
--tootip-text-color: rgb(50, 50, 50);
--tooltip-padding-x: 7px;
--tooltip-padding-y: 7px;
--tooltip-offset: 8px;
--tooltip-transition-duration: 0.3s;
}

.copy {
Expand All @@ -325,57 +315,9 @@ div[class*="bar-"]{
float: right;
}

.tooltip {
position: absolute;
opacity: 0;
visibility: 0;
top: 0;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
color: var(--tootip-text-color);
background: var(--tooltip-bg);
padding: var(--tooltip-padding-y) var(--tooltip-padding-x);
border-radius: var(--toolptip-border-radius);
pointer-events: none;
transition: all var(--tooltip-transition-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.tooltip::before {
content: attr(data-text-initial);
}

.tooltip::after {
content: "";
position: absolute;
bottom: calc(var(--tooltip-padding-y) / 2 * -1);
width: var(--tooltip-padding-y);
height: var(--tooltip-padding-y);
background: inherit;
left: 50%;
transform: translateX(-50%) rotate(45deg);
z-index: -999;
pointer-events: none;
}

.copy svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}


/* actions */

.copy:hover .tooltip,
.copy:focus:not(:focus-visible) .tooltip {
opacity: 1;
visibility: visible;
top: calc((100% + var(--tooltip-offset)) * -1);
}

.copy:focus:not(:focus-visible) .tooltip::before {
content: attr(data-text-end);
}

Loading