From 2f06a383bdd03de00ca7dea2c4cfc730cee29fe3 Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 15 May 2020 19:39:45 +0200 Subject: [PATCH] Fixed app_sdk bug --- frontend/src/AngularWorkflow.js | 13 +++--- frontend/src/Workflows.js | 63 ++++++++++++++++++---------- functions/onprem/app_sdk/app_base.py | 4 +- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/frontend/src/AngularWorkflow.js b/frontend/src/AngularWorkflow.js index 1c53d140..7f3fda3a 100644 --- a/frontend/src/AngularWorkflow.js +++ b/frontend/src/AngularWorkflow.js @@ -198,15 +198,15 @@ const AngularWorkflow = (props) => { const debugView = workflowExecutions.length > 0 ? -
- {workflowExecutions.slice(0,25).map(data => { - console.log("DATA: ", data) +
+ {workflowExecutions.slice(0,15).map(data => { return (
{new Date(data.started_at*1000).toISOString()} , {data.status} - {data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "} {data.result.length > 0 ? ", "+data.result : ", "} + {data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "} +
) return @@ -223,8 +223,8 @@ const AngularWorkflow = (props) => { 'Accept': 'application/json', }, body: JSON.stringify(executionRequest), - credentials: "include", - }) + credentials: "include", + }) .then((response) => { if (response.status !== 200) { console.log("Status not 200 for stream results :O!") @@ -234,7 +234,6 @@ const AngularWorkflow = (props) => { }) .then((responseJson) => { handleUpdateResults(responseJson) - getWorkflowExecution(props.match.params.key) }) .catch(error => { alert.error(error.toString()) diff --git a/frontend/src/Workflows.js b/frontend/src/Workflows.js index 78c850fd..d545bba3 100644 --- a/frontend/src/Workflows.js +++ b/frontend/src/Workflows.js @@ -54,7 +54,7 @@ const Workflows = (props) => { duration: 5000, startImmediate: false, callback: () => { - getWorkflowExecution(selectedWorkflow.id) + getWorkflowExecution(selectedWorkflow.id) } }); @@ -395,7 +395,7 @@ const Workflows = (props) => { @@ -502,7 +502,7 @@ const Workflows = (props) => { jsonvalid = false } - console.log("VALID: ", jsonvalid) + //console.log("VALID: ", jsonvalid) if (jsonvalid) { showResult = { var arg = null if (selectedExecution.execution_argument !== undefined && selectedExecution.execution_argument.length > 0) { - var jsonvalid = false + var jsonvalid = true + var showResult = selectedExecution.execution_argument.trim() showResult = replaceAll(showResult, " None", " \"None\""); + try { JSON.parse(showResult) } catch (e) { @@ -599,7 +601,30 @@ const Workflows = (props) => { theme="solarized" collapsed={true} 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 ? + : showResult } @@ -611,32 +636,25 @@ const Workflows = (props) => { */ if (Object.getOwnPropertyNames(selectedExecution).length > 0 && selectedExecution.workflow.actions !== null) { return ( -
+
- Actions: {selectedExecution.workflow.actions.length} + Status: {selectedExecution.status}
- Results: {resultsLength} + Started: {starttime.toISOString()}
- Results: {resultsLength} + Finished: {endtime.toISOString()}
- Result: {selectedExecution.result} + Last node: {selectedExecution.last_node}
- Status: {selectedExecution.status} + Last Result: {lastresult}
-
- Starttime: {starttime.toISOString()} +
+ {arg}
-
- Finished: {endtime.toISOString()} -
-
- Last node: {selectedExecution.last_node} -
- {arg} {resultsHandler}
@@ -825,7 +843,10 @@ const Workflows = (props) => {

Executions

-
diff --git a/functions/onprem/app_sdk/app_base.py b/functions/onprem/app_sdk/app_base.py index f914d5d4..8195a9c4 100644 --- a/functions/onprem/app_sdk/app_base.py +++ b/functions/onprem/app_sdk/app_base.py @@ -189,9 +189,9 @@ class AppBase: value = get_json_value(fullexecution, to_be_replaced) if isinstance(value, str): - parameter["value"] = value + parameter["value"] = parameter["value"].replace(to_be_replaced, value) 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