From 99ec5739e6b3001afbcc2b79e7ac3ad56ce0779d Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 25 Jun 2020 21:06:01 +0200 Subject: [PATCH] Workflow fixes towards blog #4 --- backend/app_sdk/app_base.py | 31 ++++- frontend/src/AngularWorkflow.js | 225 +++++++------------------------- frontend/src/App.js | 9 +- frontend/src/Apps.js | 6 + frontend/src/Workflows.js | 8 +- 5 files changed, 90 insertions(+), 189 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 29f32999..cd7fc992 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -173,7 +173,16 @@ class AppBase: if "split" in thistype: return data.split() if "len" in thistype or "length" in thistype: - return len(data) + tmp = "" + try: + tmp = json.loads(data) + except: + pass + + if isinstance(tmp, list): + return str(len(tmp)) + + return str(len(data)) if "parse" in thistype: splitvalues = [] default_error = """Error. Expected syntax: parse(["hello","test1"],0:1)""" @@ -554,13 +563,21 @@ class AppBase: if destinationvalue.lower() in sourcevalue.lower(): return True elif check.lower() == "larger than": - if sourcevalue.isdigit() and destinationvalue.isdigit(): - if int(sourcevalue) > int(destinationvalue): - return True + try: + if sourcevalue.isdigit() and destinationvalue.isdigit(): + if int(sourcevalue) > int(destinationvalue): + return True + except AttributeError as e: + self.logger.error("Condition larger than failed with values %s and %s: %s" % (sourcevalue, destinationvalue, e)) + return False elif check.lower() == "smaller than": - if sourcevalue.isdigit() and destinationvalue.isdigit(): - if int(sourcevalue) < int(destinationvalue): - return True + try: + if sourcevalue.isdigit() and destinationvalue.isdigit(): + if int(sourcevalue) < int(destinationvalue): + return True + except AttributeError as e: + self.logger.error("Condition smaller than failed with values %s and %s: %s" % (sourcevalue, destinationvalue, e)) + return False else: self.logger.info("Condition: can't handle %s yet. Setting to true" % check) diff --git a/frontend/src/AngularWorkflow.js b/frontend/src/AngularWorkflow.js index a6931465..b5d4a71e 100644 --- a/frontend/src/AngularWorkflow.js +++ b/frontend/src/AngularWorkflow.js @@ -219,7 +219,7 @@ const AngularWorkflow = (props) => {
{workflowExecutions.slice(0,15).map(data => { return ( -
+
{new Date(data.started_at*1000).toISOString()} , {data.status} {data.result.length > 0 ? ", "+data.result : ", "} @@ -768,12 +768,12 @@ const AngularWorkflow = (props) => { //console.log("APP: ", selectedApp) setSelectedAction({}) setSelectedApp({}) - //setSelectedTrigger({}) + setSelectedTrigger({}) //setSelectedEdge({}) // setSelectedTriggerIndex(-1) //setSelectedActionEnvironment({}) - //setSelectedEdge({}) + setSelectedEdge({}) //setTriggerAuthentication({}) //setSelectedTriggerIndex(-1) //setTriggerFolders([]) @@ -850,7 +850,7 @@ const AngularWorkflow = (props) => { const onEdgeAdded = (event) => { setLastSaved(false) const edge = event.target.data() - console.log(workflow.branches) + //console.log(workflow.branches) // Check if: // dest == source && source == dest @@ -1517,14 +1517,14 @@ const AngularWorkflow = (props) => { }} > - { + { setOpen(false) setNewVariableName(variable.name) setNewVariableDescription(variable.description) setNewVariableValue(variable.value) setVariablesModalOpen(true) }} key={"Edit"}>{"Edit"} - { + { deleteVariable(variable.name) setOpen(false) }} key={"Delete"}>{"Delete"} @@ -1579,12 +1579,12 @@ const AngularWorkflow = (props) => { }} > - { + { setOpen(false) setNewVariableName(variable.name) setExecutionVariablesModalOpen(true) }} key={"Edit"}>{"Edit"} - { + { deleteExecutionVariable(variable.name) setOpen(false) }} key={"Delete"}>{"Delete"} @@ -2183,6 +2183,7 @@ const AngularWorkflow = (props) => { var allkeys = [action.id] var handled = [] var results = [] + console.log("BEFORE PARENTS!") while(true) { for (var key in allkeys) { @@ -2410,12 +2411,7 @@ const AngularWorkflow = (props) => { datafield =
- { itemColor = "#ffeb3b" } return ( -
+
@@ -2657,11 +2650,6 @@ const AngularWorkflow = (props) => { Environment { }} /> - console.log(data) - - // Remap data based on variant - if (data.variant === "STATIC_VALUE") { - staticcolor = "#f85a3e" - } else if (data.variant === "ACTION_RESULT") { - // Gets the parents of the current node - var parents = getParents(workflow.actions.find(a => a.id === selectedEdge["target"])) - actioncolor = "#f85a3e" - // set the datafield - //var datafieldvalue = "Error: No parents. Action not eligible" - //if (parents.length > 0) { - // datafieldvalue = parents[0].label - //} - - datafield = -
- - { - changeActionVariable(data.action_field, e.target.value) - }} - />
- - } else if (data.variant === "WORKFLOW_VARIABLE") { - varcolor = "#f85a3e" - if (workflow.workflow_variables === null || workflow.workflow_variables === undefined || workflow.workflow_variables.length === 0) { - setCurrentView(2) - datafield = -
-
- Looks like you don't have any variables yet. -
-
- -
-
- } else { - // FIXME - this is a shitty solution that needs re-renders all the time - datafield = - - } - - } - const changeActionVariable = (variable, value) => { // set the name data.value = value @@ -3123,47 +3006,30 @@ const AngularWorkflow = (props) => { } return ( -
-
-
-
- {data.name} -
- -
{ - e.preventDefault() - changeActionParameterVariant("STATIC_VALUE") - }}> - +
+
+
+
+ {data.name}
- -  |  - -
{ - e.preventDefault() - changeActionParameterVariant("ACTION_RESULT") - }}> - -
-
-  |  - -
{ - e.preventDefault() - changeActionParameterVariant("WORKFLOW_VARIABLE") - }}> - -
-
-
- {datafield} -
+ +
{ + e.preventDefault() + changeActionParameterVariant("STATIC_VALUE") + }}> + +
+
+
+ {datafield} +
) } const menuItemStyle = { color: "white", + backgroundColor: inputColor } const conditionsModal = @@ -3243,6 +3109,16 @@ const AngularWorkflow = (props) => { setConditionValue(conditionValue) setVariableAnchorEl(null) }} key={"matches regex"}>matches regex + { + conditionValue.value = "larger than" + setConditionValue(conditionValue) + setVariableAnchorEl(null) + }} key={"larger than"}>larger than + { + conditionValue.value = "less than" + setConditionValue(conditionValue) + setVariableAnchorEl(null) + }} key={"less than"}>less than
@@ -3303,8 +3179,8 @@ const AngularWorkflow = (props) => { } const paperVariableStyle = { - minHeight: "50px", - maxHeight: "50px", + minHeight: 75, + maxHeight: 75, minWidth: "100%", maxWidth: "100%", marginTop: "5px", @@ -3330,15 +3206,15 @@ const AngularWorkflow = (props) => { setDestinationValue(condition.destination) setConditionsModalOpen(true) }}> -
+
{condition.source.value}
-
{}}> +
{}}> {condition.condition.value}
-
+
{condition.destination.value}
@@ -3348,6 +3224,7 @@ const AngularWorkflow = (props) => { aria-controls="long-menu" aria-haspopup="true" onClick={menuClick} + style={{color: "white",}} > @@ -3366,7 +3243,7 @@ const AngularWorkflow = (props) => { setAnchorEl(null) }} > - { + { setOpen(false) deleteCondition(index) }} key={"Delete"}>{"Delete"} @@ -3557,12 +3434,6 @@ const AngularWorkflow = (props) => { rows="10" value={selectedTrigger.parameters[0].value.split(splitter)} style={{backgroundColor: inputColor, color: "white"}} - PaperProps={{ - style: { - height: "200px", - backgroundColor: inputColor, - } - }} SelectDisplayProps={{ style: { marginLeft: 10, diff --git a/frontend/src/App.js b/frontend/src/App.js index 8eb7f108..c162b774 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -59,7 +59,14 @@ const theme = createMuiTheme({ }, typography: { useNextVariants: true - } + }, + overrides: { + MuiMenu: { + list: { + backgroundColor: inputColor, + }, + }, + }, }); diff --git a/frontend/src/Apps.js b/frontend/src/Apps.js index 8bdb587f..3e48b8e6 100644 --- a/frontend/src/Apps.js +++ b/frontend/src/Apps.js @@ -448,6 +448,12 @@ const Apps = (props) => { })}
: null} + {selectedAction.description !== undefined && selectedAction.description !== null ? +
+ Action Description
+ {selectedAction.description} +
+ : null}
: null diff --git a/frontend/src/Workflows.js b/frontend/src/Workflows.js index 043b35c7..95c2e2ba 100644 --- a/frontend/src/Workflows.js +++ b/frontend/src/Workflows.js @@ -383,21 +383,21 @@ const Workflows = (props) => { }} > - { + { setModalOpen(true) setEditingWorkflow(data) setNewWorkflowName(data.name) setNewWorkflowDescription(data.description) }} key={"change"}>{"Change name"} - { + { copyWorkflow(data) setOpen(false) }} key={"copy"}>{"Copy"} - { + { exportWorkflow(data) setOpen(false) }} key={"export"}>{"Export"} - { + { deleteWorkflow(data.id) setOpen(false) }} key={"delete"}>{"Delete"}