diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 4b100d48..ac9e766a 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -1024,7 +1024,7 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) { resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Workflowexecution is aborted because of %s with result %s and status %s"}`, workflowExecution.LastNode, workflowExecution.Result, workflowExecution.Status))) return } else { - log.Printf("Continuing even though it's aborted.") + log.Printf("[WARNING] Continuing workflow even though it's aborted (ExitOnError config)") } } @@ -1936,6 +1936,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request } } + removeTriggers := []string{} for triggerIndex, trigger := range workflowExecution.Workflow.Triggers { //log.Printf("[INFO] ID: %s vs %s", trigger.ID, workflowExecution.Start) if trigger.ID == workflowExecution.Start { @@ -1976,81 +1977,99 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request }) } else { // Replaces trigger with the subflow - if trigger.AppName == "Shuffle Workflow" { - replaceActions := false - workflowAction := "" - for _, param := range trigger.Parameters { - if param.Name == "argument" && !strings.Contains(param.Value, ".#") { - replaceActions = true - } + //if trigger.AppName == "Shuffle Workflow" { + // replaceActions := false + // workflowAction := "" + // for _, param := range trigger.Parameters { + // if param.Name == "argument" && !strings.Contains(param.Value, ".#") { + // replaceActions = true + // } - if param.Name == "startnode" { - workflowAction = param.Value - } - } + // if param.Name == "startnode" { + // workflowAction = param.Value + // } + // } - if replaceActions { - replacementNodes, newBranches, lastnode := shuffle.GetReplacementNodes(ctx, workflowExecution, trigger) - log.Printf("REPLACEMENTS: %d, %d", len(replacementNodes), len(newBranches)) - if len(replacementNodes) > 0 { - //workflowExecution.Workflow.Actions = append(workflowExecution.Workflow.Actions, action) + // if replaceActions { + // replacementNodes, newBranches, lastnode := shuffle.GetReplacementNodes(ctx, workflowExecution, trigger, trigger.Label) + // log.Printf("REPLACEMENTS: %d, %d", len(replacementNodes), len(newBranches)) + // if len(replacementNodes) > 0 { + // for _, action := range replacementNodes { + // found := false - //lastnode = replacementNodes[0] - // Have to validate in case it's the same workflow and such - for _, action := range replacementNodes { - found := false - for subActionIndex, subaction := range newActions { - if subaction.ID == action.ID { - found = true - //newActions[subActionIndex].Name = action.Name - newActions[subActionIndex].Label = action.Label - break - } - } + // for subActionIndex, subaction := range newActions { + // if subaction.ID == action.ID { + // found = true + // //newActions[subActionIndex].Name = action.Name + // newActions[subActionIndex].Label = action.Label + // break + // } + // } - if !found { - newActions = append(newActions, action) - } + // if !found { + // action.SubAction = true + // newActions = append(newActions, action) + // } - // Check if it's already set to have a value - for resultIndex, result := range defaultResults { - if result.Action.ID == action.ID { - defaultResults = append(defaultResults[:resultIndex], defaultResults[resultIndex+1:]...) - break - } - } - } + // // Check if it's already set to have a value + // for resultIndex, result := range defaultResults { + // if result.Action.ID == action.ID { + // defaultResults = append(defaultResults[:resultIndex], defaultResults[resultIndex+1:]...) + // break + // } + // } + // } - for _, branch := range newBranches { - workflowExecution.Workflow.Branches = append(workflowExecution.Workflow.Branches, branch) - } + // for _, branch := range newBranches { + // workflowExecution.Workflow.Branches = append(workflowExecution.Workflow.Branches, branch) + // } - // Append branches: - // parent -> new inner node (FIRST one) - for branchIndex, branch := range workflowExecution.Workflow.Branches { - if branch.DestinationID == trigger.ID { - log.Printf("REPLACE DESTINATION WITH %s!!", workflowAction) - workflowExecution.Workflow.Branches[branchIndex].DestinationID = workflowAction - } + // // Append branches: + // // parent -> new inner node (FIRST one) + // for branchIndex, branch := range workflowExecution.Workflow.Branches { + // if branch.DestinationID == trigger.ID { + // log.Printf("REPLACE DESTINATION WITH %s!!", workflowAction) + // workflowExecution.Workflow.Branches[branchIndex].DestinationID = workflowAction + // } - if branch.SourceID == trigger.ID { - log.Printf("REPLACE SOURCE WITH LASTNODE %s!!", lastnode) - workflowExecution.Workflow.Branches[branchIndex].SourceID = lastnode - } - } + // if branch.SourceID == trigger.ID { + // log.Printf("REPLACE SOURCE WITH LASTNODE %s!!", lastnode) + // workflowExecution.Workflow.Branches[branchIndex].SourceID = lastnode + // } + // } - // Remove the trigger - workflowExecution.Workflow.Triggers = append(workflowExecution.Workflow.Triggers[:triggerIndex], workflowExecution.Workflow.Triggers[triggerIndex+1:]...) - workflow.Triggers = append(workflow.Triggers[:triggerIndex], workflow.Triggers[triggerIndex+1:]...) - } + // // Remove the trigger + // removeTriggers = append(removeTriggers, workflowExecution.Workflow.Triggers[triggerIndex].ID) + // } - log.Printf("NEW ACTION LENGTH %d, RESULT: %d, Triggers: %d", len(newActions), len(defaultResults), len(workflowExecution.Workflow.Triggers)) - } - } + // log.Printf("NEW ACTION LENGTH %d, RESULT: %d, Triggers: %d, BRANCHES: %d", len(newActions), len(defaultResults), len(workflowExecution.Workflow.Triggers), len(workflowExecution.Workflow.Branches)) + // } + //} + _ = triggerIndex } } } + //newTriggers := []shuffle.Trigger{} + //for _, trigger := range workflowExecution.Workflow.Triggers { + // found := false + // for _, triggerId := range removeTriggers { + // if trigger.ID == triggerId { + // found = true + // break + // } + // } + + // if found { + // log.Printf("[WARNING] Removed trigger %s during execution", trigger.ID) + // continue + // } + + // newTriggers = append(newTriggers, trigger) + //} + //workflowExecution.Workflow.Triggers = newTriggers + _ = removeTriggers + if !startFound { if len(workflowExecution.Start) == 0 && len(workflowExecution.Workflow.Start) > 0 { workflowExecution.Start = workflow.Start diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 3b11d6dd..bd450a0d 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -554,9 +554,9 @@ const AngularWorkflow = (props) => { if (executionData.execution_id === undefined || (responseJson.execution_id === executionData.execution_id && responseJson.results !== undefined && responseJson.results !== null)) { if (executionData.status !== responseJson.status || executionData.result !== responseJson.result || executionData.results.length !== responseJson.results.length) { - console.log("Updated state with this data:") - console.log(responseJson) - console.log(executionData) + //console.log("Updated state with this data:") + //console.log(responseJson) + //console.log(executionData) setExecutionData(responseJson) } else { console.log("NOT updating state.") @@ -1731,6 +1731,7 @@ const AngularWorkflow = (props) => { console.log(tmpapp) console.log(curaction) setSelectedApp(tmpapp) + //setSelectedAction(JSON.parse(JSON.stringify(curaction))) setSelectedAction(curaction) //return } else { @@ -1779,6 +1780,7 @@ const AngularWorkflow = (props) => { curaction.selectedAuthentication = {} } + //setSelectedAction(JSON.parse(JSON.stringify(curaction))) setSelectedApp(curapp) setSelectedAction(curaction) @@ -3365,7 +3367,7 @@ const AngularWorkflow = (props) => { if (data.name !== "User Input" && data.name !== "Shuffle Workflow") { //workflow.branches.push(newbranch) - //cy.add(edgeToBeAdded) + cy.add(edgeToBeAdded) } setWorkflow(workflow) @@ -3865,7 +3867,7 @@ const AngularWorkflow = (props) => { } if (currentnode.data() === undefined) { - console.log("Node doesn't have any data (getParents)! Probably a trigger.") + //console.log("Node doesn't have any data (getParents)! Probably a trigger.") handled.push(allkeys[key]) results.push({"id": allkeys[key], "type": "TRIGGER"}) } else { @@ -5037,7 +5039,7 @@ const AngularWorkflow = (props) => { } - console.log("ACTIONS: ", actionlist) + //console.log("ACTIONS: ", actionlist) setActionlist(actionlist) } @@ -5260,6 +5262,7 @@ const AngularWorkflow = (props) => { workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "argument", "value": ""} workflow.triggers[selectedTriggerIndex].parameters[2] = {"name": "user_apikey", "value": ""} workflow.triggers[selectedTriggerIndex].parameters[3] = {"name": "startnode", "value": ""} + workflow.triggers[selectedTriggerIndex].parameters[4] = {"name": "check_result", "value": "true"} console.log("SETTINGS: ", userSettings) if (userSettings !== undefined && userSettings !== null && userSettings.apikey !== null && userSettings.apikey !== undefined && userSettings.apikey.length > 0) { @@ -5268,7 +5271,7 @@ const AngularWorkflow = (props) => { } return( -
+

{selectedTrigger.app_name}

@@ -5295,6 +5298,27 @@ const AngularWorkflow = (props) => { placeholder={selectedTrigger.label} onChange={selectedTriggerChange} /> + { + const newvalue = workflow.triggers[selectedTriggerIndex].parameters[4] === undefined || workflow.triggers[selectedTriggerIndex].parameters[4].value === "false" ? "true" : "false" + workflow.triggers[selectedTriggerIndex].parameters[4] = { + "name": "check_result", + "value": newvalue, + } + + setWorkflow(workflow) + setUpdate(Math.random()) + }} + color="primary" + value="Wait for results" + /> + } + style={{marginTop: 10}} + label={
Wait for results
} + />
@@ -5384,7 +5408,7 @@ const AngularWorkflow = (props) => { fullWidth onChange={(e) => { setSubworkflowStartnode(e.target.value) - console.log("WF: ", workflow) + //console.log("WF: ", workflow) const branchId = uuid.v4() const newbranch = { @@ -5418,15 +5442,17 @@ const AngularWorkflow = (props) => { } } - const cybranch = { - group: "edges", - source: newbranch.source_id, - target: newbranch.destination_id, - id: branchId, - data: newbranch, - } + if (workflow.id == subworkflow.id) { + const cybranch = { + group: "edges", + source: newbranch.source_id, + target: newbranch.destination_id, + id: branchId, + data: newbranch, + } - cy.add(cybranch) + cy.add(cybranch) + } try { workflow.triggers[selectedTriggerIndex].parameters[3].value = e.target.value.id @@ -7017,7 +7043,7 @@ const AngularWorkflow = (props) => { {executionData.status !== undefined && executionData.status.length > 0 ?
- Status   + Status    {executionData.status} @@ -7144,7 +7170,7 @@ const AngularWorkflow = (props) => { } return ( -
{ +
{ var currentnode = cy.getElementById(data.action.id) if (currentnode.length !== 0) { currentnode.addClass('shuffle-hover-highlight')