Skip to content

Commit bb39410

Browse files
authored
UI - Misc Fixes 4 (#171)
* Fix deployments download * Add "none" to process table if no in/out vars * Fix state for "Show stats for last ..." * Fix null exception for input variables * Fix error where worker status was opposite * Update default order on proc page * Update model to include more examples of imgs * Fix deleting process resulting in ajax error * When model is suspended, grey out line * Process details table now changes size * Adjust sizing * Add message re: popup permission for open all * Moved output var to local filter * Make default for logs page to be "ERROR" * Search on enter key press * Add support for image urls, other file support * Update to add support for other files, image urls * Only show input vars (not vars during proc run) * Update nested table on logs - make same font size * Make hide all suspended processes check stateful * Make warning hidden by default * Add 3-way toggle: show all, log lines only, no log * Update input var detection * Add copy button to long stderr/stdout * Searchbuilder is now encoded in url * Update history test to be compat. with new btns * Update caching behavior * Update test model with relative paths * Create cookie w/ username for stateful local vars * Add tooltips to suspend/resume, edit, delete btns * Fix timestamp, edit formatting of vars * Support files that have mime type but not image * Show var types on history page * Update wording of log line filtering on history pg * Edit var styling * Fix formatting
1 parent 791b504 commit bb39410

File tree

12 files changed

+414
-149
lines changed

12 files changed

+414
-149
lines changed

cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.springframework.jdbc.support.lob.LobCreator;
1717

1818
import java.io.ByteArrayOutputStream;
19+
import java.sql.Array;
1920
import java.sql.PreparedStatement;
2021
import java.sql.SQLException;
2122
import java.sql.Timestamp;

cws-core/src/main/java/jpl/cws/core/web/CwsSecurityFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public abstract class CwsSecurityFilter implements javax.servlet.Filter {
4141
private static final Logger log = LoggerFactory.getLogger(CwsSecurityFilter.class);
4242

4343
public static final String CWS_TOKEN_COOKIE_NAME = "cwsToken";
44+
public static final String CWS_USERNAME_COOKIE_NAME = "cwsUsername";
4445

4546
static final String COOKIES_HEADER = "Set-Cookie";
4647

@@ -564,6 +565,7 @@ else if (resourceId.startsWith("process/")) {
564565
protected void setCwsTokenCookie(HttpServletRequest req, HttpServletResponse resp) {
565566
String cwsToken = req.getSession().getId();
566567
WebUtils.addCookie(CWS_TOKEN_COOKIE_NAME, cwsToken, null, "/", resp);
568+
WebUtils.addUnsecureCookie(CWS_USERNAME_COOKIE_NAME, getUsernameFromReq(req), null, "/", resp);
567569
cwsSecurityService.addNewCwsTokenToDb(cwsToken, getUsernameFromReq(req));
568570
//addCwsSessionId(getUsernameFromReq(req), req.getSession().getId());
569571
}

cws-core/src/main/java/jpl/cws/core/web/WebUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ public static void addCookie(String name, String value, String domain, String pa
212212
Cookie cookie = constructCookie(name, value, domain, path);
213213
resp.addCookie(cookie);
214214
}
215+
216+
public static void addUnsecureCookie(String name, String value, String domain, String path, HttpServletResponse resp) {
217+
if (!isValidCookieString(name) || !isValidCookieString(value)) {
218+
throw new IllegalArgumentException("Cookie name and/or value is invalid (contains unacceptable characters)!");
219+
}
220+
Cookie cookie = constructCookie(name, value, domain, path);
221+
cookie.setHttpOnly(false);
222+
resp.addCookie(cookie);
223+
}
215224

216225

217226

cws-service/src/main/java/jpl/cws/controller/RestService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@
5555
import org.springframework.mock.web.MockMultipartFile;
5656
import org.springframework.stereotype.Controller;
5757
import org.springframework.util.MultiValueMap;
58-
import org.springframework.web.bind.annotation.PathVariable;
59-
import org.springframework.web.bind.annotation.RequestBody;
60-
import org.springframework.web.bind.annotation.RequestMapping;
61-
import org.springframework.web.bind.annotation.RequestParam;
62-
import org.springframework.web.bind.annotation.ResponseBody;
58+
import org.springframework.web.bind.annotation.*;
6359
import org.springframework.web.multipart.MultipartFile;
6460
import org.springframework.web.servlet.ModelAndView;
6561

cws-service/src/main/java/jpl/cws/service/CwsConsoleService.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,15 @@ public Map<String, String> getInputVariablesForProcess(String processInstanceId)
636636
}
637637
inputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + " (" + varType + ", " + mimeType + ")", encodedString);
638638
} else {
639-
inputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + " (" + varType + ")", fileName);
639+
InputStream fileInputStream = fileValue.getValue();
640+
String encodedString = "";
641+
try {
642+
byte[] sourceBytes = IOUtils.toByteArray(fileInputStream);
643+
encodedString += Base64.getEncoder().encodeToString(sourceBytes);
644+
} catch (IOException e) {
645+
log.error("Error converting file to Base64");
646+
}
647+
inputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + "(" + varType + ") {" + fileName + "}", encodedString);
640648
}
641649
} else {
642650
InputStream fileInputStream = fileValue.getValue();
@@ -647,7 +655,7 @@ public Map<String, String> getInputVariablesForProcess(String processInstanceId)
647655
} catch (IOException e) {
648656
log.error("Error converting file to Base64");
649657
}
650-
inputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + "(" + varType + ") {" + fileName + "}", encodedString);
658+
inputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + " (" + varType + ") {" + fileName + "}", encodedString);
651659
}
652660
}
653661
}
@@ -699,7 +707,16 @@ public Map<String, String> getOutputVariablesForProcess(String processInstanceId
699707
}
700708
outputVarMap.put(varName + " (" + varType + ", " + mimeType + ")", encodedString);
701709
} else {
702-
outputVarMap.put(varName + " (" + varType + ")", fileName);
710+
InputStream fileInputStream = fileValue.getValue();
711+
String encodedString = "";
712+
try {
713+
byte[] sourceBytes = IOUtils.toByteArray(fileInputStream);
714+
encodedString += Base64.getEncoder().encodeToString(sourceBytes);
715+
} catch (IOException e) {
716+
log.error("Error converting file to Base64");
717+
}
718+
outputVarMap.put("[" + historicVariableInstance.getCreateTime().toString() + "]" + varName + " (" + varType + ") {" + fileName + "}", encodedString);
719+
703720
}
704721
} else {
705722
InputStream fileInputStream = fileValue.getValue();
@@ -710,7 +727,7 @@ public Map<String, String> getOutputVariablesForProcess(String processInstanceId
710727
} catch (IOException e) {
711728
log.error("Error converting file to Base64");
712729
}
713-
outputVarMap.put(varName + "(" + varType + ") {" + fileName + "}", encodedString);
730+
outputVarMap.put(varName + " (" + varType + ") {" + fileName + "}", encodedString);
714731
}
715732
}
716733
}

