Fixed cache view UI, minor theme bug and an SDK loading problem

This commit is contained in:
Frikky
2024-01-26 11:45:14 +01:00
parent 57b7440b46
commit b796eba7b2
4 changed files with 66 additions and 55 deletions
+3 -2
View File
@@ -534,6 +534,7 @@ class AppBase:
try: try:
finished = False finished = False
ret = {}
for i in range (0, 10): for i in range (0, 10):
# Random sleeptime between 0 and 1 second, with 0.1 increments # Random sleeptime between 0 and 1 second, with 0.1 increments
sleeptime = float(random.randint(0, 10) / 10) sleeptime = float(random.randint(0, 10) / 10)
@@ -541,13 +542,14 @@ class AppBase:
try: try:
ret = requests.post(url, headers=headers, json=action_result, timeout=10, verify=False, proxies=self.proxy_config) ret = requests.post(url, headers=headers, json=action_result, timeout=10, verify=False, proxies=self.proxy_config)
self.logger.info(f"[DEBUG] Result: {ret.status_code} (break on 200 or 201)") self.logger.info(f"""[DEBUG] Successful request result request: Status= {ret.status_code} (break on 200/201) & Response= {ret.text}. Action status: {action_result["status"]}""")
if ret.status_code == 200 or ret.status_code == 201: if ret.status_code == 200 or ret.status_code == 201:
finished = True finished = True
break break
else: else:
self.logger.info(f"[ERROR] Bad resp {ret.status_code}: {ret.text}") self.logger.info(f"[ERROR] Bad resp {ret.status_code}: {ret.text}")
time.sleep(sleeptime) time.sleep(sleeptime)
# Proxyerrror # Proxyerrror
except requests.exceptions.ProxyError as e: except requests.exceptions.ProxyError as e:
@@ -608,7 +610,6 @@ class AppBase:
self.send_result(action_result, {"Content-Type": "application/json", "Authorization": "Bearer %s" % self.authorization}, "/api/v1/streams") self.send_result(action_result, {"Content-Type": "application/json", "Authorization": "Bearer %s" % self.authorization}, "/api/v1/streams")
return return
self.logger.info(f"""[DEBUG] Successful request result request: Status= {ret.status_code} & Response= {ret.text}. Action status: {action_result["status"]}""")
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
self.logger.info(f"[DEBUG] Unexpected ConnectionError happened: {e}") self.logger.info(f"[DEBUG] Unexpected ConnectionError happened: {e}")
except TypeError as e: except TypeError as e:
+52 -47
View File
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import theme from "../theme.jsx"; import theme from "../theme.jsx";
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import ReactJson from "react-json-view";
import { import {
Tooltip, Tooltip,
@@ -42,6 +43,7 @@ import {
Visibility as VisibilityIcon, Visibility as VisibilityIcon,
VisibilityOff as VisibilityOffIcon, VisibilityOff as VisibilityOffIcon,
} from "@mui/icons-material"; } from "@mui/icons-material";
import { validateJson, } from "../views/Workflows.jsx";
const scrollStyle1 = { const scrollStyle1 = {
height: 100, height: 100,
@@ -59,6 +61,7 @@ const scrollStyle2 = {
overflow: "scroll", overflow: "scroll",
} }
const CacheView = (props) => { const CacheView = (props) => {
const { globalUrl, userdata, serverside, orgId } = props; const { globalUrl, userdata, serverside, orgId } = props;
const [orgCache, setOrgCache] = React.useState(""); const [orgCache, setOrgCache] = React.useState("");
@@ -345,7 +348,7 @@ const CacheView = (props) => {
return ( return (
<div> <div style={{paddingBottom: 250, }}>
{modalView} {modalView}
<div style={{ marginTop: 20, marginBottom: 20 }}> <div style={{ marginTop: 20, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Shuffle Datastore</h2> <h2 style={{ display: "inline" }}>Shuffle Datastore</h2>
@@ -391,19 +394,18 @@ const CacheView = (props) => {
<ListItem> <ListItem>
<ListItemText <ListItemText
primary="Key" primary="Key"
// style={{ minWidth: 150, maxWidth: 150 }} style={{ minWidth: 250, maxWidth: 250, }}
/> />
<ListItemText <ListItemText
primary="value" primary="Value"
// style={{ minWidth: 150, maxWidth: 150 }} style={{ minWidth: 400, maxWidth: 400, }}
/>
<ListItemText
primary="Updated"
// style={{ minWidth: 150, maxWidth: 150 }}
/> />
<ListItemText <ListItemText
primary="Actions" primary="Actions"
// style={{ minWidth: 150, maxWidth: 150 }} style={{ minWidth: 150, maxWidth: 150, marginLeft: 50, }}
/>
<ListItemText
primary="Updated"
/> />
</ListItem> </ListItem>
{listCache === undefined || listCache === null {listCache === undefined || listCache === null
@@ -413,58 +415,54 @@ const CacheView = (props) => {
if (index % 2 === 0) { if (index % 2 === 0) {
bgColor = "#1f2023"; bgColor = "#1f2023";
} }
const validate = validateJson(data.value);
console.log("Past validate: ", validate);
return ( return (
<ListItem key={index} style={{ backgroundColor: bgColor }}> <ListItem key={index} style={{ backgroundColor: bgColor }}>
<ListItemText <ListItemText
style={{ style={{
maxWidth: 225, maxWidth: 250,
minWidth: 225, minWidth: 250,
overflow: "hidden", overflow: "hidden",
}} }}
primary={data.key} primary={data.key}
/> />
<div style={scrollStyle1}>
<ListItemText <ListItemText
// style={{ style={{
// maxWidth: 225, minWidth: 400,
// maxHeight: 150, maxWidth: 400,
// // overflow: "hidden", }}
// paddingLeft: "52px", primary={validate.valid ?
// overflow: "scroll", <ReactJson
src={validate.result}
// }} theme={theme.palette.jsonTheme}
style={scrollStyle2} style={theme.palette.reactJsonStyle}
// style={{ maxWidth: 100, minWidth: 100 }} collapsed={true}
// onMouseOver={() => enableClipboard={(copy) => {
// setShow((prevState) => ({ ...prevState, [data.value]: true })) //handleReactJsonClipboard(copy);
// } }}
// onMouseLeave={() => displayDataTypes={false}
// setShow((prevState) => ({ ...prevState, [data.value]: false })) onSelect={(select) => {
// } //HandleJsonCopy(showResult, select, data.action.label);
//primary={show[data.value] ? data.value : `${data.value.substring(0, 5)}...`} //console.log("SELECTED!: ", select);
primary={data.value} }}
/> name={"value"}
</div> />
:
data.value
}
/>
<ListItemText <ListItemText
style={{ style={{
maxWidth: 225, maxWidth: 150,
minWidth: 225, minWidth: 150,
overflow: "hidden", marginLeft: 50,
marginLeft: "42px",
}}
primary={new Date(data.edited * 1000).toISOString()}
/>
<ListItemText
style={{
minWidth: 250,
maxWidth: 250,
overflow: "hidden",
paddingLeft: "155px",
}} }}
primary=<span style={{ display: "inline" }}> primary=<span style={{ display: "inline" }}>
<Tooltip <Tooltip
title="Edit" title="Edit item"
style={{}} style={{}}
aria-label={"Edit"} aria-label={"Edit"}
> >
@@ -484,7 +482,7 @@ const CacheView = (props) => {
</span> </span>
</Tooltip> </Tooltip>
<Tooltip <Tooltip
title={"Delete Cache"} title={"Delete item"}
style={{ marginLeft: 15, }} style={{ marginLeft: 15, }}
aria-label={"Delete"} aria-label={"Delete"}
> >
@@ -504,6 +502,13 @@ const CacheView = (props) => {
</Tooltip> </Tooltip>
</span> </span>
/> />
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
}}
primary={new Date(data.edited * 1000).toISOString()}
/>
</ListItem> </ListItem>
); );
})} })}
+1
View File
@@ -31,6 +31,7 @@ const theme = createTheme(adaptV4Theme({
borderRadius: 5, borderRadius: 5,
border: "1px solid rgba(255,255,255,0.7)", border: "1px solid rgba(255,255,255,0.7)",
padding: 5, padding: 5,
width: "100%",
}, },
textFieldStyle: { textFieldStyle: {
backgroundColor: "#383B40", backgroundColor: "#383B40",
+10 -6
View File
@@ -1856,18 +1856,22 @@ const AngularWorkflow = (defaultprops) => {
}) })
.then((responseJson) => { .then((responseJson) => {
if (!responseJson.success) { if (!responseJson.success) {
//toast("Failed to start: " + responseJson.reason); //toast("Failed to start: " + responseJson.reason);
toast(responseJson.reason); toast(responseJson.reason);
//toast.error(responseJson.reason); //toast.error(responseJson.reason);
setExecutionRunning(false); setExecutionRunning(false);
setExecutionRequestStarted(false); setExecutionRequestStarted(false);
stop(); stop();
for (let i = 0; i < curelements.length; i++) { for (let i = 0; i < curelements.length; i++) {
curelements[i].removeClass("not-executing-highlight"); curelements[i].removeClass("not-executing-highlight");
} }
return; return;
} else { } else {
if (responseJson.execution_id !== undefined && responseJson.execution_id !== null && responseJson.execution_id.length > 0) {
navigate(`?execution_id=${responseJson.execution_id}`)
}
setExecutionRunning(true); setExecutionRunning(true);
setExecutionRequestStarted(false); setExecutionRequestStarted(false);
} }