diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 9290353c..b4c0fe62 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -1461,7 +1461,12 @@ class AppBase: # FIXME: Only do this IF they want to loop new_replacement = [] for i in range(len(json_replacement)): - newvalue = tmpitem.replace(actualitem[0][0], json_replacement[i], 1) + if isinstance(json_replacement[i], dict) or isinstance(json_replacement[i], dict): + tmp_replacer = json.dumps(json_replacement[i]) + newvalue = tmpitem.replace(actualitem[0][0], tmp_replacer, 1) + else: + newvalue = tmpitem.replace(actualitem[0][0], json_replacement[i], 1) + try: newvalue = json.loads(newvalue) except json.decoder.JSONDecodeError as e: diff --git a/backend/app_sdk/build.sh b/backend/app_sdk/build.sh index 0651424c..5a24cba5 100644 --- a/backend/app_sdk/build.sh +++ b/backend/app_sdk/build.sh @@ -1,6 +1,6 @@ #!/bin/bash NAME=shuffle-app_sdk -VERSION=0.8.5 +VERSION=0.8.51 docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force docker build . -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION diff --git a/backend/go-app/main.go b/backend/go-app/main.go index c4863119..c3987846 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -7173,8 +7173,10 @@ func runInit(ctx context.Context) { } } } else { - if len(users) == 1 { - log.Printf("Found 1 user - %s.", users[0].Username) + if len(users) < 5 && len(users) > 0 { + for _, user := range users { + log.Printf("Username: %s, role: %s", user.Username, user.Role) + } } else { log.Printf("Found %d users.", len(users)) } diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 8c9cdf0d..cc4fb83e 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -1240,20 +1240,19 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl } extraInputs := 0 - for _, result := range workflowExecution.Results { - if result.Action.Name == "User Input" && result.Action.AppName == "User Input" { - log.Printf("Found User Input node - prepare cloud?") + for _, trigger := range workflowExecution.Workflow.Triggers { + if trigger.Name == "User Input" && trigger.AppName == "User Input" { extraInputs += 1 - } else if result.Action.Name == "run_subflow" && result.Action.AppName == "shuffle-subflow" { - log.Printf("[INFO] Found Shuffle Workflow node") + } else if trigger.Name == "Shuffle Workflow" && trigger.AppName == "Shuffle Workflow" { extraInputs += 1 } } - //log.Printf("LENGTH: %d - %d", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)) + //log.Printf("EXTRA: %d", extraInputs) + //log.Printf("LENGTH: %d - %d", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extraInputs) if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions)+extraInputs { - log.Printf("\nIN HERE WITH RESULTS %d vs %d\n", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extraInputs) + //log.Printf("\nIN HERE WITH RESULTS %d vs %d\n", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extraInputs) finished := true lastResult := "" @@ -1367,13 +1366,15 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl } } - if setExecution { + if setExecution || workflowExecution.Status == "FINISHED" || workflowExecution.Status == "ABORTED" || workflowExecution.Status == "FAILURE" { err = setWorkflowExecution(ctx, *workflowExecution, dbSave) if err != nil { resp.WriteHeader(401) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed setting workflowexecution actionresult: %s"}`, err))) return } + } else { + log.Printf("Skipping setexec with status %s", workflowExecution.Status) } //ExecutionId @@ -2070,7 +2071,17 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) { trigger.Status = "stopped" } } else if trigger.TriggerType == "SUBFLOW" { - //log.Printf("Found subflow: %#v", trigger.Parameters) + for _, param := range trigger.Parameters { + if len(param.Value) == 0 && param.Name != "argument" { + workflow.IsValid = false + workflow.Errors = []string{"Trigger is missing a parameter: %s", param.Name} + + log.Printf("No type specified for user input node") + resp.WriteHeader(401) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Trigger %s is missing the parameter %s"}`, trigger.Label, param.Name))) + return + } + } } else if trigger.TriggerType == "WEBHOOK" && trigger.Status != "uninitialized" { hook, err := getHook(ctx, trigger.ID) if err != nil { diff --git a/docker-compose.yml b/docker-compose.yml index b5f9e1f1..3f5674b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ version: '3' services: frontend: - #build: ./frontend - image: ghcr.io/frikky/shuffle-frontend:0.8.5 + build: ./frontend + image: ghcr.io/frikky/shuffle-frontend:0.8.51 container_name: shuffle-frontend hostname: shuffle-frontend ports: @@ -16,8 +16,8 @@ services: depends_on: - backend backend: - #build: ./backend - image: ghcr.io/frikky/shuffle-backend:0.8.5 + build: ./backend + image: ghcr.io/frikky/shuffle-backend:0.8.51 container_name: shuffle-backend hostname: ${BACKEND_HOSTNAME} # Here for debugging: @@ -53,8 +53,8 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - - SHUFFLE_APP_SDK_VERSION=0.8.5 - - SHUFFLE_WORKER_VERSION=0.8.5 + - SHUFFLE_APP_SDK_VERSION=0.8.51 + - SHUFFLE_WORKER_VERSION=0.8.51 - ORG_ID=${ORG_ID} - ENVIRONMENT_NAME=${ENVIRONMENT_NAME} - BASE_URL=http://${OUTER_HOSTNAME}:${BACKEND_PORT} diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index cad79b62..d9558537 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -252,16 +252,12 @@ const AngularWorkflow = (props) => { setWorkflows(responseJson) const trigger = workflow.triggers[trigger_index] - console.log("Trigger: ",trigger) if (trigger.parameters.length >= 3) { for (var key in trigger.parameters) { const param = trigger.parameters[key] - console.log(param) if (param.name === "workflow") { const sub = responseJson.find(data => data.id === param.value) - console.log("SUBFLOW: ", sub) - - if (subworkflow.id !== sub.id) { + if (sub !== undefined && subworkflow.id !== sub.id) { setSubworkflow(sub) } } @@ -321,7 +317,7 @@ const AngularWorkflow = (props) => { setUserSettings(responseJson) }) .catch(error => { - console.log(error) + console.log(error) }); } @@ -2260,6 +2256,8 @@ const AngularWorkflow = (props) => { return } + const triggerLabel = getNextActionName(data.name) + newNodeId = uuid.v4() const newposition = { "x": e.pageX-cycontainer.offsetLeft, @@ -2277,7 +2275,7 @@ const AngularWorkflow = (props) => { id_: newNodeId, _id_: newNodeId, id: newNodeId, - label: data.label, + label: triggerLabel, type: data.type, is_valid: true, trigger_type: data.trigger_type, @@ -2329,7 +2327,7 @@ const AngularWorkflow = (props) => { data: newcybranch, } - if (data.name !== "User Input") { + if (data.name !== "User Input" && data.name !== "Shuffle Workflow") { //workflow.branches.push(newbranch) cy.add(edgeToBeAdded) } @@ -2591,8 +2589,9 @@ const AngularWorkflow = (props) => { const getNextActionName = (appName) => { var highest = "" //label = name + _number - for (var key in workflow.actions) { - const item = workflow.actions[key] + const allitems = workflow.actions.concat(workflow.triggers) + for (var key in allitems) { + const item = allitems[key] if (item.app_name === appName) { var number = item.label.split("_") if (isNaN(number[-1]) && parseInt(number[number.length-1]) > highest) { @@ -5059,7 +5058,7 @@ const AngularWorkflow = (props) => {