cws-ui/src/main/webapp/css/history.css

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,26 @@ summary {
6969
align-items: center;
7070
}
7171

72+
.proc-var-flex-main-sub-1 {
73+
align-self: start;
74+
display: flex;
75+
flex-wrap: nowrap;
76+
justify-content: space-between;
77+
}
78+
79+
.proc-var-flex-main-sub-2 {
80+
width: 150px;
81+
word-wrap: break-word;
82+
overflow: hidden;
83+
}
84+
85+
.proc-var-flex-main-sub-3 {
86+
width: 200px;
87+
word-wrap: break-word;
88+
}
89+
7290
.proc-var-flex-btn {
7391
align-self: start;
74-
margin-top: auto;
75-
margin-bottom: auto;
7692
}
7793

7894
#logDataNest {

cws-ui/src/main/webapp/css/processes.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,25 @@ summary {
136136
justify-content: space-between;
137137
align-items: flex-start;
138138
gap: 0px;
139+
}
140+
141+
.var-row-div-flex {
142+
display: flex;
143+
flex-direction: row;
144+
flex-wrap: nowrap;
145+
justify-content: flex-start;
146+
align-items: flex-start;
147+
align-content: center;
148+
}
149+
150+
.var-row-div-flex-sub-1 {
151+
width: 85%;
152+
max-width: 300px;
153+
min-height: 25px;
154+
float:left;
155+
overflow-wrap: break-word;
156+
}
157+
158+
.var-row-div-flex-sub-2 {
159+
flex-grow: 1;
139160
}

