From 274ffce9fa059660e9398db13983140dc00fa664 Mon Sep 17 00:00:00 2001 From: frikky Date: Sat, 10 Oct 2020 06:14:38 +0200 Subject: [PATCH] #170: Fixed double for-loop issues. Now for anything >2 .. :) --- backend/app_sdk/app_base.py | 28 ++++++++++++++-------- frontend/src/views/AngularWorkflow.jsx | 32 ++++++++++++++++++-------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 30a0f9f2..97026b67 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -876,7 +876,6 @@ class AppBase: actionname = action["name"] #print("Multicheck ", actualitem) print("Actual item: %s" % actualitem) - print("LENGTH: %d" % len(actualitem)) if len(actualitem) > 0: multiexecution = True @@ -903,9 +902,12 @@ class AppBase: minlength = len(json_replacement) tmpitem = tmpitem.replace(actualitem[0][0], replacement, 1) - multi_execution_lists.append(tmpitem) params[parameter["name"]] = tmpitem - multi_parameters[parameter["name"]] = tmpitem + multi_execution_lists.append(json_replacement) + multi_parameters[parameter["name"]] = json_replacement + + #print("LENGTH OF ARR: %d" % len(resultarray)) + #print("RESULTARRAY: %s" % resultarray) print("MULTI finished: %s" % replacement) else: @@ -949,6 +951,11 @@ class AppBase: resultarray.append(tmpitem) # With this parameter ready, add it to... a greater list of parameters. Rofl + print("LENGTH OF ARR: %d" % len(resultarray)) + print("RESULTARRAY: %s" % resultarray) + if resultarray not in multi_execution_lists: + multi_execution_lists.append(resultarray) + multi_parameters[parameter["name"]] = resultarray else: # Parses things like int(value) @@ -961,7 +968,7 @@ class AppBase: # Fix lists here print("CHECKING multi execution list!") if len(multi_execution_lists) > 0: - print("Multi execution list has more data: %d" % len(multi_execution_lists)) + print("\n Multi execution list has more data: %d" % len(multi_execution_lists)) filteredlist = [] for listitem in multi_execution_lists: if listitem in filteredlist: @@ -971,14 +978,15 @@ class AppBase: #print("New list length: %d" % len(filteredlist)) if len(filteredlist) > 1: - print("Calculating new multi-loop length") + print("Calculating new multi-loop length with %d lists" % len(filteredlist)) tmplength = 1 for innerlist in filteredlist: + print("List length: %d. %d*%d" % (len(innerlist), len(innerlist), tmplength)) tmplength = len(innerlist)*tmplength minlength = tmplength - #print("New multi execution length: %d" % tmplength) + print("New multi execution length: %d\n" % tmplength) # FIXME - this is horrible, but works for now #for i in range(calltimes): @@ -1025,7 +1033,7 @@ class AppBase: newarray = [] print("VALUE: ", value) additiontime = minlength/len(value) - #print("Bad length for value: %d - should be %d. Additiontime: %d" % (len(value), minlength, additiontime)) + print("Bad length for value: %d - should be %d. Additiontime: %d" % (len(value), minlength, additiontime)) if firstlist: print("Running normal list (FIRST)") for subvalue in value: @@ -1052,7 +1060,7 @@ class AppBase: newarray[cnt] = value[subvaluerange] cnt += 1 - print("Newarray =", newarray) + #print("Newarray =", newarray) newvalue = newarray[i] firstlist = False @@ -1079,10 +1087,10 @@ class AppBase: #print("Json: %s" % e) results.append(ret) - print("Inner ret parsed: %s" % ret) + #print("Inner ret parsed: %s" % ret) # Dump the result as a string of a list - print("RESULTS: %s" % results) + #print("RESULTS: %s" % results) if isinstance(results, list): print("JSON OBJECT? ", json_object) if json_object: diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index be9cd8d2..d18044b9 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -2524,14 +2524,17 @@ const AngularWorkflow = (props) => { continue } - const foundResult = workflowExecutions[key].results.find(result => result.action.id === item.id) + var foundResult = workflowExecutions[key].results.find(result => result.action.id === item.id) if (foundResult === undefined) { continue } + foundResult.result = foundResult.result.trim() + foundResult.result = foundResult.result.split(" None").join(" \"None\"") + foundResult.result = foundResult.result.split("\'").join("\"") + var jsonvalid = true try { - console.log(foundResult.result) const tmp = String(JSON.parse(foundResult.result)) if (!tmp.includes("{") && !tmp.includes("[")) { jsonvalid = false @@ -2544,9 +2547,10 @@ const AngularWorkflow = (props) => { if (jsonvalid) { exampledata = JSON.parse(foundResult.result) break - } else { - console.log("Invalid JSON: ", foundResult.result) - } + } + //else { + // console.log("Invalid JSON: ", foundResult.result) + //} } } @@ -2610,10 +2614,14 @@ const AngularWorkflow = (props) => { if (curstring.length > 0) { // Search back in the action list curstring = curstring.split(" ").join("_").toLowerCase() - const actionItem = actionlist.find(data => data.autocomplete.split(" ").join("_").toLowerCase() === curstring) + var actionItem = actionlist.find(data => data.autocomplete.split(" ").join("_").toLowerCase() === curstring) if (actionItem !== undefined) { console.log("Found item: ", actionItem) + //actionItem.example = actionItem.example.trim() + //actionItem.example = actionItem.example.split(" None").join(" \"None\"") + //actionItem.example = actionItem.example.split("\'").join("\"") + var jsonvalid = true try { const tmp = String(JSON.parse(actionItem.example)) @@ -2977,7 +2985,6 @@ const AngularWorkflow = (props) => { selectedActionParameters[count].value += toComplete selectedAction.parameters[count].value = selectedActionParameters[count].value - console.log("TARGET: ", selectedActionParameters) setSelectedAction(selectedAction) setUpdate(Math.random()) @@ -5336,7 +5343,8 @@ const AngularWorkflow = (props) => { const parsedExecutionArgument = () => { var showResult = executionData.execution_argument.trim() - showResult.split(" None").join(" \"None\"") + showResult = showResult.split(" None").join(" \"None\"") + showResult = showResult.split("\'").join("\"") var jsonvalid = true try { @@ -5524,11 +5532,15 @@ const AngularWorkflow = (props) => { return null } - var showResult = data.result.trim() - showResult.split(" None").join(" \"None\"") // showResult = replaceAll(showResult, " None", " \"None\"") // Super basic check. + // + // FIXME: The latter replace doens't really work if ' is used in a string + var showResult = data.result.trim() + showResult = showResult.split(" None").join(" \"None\"") + showResult = showResult.split("\'").join("\"") + var jsonvalid = true try { const tmp = String(JSON.parse(showResult))