Fixed app_sdk bug

This commit is contained in:
frikky
2020-05-15 19:39:45 +02:00
parent e98ac680dd
commit 2f06a383bd
3 changed files with 50 additions and 30 deletions
+6 -7
View File
@@ -198,15 +198,15 @@ const AngularWorkflow = (props) => {
const debugView = workflowExecutions.length > 0 ? const debugView = workflowExecutions.length > 0 ?
<Draggable> <Draggable>
<div style={{color: "white", position: "fixed", top: appBarSize+65, left: leftBarSize+20, zIndex: 5000, backgroundColor: "rgba(0,0,0,0.1)", minHeight: 100, padding: 15, maxHeight: 100, maxWidth: 500, overflowX: "hidden",}}> <div style={{color: "white", position: "fixed", top: appBarSize+65, left: leftBarSize+20, zIndex: 5000, minHeight: 100, padding: 15, maxHeight: 100, maxWidth: 500, overflowX: "hidden",}}>
{workflowExecutions.slice(0,25).map(data => { {workflowExecutions.slice(0,15).map(data => {
console.log("DATA: ", data)
return ( return (
<div> <div>
{new Date(data.started_at*1000).toISOString()} {new Date(data.started_at*1000).toISOString()}
, {data.status} , {data.status}
{data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "}
{data.result.length > 0 ? ", "+data.result : ", "} {data.result.length > 0 ? ", "+data.result : ", "}
{data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "}
<Divider style={{backgroundColor: "white"}}/>
</div> </div>
) )
return return
@@ -223,8 +223,8 @@ const AngularWorkflow = (props) => {
'Accept': 'application/json', 'Accept': 'application/json',
}, },
body: JSON.stringify(executionRequest), body: JSON.stringify(executionRequest),
credentials: "include", credentials: "include",
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for stream results :O!") console.log("Status not 200 for stream results :O!")
@@ -234,7 +234,6 @@ const AngularWorkflow = (props) => {
}) })
.then((responseJson) => { .then((responseJson) => {
handleUpdateResults(responseJson) handleUpdateResults(responseJson)
getWorkflowExecution(props.match.params.key)
}) })
.catch(error => { .catch(error => {
alert.error(error.toString()) alert.error(error.toString())
+42 -21
View File
@@ -54,7 +54,7 @@ const Workflows = (props) => {
duration: 5000, duration: 5000,
startImmediate: false, startImmediate: false,
callback: () => { callback: () => {
getWorkflowExecution(selectedWorkflow.id) getWorkflowExecution(selectedWorkflow.id)
} }
}); });
@@ -395,7 +395,7 @@ const Workflows = (props) => {
<a href={"/workflows/"+data.id}> <a href={"/workflows/"+data.id}>
<Tooltip color="primary" title="Edit workflow" placement="bottom"> <Tooltip color="primary" title="Edit workflow" placement="bottom">
<Button style={{}} color="primary" variant="outlined" style={{marginRight: 10}} onClick={() => {}}> <Button style={{}} color="primary" variant="outlined" style={{marginRight: 10}} onClick={() => {}}>
<EditIcon /> <EditIcon style={{marginRight: 10}}/> Edit
</Button> </Button>
</Tooltip> </Tooltip>
</a> </a>
@@ -502,7 +502,7 @@ const Workflows = (props) => {
jsonvalid = false jsonvalid = false
} }
console.log("VALID: ", jsonvalid) //console.log("VALID: ", jsonvalid)
if (jsonvalid) { if (jsonvalid) {
showResult = <ReactJson showResult = <ReactJson
src={JSON.parse(showResult)} src={JSON.parse(showResult)}
@@ -584,9 +584,11 @@ const Workflows = (props) => {
var arg = null var arg = null
if (selectedExecution.execution_argument !== undefined && selectedExecution.execution_argument.length > 0) { if (selectedExecution.execution_argument !== undefined && selectedExecution.execution_argument.length > 0) {
var jsonvalid = false var jsonvalid = true
var showResult = selectedExecution.execution_argument.trim() var showResult = selectedExecution.execution_argument.trim()
showResult = replaceAll(showResult, " None", " \"None\""); showResult = replaceAll(showResult, " None", " \"None\"");
try { try {
JSON.parse(showResult) JSON.parse(showResult)
} catch (e) { } catch (e) {
@@ -599,7 +601,30 @@ const Workflows = (props) => {
theme="solarized" theme="solarized"
collapsed={true} collapsed={true}
displayDataTypes={false} displayDataTypes={false}
name={"Execution argument"} name={"Execution argument / webhook"}
/>
: showResult
}
var lastresult = null
if (selectedExecution.result !== undefined && selectedExecution.result.length > 0) {
var jsonvalid = true
var showResult = selectedExecution.result.trim()
showResult = replaceAll(showResult, " None", " \"None\"");
try {
JSON.parse(showResult)
} catch (e) {
jsonvalid = false
}
lastresult = jsonvalid ?
<ReactJson
src={JSON.parse(showResult)}
theme="solarized"
collapsed={true}
displayDataTypes={false}
name={"Last result from execution"}
/> />
: showResult : showResult
} }
@@ -611,32 +636,25 @@ const Workflows = (props) => {
*/ */
if (Object.getOwnPropertyNames(selectedExecution).length > 0 && selectedExecution.workflow.actions !== null) { if (Object.getOwnPropertyNames(selectedExecution).length > 0 && selectedExecution.workflow.actions !== null) {
return ( return (
<div > <div>
<div> <div>
Actions: {selectedExecution.workflow.actions.length} <b>Status:</b> {selectedExecution.status}
</div> </div>
<div> <div>
Results: {resultsLength} <b>Started:</b> {starttime.toISOString()}
</div> </div>
<div> <div>
Results: {resultsLength} <b>Finished:</b> {endtime.toISOString()}
</div> </div>
<div> <div>
Result: {selectedExecution.result} <b>Last node:</b> {selectedExecution.last_node}
</div> </div>
<div> <div>
Status: {selectedExecution.status} <b>Last Result:</b> {lastresult}
</div> </div>
<div> <div style={{marginTop: 10}}>
Starttime: {starttime.toISOString()} {arg}
</div> </div>
<div>
Finished: {endtime.toISOString()}
</div>
<div>
Last node: {selectedExecution.last_node}
</div>
{arg}
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/>
{resultsHandler} {resultsHandler}
</div> </div>
@@ -825,7 +843,10 @@ const Workflows = (props) => {
<h2>Executions</h2> <h2>Executions</h2>
</div> </div>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<Button color="primary" style={{marginTop: "20px"}} variant="outlined" onClick={() => {alert.info("Refreshing executions"); getWorkflowExecution(selectedWorkflow.id)}}> <Button color="primary" style={{marginTop: "20px"}} variant="outlined" onClick={() => {
alert.info("Refreshing executions");
getWorkflowExecution(selectedWorkflow.id)
}}>
<CachedIcon /> <CachedIcon />
</Button> </Button>
</div> </div>
+2 -2
View File
@@ -189,9 +189,9 @@ class AppBase:
value = get_json_value(fullexecution, to_be_replaced) value = get_json_value(fullexecution, to_be_replaced)
if isinstance(value, str): if isinstance(value, str):
parameter["value"] = value parameter["value"] = parameter["value"].replace(to_be_replaced, value)
elif isinstance(value, dict): elif isinstance(value, dict):
parameter["value"] = json.dumps(value) parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
# Check if json inside string # Check if json inside string