install/cws-ui/deployments.ftl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
<!-- Custom styles for this template -->
1313
<link href="/${base}/css/dashboard.css" rel="stylesheet">
1414
<link href="/${base}/css/deployments.css" rel="stylesheet">
15+
<link href="/${base}/css/microtip.css" rel="stylesheet">
1516

1617
<script>
1718
1819
//STATE PERSISTANCE CONSTS
19-
const username = "username"; //temporary, hardcoded value for now
20+
var username = document.cookie.substring(document.cookie.indexOf("cwsUsername=") + 12);
21+
if (username.indexOf(";") > 0) {
22+
username = username.substring(0, username.indexOf(";"));
23+
}
2024
const lastNumHoursVar = "CWS_DASH_DEPLOY_LAST_NUM_HOURS-" + username;
2125
const refreshRateVar = "CWS_DASH_DEPLOY_REFRESH_RATE-" + username;
2226
const hideSuspendedProcVar = "CWS_DASH_DEPLOY_HIDE_SUS-" + username;
@@ -382,18 +386,20 @@
382386
383387
var returnVal = `<div class="proc-name-btns">`;
384388
if (data.suspended == "true") {
385-
returnVal += `<a id="btn-suspend-` + data.key + `" data-proc-id="` + data.key + `" onClick="resumeProcDef('` + data.id + `', '` + data.key + `')">`
389+
returnVal += `<a id="btn-suspend-` + data.key + `" data-proc-id="` + data.key + `" onClick="resumeProcDef('` + data.id + `', '` + data.key + `')" aria-label="Resume" data-microtip-position="top-right" role="tooltip">`
386390
+ `<span style="cursor: pointer; float: right; color: green;" id="suspend-`
387-
+ data.key + `" class="glyphicon glyphicon-play"></span></a>`;
391+
+ data.key + `" class="glyphicon glyphicon-play"></span>`
392+
+ `</a>`;
388393
} else {
389-
returnVal += `<a id="btn-suspend-` + data.key + `" data-proc-id="` + data.key + `" onClick="suspendProcDef('` + data.id + `', '` + data.key + `')">`
394+
returnVal += `<a id="btn-suspend-` + data.key + `" data-proc-id="` + data.key + `" onClick="suspendProcDef('` + data.id + `', '` + data.key + `')" aria-label="Suspend" data-microtip-position="top-right" role="tooltip">`
390395
+ `<span style="cursor: pointer; float: right; color: #d9534f;" id="suspend-`
391396
+ data.key + `" class="glyphicon glyphicon-pause"></span></a>`;
392397
}
393398
394-
returnVal += `<a href="/${base}/modeler?procDefKey=` + data.key + `" target="_blank">`
399+
returnVal += `<a href="/${base}/modeler?procDefKey=` + data.key + `" target="_blank" aria-label="Edit" data-microtip-position="top-right" role="tooltip">`
395400
+ `<span style="float: right;" id="edit-` + data.key + `" class="glyphicon glyphicon-pencil"></span></a>`
396-
+ `<a data-proc-key="` + data.key + `" onClick="handleDeleteProcDef('` + data.key + `')"><span style="cursor: pointer; float: right; color: #d9534f;" id="delete-`
401+
+ `<a data-proc-key="` + data.key + `" onClick="handleDeleteProcDef('` + data.key + `')" aria-label="Delete" data-microtip-position="top-right" role="tooltip">`
402+
+ `<span style="cursor: pointer; float: right; color: #d9534f;" id="delete-`
397403
+ data.key + `" class="glyphicon glyphicon-trash"></span></a>`;
398404
399405
returnVal += `</div>`;

0 commit comments

Comments
 (0)