Upgrade pre shuffle-shared merge

This commit is contained in:
frikky
2021-03-21 18:01:09 +01:00
parent 4f49a87a21
commit 6574f122f1
6 changed files with 94 additions and 33 deletions
+3 -3
View File
@@ -141,11 +141,11 @@ class AppBase:
print(f"VALUE APPEND: {value}") print(f"VALUE APPEND: {value}")
param_value += value param_value += value
if param["name"] not in param_names: if param["name"] not in param_names:
param_names.append(param["name"]) param_names.append(param["name"])
except (KeyError, NameError) as e: except (KeyError, NameError) as e:
print(f"Key/NameError in param handler: {e}") print(f"""Key/NameError in param handler for {param["name"]}: {e}""")
print(f"OUTER VALUE: {param_value}") print(f"OUTER VALUE: {param_value}")
if len(param_value) > 0: if len(param_value) > 0:
@@ -2292,7 +2292,7 @@ class AppBase:
if action_result["result"] == "": if action_result["result"] == "":
action_result["result"] = result action_result["result"] = result
self.logger.debug(f"Executed {action['label']}-{action['id']} with result: {result}") self.logger.debug(f"Executed {action['label']}-{action['id']}")#with result: {result}")
#self.logger.debug(f"Data: %s" % action_result) #self.logger.debug(f"Data: %s" % action_result)
except TypeError as e: except TypeError as e:
print("TypeError issue: %s" % e) print("TypeError issue: %s" % e)
+6 -8
View File
@@ -429,15 +429,13 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
) )
// Use lowercase when checking // Use lowercase when checking
/*
if strings.Contains(functionname, "login") {
//log.Printf("FUNCTION: %s", data)
log.Println(data)
log.Printf("Queries: %s", queryString)
}
*/
//log.Printf(data) if strings.Contains(functionname, "attachment") {
//log.Printf("FUNCTION: %s", data)
//log.Println(data)
//log.Printf("Queries: %s", queryString)
}
return functionname, data return functionname, data
} }
+26 -2
View File
@@ -3405,7 +3405,7 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) {
//resp.WriteHeader(200) //resp.WriteHeader(200)
//resp.Write([]byte(`{"success": true}`)) //resp.Write([]byte(`{"success": true}`))
if hook.Status == "stopped" { if hook.Status == "stopped" {
log.Printf("Not running %s because hook status is stopped", hook.Id) log.Printf("[WARNING] Not running %s because hook status is stopped", hook.Id)
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "The webhook isn't running. Click start to start it"}`))) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "The webhook isn't running. Click start to start it"}`)))
return return
@@ -3436,10 +3436,34 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) {
return return
} }
//log.Printf("BODY: %s", parsedBody)
// This is a specific fix for MSteams and may fix other things as well
// Scared whether it may stop other things though, but that's a future problem
// (famous last words)
parsedBody := string(body)
if strings.Contains(parsedBody, "choice") {
if strings.Count(parsedBody, `\\n`) > 2 {
parsedBody = strings.Replace(parsedBody, `\\n`, "", -1)
}
if strings.Count(parsedBody, `\u0022`) > 2 {
parsedBody = strings.Replace(parsedBody, `\u0022`, `"`, -1)
}
if strings.Count(parsedBody, `\\"`) > 2 {
parsedBody = strings.Replace(parsedBody, `\\"`, `"`, -1)
}
if strings.Contains(parsedBody, `"extra": "{`) {
parsedBody = strings.Replace(parsedBody, `"extra": "{`, `"extra": {`, 1)
parsedBody = strings.Replace(parsedBody, `}"}`, `}}`, 1)
}
}
//log.Printf("\n\nPARSEDBODY: %s", parsedBody)
newBody := ExecutionStruct{ newBody := ExecutionStruct{
Start: hook.Start, Start: hook.Start,
ExecutionSource: "webhook", ExecutionSource: "webhook",
ExecutionArgument: string(body), ExecutionArgument: parsedBody,
} }
b, err := json.Marshal(newBody) b, err := json.Marshal(newBody)
+8 -2
View File
@@ -981,6 +981,10 @@ func validateNewWorkerExecution(body []byte) error {
return errors.New(fmt.Sprintf("Bad length of trigger: %d (probably normal app)", len(execution.Workflow.Triggers))) return errors.New(fmt.Sprintf("Bad length of trigger: %d (probably normal app)", len(execution.Workflow.Triggers)))
} }
if baseExecution.Status != "WAITING" && baseExecution.Status != "EXECUTING" {
return errors.New(fmt.Sprintf("Workflow is already finished or failed. Can't update"))
}
if execution.Status == "EXECUTING" { if execution.Status == "EXECUTING" {
//log.Printf("[INFO] Inside executing.") //log.Printf("[INFO] Inside executing.")
extra := 0 extra := 0
@@ -994,6 +998,8 @@ func validateNewWorkerExecution(body []byte) error {
if len(execution.Workflow.Actions)+extra == len(execution.Results) { if len(execution.Workflow.Actions)+extra == len(execution.Results) {
execution.Status = "FINISHED" execution.Status = "FINISHED"
} }
log.Printf("BASEEXECUTION LENGTH: %d", len(baseExecution.Workflow.Actions)+extra)
} }
// FIXME: Add extra here // FIXME: Add extra here
@@ -3699,14 +3705,14 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
Status: "SKIPPED", Status: "SKIPPED",
}) })
} else { } else {
log.Printf("SHOULD KEEP TRIGGER %s", trigger.ID) //log.Printf("SHOULD KEEP TRIGGER %s", trigger.ID)
} }
} }
} }
//childNodes := findChildNodes(workflowExecution, workflowExecution.Start) //childNodes := findChildNodes(workflowExecution, workflowExecution.Start)
if !startFound { if !startFound {
log.Printf("Startnode %s doesn't exist!", workflowExecution.Start) log.Printf("[ERROR] Startnode %s doesn't exist!!", workflowExecution.Start)
return WorkflowExecution{}, fmt.Sprintf("Workflow action %s doesn't exist in workflow", workflowExecution.Start), errors.New(fmt.Sprintf(`Workflow start node "%s" doesn't exist. Exiting!`, workflowExecution.Start)) return WorkflowExecution{}, fmt.Sprintf("Workflow action %s doesn't exist in workflow", workflowExecution.Start), errors.New(fmt.Sprintf(`Workflow start node "%s" doesn't exist. Exiting!`, workflowExecution.Start))
} }
+10 -4
View File
@@ -164,7 +164,7 @@ const data = [{
css: { css: {
'background-color': '#ffef47', 'background-color': '#ffef47',
'border-color': '#ffef47', 'border-color': '#ffef47',
'border-width': '5px', 'border-width': '8px',
'transition-property': 'border-width', 'transition-property': 'border-width',
'transition-duration': '0.25s', 'transition-duration': '0.25s',
}, },
@@ -212,10 +212,13 @@ const data = [{
selector: 'edge.success-highlight', selector: 'edge.success-highlight',
css: { css: {
'width': '5px', 'width': '5px',
'target-arrow-color': '#399645', 'target-arrow-color': '#41dcab',
'line-color': '#399645', 'line-color': '#41dcab',
'transition-property': 'line-color, width', 'transition-property': 'line-color, width',
'transition-duration': '0.5s', 'transition-duration': '0.5s',
"line-fill": "linear-gradient",
"line-gradient-stop-positions": ["0.0", "100"],
"line-gradient-stop-colors": ["#41dcab", "#41dcab"],
}, },
}, },
{ {
@@ -223,7 +226,10 @@ const data = [{
css: { css: {
'target-arrow-color': '#991818', 'target-arrow-color': '#991818',
'line-color': '#991818', 'line-color': '#991818',
'line-style': 'dashed' 'line-style': 'dashed',
"line-fill": "linear-gradient",
"line-gradient-stop-positions": ["0.0", "100"],
"line-gradient-stop-colors": ["#991818", "#991818"],
}, },
}, },
{ {
+41 -14
View File
@@ -447,7 +447,7 @@ const AngularWorkflow = (props) => {
return response.json() return response.json()
}) })
.then((responseJson) => { .then((responseJson) => {
handleUpdateResults(responseJson) handleUpdateResults(responseJson, executionRequest)
}) })
.catch(error => { .catch(error => {
console.log("Error: ", error) console.log("Error: ", error)
@@ -484,7 +484,7 @@ const AngularWorkflow = (props) => {
// Controls the colors and direction of execution results. // Controls the colors and direction of execution results.
// Style is in defaultCytoscapeStyle.js // Style is in defaultCytoscapeStyle.js
const handleUpdateResults = (responseJson) => { const handleUpdateResults = (responseJson, executionRequest) => {
//console.log(responseJson) //console.log(responseJson)
// Loop nodes and find results // Loop nodes and find results
// Update on every interval? idk // Update on every interval? idk
@@ -496,11 +496,16 @@ const AngularWorkflow = (props) => {
setExecutionData(responseJson) setExecutionData(responseJson)
} }
} }
//console.log("PRE LOOPING RESULTS: !", responseJson.execution_id, executionRequest.execution_id)
if (responseJson.execution_id !== executionRequest.execution_id) { if (responseJson.execution_id !== executionRequest.execution_id) {
cy.elements().removeClass('success-highlight failure-highlight executing-highlight') cy.elements().removeClass('success-highlight failure-highlight executing-highlight')
return return
} }
//console.log("LOOPING RESULTS!")
if (responseJson.results !== null && responseJson.results !== []) { if (responseJson.results !== null && responseJson.results !== []) {
for (var key in responseJson.results) { for (var key in responseJson.results) {
var item = responseJson.results[key] var item = responseJson.results[key]
@@ -562,6 +567,8 @@ const AngularWorkflow = (props) => {
currentnode.removeClass('shuffle-hover-highlight') currentnode.removeClass('shuffle-hover-highlight')
currentnode.removeClass('awaiting-data-highlight') currentnode.removeClass('awaiting-data-highlight')
currentnode.addClass('success-highlight') currentnode.addClass('success-highlight')
incomingEdges.addClass('success-highlight')
outgoingEdges.addClass('success-highlight')
if (visited !== undefined && visited !== null && !visited.includes(item.action.label)) { if (visited !== undefined && visited !== null && !visited.includes(item.action.label)) {
if (executionRunning) { if (executionRunning) {
@@ -603,7 +610,7 @@ const AngularWorkflow = (props) => {
currentnode.addClass('failure-highlight') currentnode.addClass('failure-highlight')
if (!visited.includes(item.action.label)) { if (!visited.includes(item.action.label)) {
if (!item.action.result.includes("failed condition")) { if (item.action.result !== undefined && item.action.result !== null && !item.action.result.includes("failed condition")) {
alert.error("Error for "+item.action.label+" with result "+item.result) alert.error("Error for "+item.action.label+" with result "+item.result)
} }
visited.push(item.action.label) visited.push(item.action.label)
@@ -4014,7 +4021,7 @@ const AngularWorkflow = (props) => {
} }
} }
}}> }}>
<Tooltip color="primary" title="See last result" placement="top"> <Tooltip color="primary" title="See previous results for this action" placement="top">
<ArrowLeftIcon style={{color: "white"}}/> <ArrowLeftIcon style={{color: "white"}}/>
</Tooltip> </Tooltip>
</IconButton> </IconButton>
@@ -4029,10 +4036,16 @@ const AngularWorkflow = (props) => {
</span> </span>
</div> </div>
</div> </div>
<div style={{flex: "1"}}> <div>
<Button disabled={selectedAction.id === workflow.start} style={{zIndex: 5000, marginTop: "15px",}} color="primary" variant="outlined" onClick={(e) => { {selectedAction.id === workflow.start ? null :
defineStartnode(e) <Tooltip color="primary" title={"Make this node the start action"} placement="top">
}}>Set startnode</Button> <Button style={{zIndex: 5000, marginTop: "15px",}} color="primary" variant="outlined" onClick={(e) => {
defineStartnode(e)
}}>
<KeyboardArrowRightIcon />
</Button>
</Tooltip>
}
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -6690,17 +6703,21 @@ const AngularWorkflow = (props) => {
<Tooltip key={data.execution_id} title={data.result} placement="left-start"> <Tooltip key={data.execution_id} title={data.result} placement="left-start">
<Paper elevation={5} key={data.execution_id} square style={executionPaperStyle} onMouseOver={() => {}} onMouseOut={() => {}} onClick={() => { <Paper elevation={5} key={data.execution_id} square style={executionPaperStyle} onMouseOver={() => {}} onMouseOut={() => {}} onClick={() => {
if (data.result === undefined || data.result === null || data.result.length === 0) { if ((data.result === undefined || data.result === null || data.result.length === 0) && data.status !== "FINISHED" && data.status !== "ABORTED") {
setExecutionRequest({
"execution_id": data.execution_id,
"authorization": data.authorization,
})
start() start()
setExecutionRunning(true) setExecutionRunning(true)
setExecutionRequestStarted(false) setExecutionRequestStarted(false)
} }
const cur_execution = {
"execution_id": data.execution_id,
"authorization": data.authorization,
}
setExecutionRequest(cur_execution)
setExecutionModalView(1) setExecutionModalView(1)
setExecutionData(data) setExecutionData(data)
handleUpdateResults(data, cur_execution)
}}> }}>
<div style={{display: "flex", flex: 1}}> <div style={{display: "flex", flex: 1}}>
<div style={{marginLeft: 0, width: lastExecution === data.execution_id ? 4 : 2, backgroundColor: statusColor, marginRight: 5}} /> <div style={{marginLeft: 0, width: lastExecution === data.execution_id ? 4 : 2, backgroundColor: statusColor, marginRight: 5}} />
@@ -6880,7 +6897,17 @@ const AngularWorkflow = (props) => {
} }
return ( return (
<div key={index} style={{marginBottom: 40,}}> <div key={index} style={{marginBottom: 40,}} onMouseOver={() => {
var currentnode = cy.getElementById(data.action.id)
if (currentnode.length !== 0) {
currentnode.addClass('shuffle-hover-highlight')
}
}} onMouseOut={() => {
var currentnode = cy.getElementById(data.action.id)
if (currentnode.length !== 0) {
currentnode.removeClass('shuffle-hover-highlight')
}
}}>
<div style={{display: "flex", marginBottom: 15,}}> <div style={{display: "flex", marginBottom: 15,}}>
<IconButton style={{marginTop: "auto", marginBottom: "auto", height: 30, paddingLeft: 0, width: 30}} onClick={() => { <IconButton style={{marginTop: "auto", marginBottom: "auto", height: 30, paddingLeft: 0, width: 30}} onClick={() => {
setSelectedResult(data) setSelectedResult(data)