From e7541320a14cc8c354e0fbdf6e0501bea3dbec46 Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 18 Feb 2021 17:20:51 +0100 Subject: [PATCH] #256: Added category dropdown to app editor --- backend/app_sdk/app_base.py | 30 +++++---- backend/go-app/main.go | 8 +-- backend/go-app/walkoff.go | 7 +-- frontend/src/views/AngularWorkflow.jsx | 29 +++++---- frontend/src/views/AppCreator.jsx | 84 +++++++++++++++++++------- 5 files changed, 102 insertions(+), 56 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 25d63d80..47bb2aa5 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -541,9 +541,11 @@ class AppBase: print(action["parameters"]) except KeyError: action["parameters"] = [] + except TypeError: + pass self.action = copy.deepcopy(action) - self.logger.info("ACTION RESULT (start): %s", action_result) + self.logger.info("Sending starting action result (EXECUTING)") headers = { "Content-Type": "application/json", @@ -1473,10 +1475,10 @@ class AppBase: except KeyError: pass - print("Return value: %s" % value) + #print("Return value: %s" % value) actionname = action["name"] #print("Multicheck ", actualitem) - print("ITEM LENGTH: %d, Actual item: %s" % (len(actualitem), actualitem)) + #print("ITEM LENGTH: %d, Actual item: %s" % (len(actualitem), actualitem)) if len(actualitem) > 0: multiexecution = True @@ -1636,14 +1638,14 @@ class AppBase: # With this parameter ready, add it to... a greater list of parameters. Rofl print("LENGTH OF ARR: %d" % len(resultarray)) - print("RESULTARRAY: %s" % 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) - print("Normal parsing (not looping) with data %s" % value) + print("Normal parsing (not looping)")#with data %s" % value) value = parse_wrapper_start(value) if parameter["id"] == "body_replacement": @@ -1663,7 +1665,7 @@ class AppBase: # print("PARAM: %s" % parameter) #if param.id == "body_replacement": - print("POST data value: %s" % value) + #print("POST data value: %s" % value) params[parameter["name"]] = value multi_parameters[parameter["name"]] = value @@ -1719,9 +1721,9 @@ class AppBase: #}) #print("[INFO] APP_SDK DONE: Starting NORMAL execution of function") - #print("[INFO] Running with params (0): %s" % params) + print("[INFO] Running execition\n") newres = await func(**params) - print("[INFO] Returned from execution:", newres) + print("\n[INFO] Returned from execution:", newres) if isinstance(newres, tuple): print("[INFO] Handling return as tuple") # Handles files. @@ -1940,16 +1942,16 @@ class AppBase: logger = logging.getLogger(f"{cls.__name__}") logger.setLevel(logging.DEBUG) - print("Started execution: %s!!" % cls) - print("Action: %s" % action) + #print("Started execution: %s!!" % cls) + #print("Action: %s" % action) #if isinstance(cls, object): # self.action = cls - # Authorization for the app/function to control the workflow - # Function will crash if its wrong, which it probably should. app = cls(redis=None, logger=logger, console_logger=logger) - if isinstance(action, object): + if isinstance(action, str): + print("Normal execution. Action is a string.") + elif isinstance(action, object): app.action = action try: @@ -1967,5 +1969,7 @@ class AppBase: app.base_url = action["base_url"] except: pass + else: + print("ACTION TYPE (unhandled): %s" % type(action)) await app.execute_action(app.action) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 349cf5b5..c27de623 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -6615,7 +6615,7 @@ func healthCheckHandler(resp http.ResponseWriter, request *http.Request) { // Creates osfs from folderpath with a basepath as directory base func createFs(basepath, pathname string) (billy.Filesystem, error) { - log.Printf("base: %s, pathname: %s", basepath, pathname) + log.Printf("[INFO] MemFS base: %s, pathname: %s", basepath, pathname) fs := memfs.New() err := filepath.Walk(pathname, @@ -6676,19 +6676,19 @@ func handleAppHotload(location string, forceUpdate bool) error { log.Printf("Failed memfs creation - probably bad path: %s", err) return errors.New(fmt.Sprintf("Failed to find directory %s", location)) } else { - log.Printf("Memfs creation from %s done", location) + log.Printf("[INFO] Memfs creation from %s done", location) } dir, err := fs.ReadDir("") if err != nil { - log.Printf("Failed reading folder: %s", err) + log.Printf("[WARNING] Failed reading folder: %s", err) return err } //log.Printf("Reading app folder: %#v", dir) _, _, err = iterateAppGithubFolders(fs, dir, "", "", forceUpdate) if err != nil { - log.Printf("Err: %s", err) + log.Printf("[WARNING] Githubfolders error: %s", err) return err } diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 80e39e0c..5a241064 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -820,7 +820,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { if len(executionRequests.Data) == 0 { executionRequests.Data = []ExecutionRequest{} } else { - log.Printf("[INFO] Executionrequests: %d", len(executionRequests.Data)) + log.Printf("[INFO] Executionrequests (%s): %d", id, len(executionRequests.Data)) } newjson, err := json.Marshal(executionRequests) @@ -3135,7 +3135,6 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf // This one doesn't really matter. log.Printf("[INFO] Running POST execution with body of length %d", len(string(body))) - a if body[0] == 34 && body[len(body)-1] == 34 { body = body[1 : len(body)-1] } @@ -5958,7 +5957,7 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) { return } - log.Printf("Starting app hotloading") + log.Printf("[INFO] Starting app hotloading") // Just need to be logged in // FIXME - should have some permissions? @@ -5983,7 +5982,7 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) { return } - log.Printf("Hotloading from %s", location) + log.Printf("[INFO] Hotloading from %s", location) err = handleAppHotload(location, true) if err != nil { log.Printf("Failed app hotload: %s", err) diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 861c37f1..4ba479b4 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -137,6 +137,7 @@ const AngularWorkflow = (props) => { const [workflow, setWorkflow] = React.useState({}); const [userSettings, setUserSettings] = React.useState({}); const [subworkflow, setSubworkflow] = React.useState({}); + const [subworkflowStartnode, setSubworkflowStartnode] = React.useState(""); const [leftViewOpen, setLeftViewOpen] = React.useState(true); const [leftBarSize, setLeftBarSize] = React.useState(350) const [executionText, setExecutionText] = React.useState(""); @@ -783,8 +784,8 @@ const AngularWorkflow = (props) => { //alert.success("Successfully saved workflow") setSavingState(1) setTimeout(() => { - setSavingState(0) - }, 3000); + setSavingState(0) + }, 2000); } }) .catch(error => { @@ -830,9 +831,9 @@ const AngularWorkflow = (props) => { } if (executionArgument.length > 0) { - alert.success("Starting execution WITH an execution argument") + //alert.success("Starting execution WITH an execution argument") } else { - alert.success("Starting execution") + //alert.success("Starting execution") } const data = {"execution_argument": executionArgument, "start": startNode} @@ -5154,6 +5155,7 @@ const AngularWorkflow = (props) => { setUpdate(Math.random()) workflow.triggers[selectedTriggerIndex].parameters[0].value = e.target.value.id setWorkflow(workflow) + setSubworkflowStartnode(e.target.value.start) }} style={{backgroundColor: inputColor, color: "white", height: "50px"}} > @@ -5170,9 +5172,9 @@ const AngularWorkflow = (props) => { })} } - {/*subworkflow === undefined || subworkflow === null || subworkflow.id === undefined ? null : + {/*subworkflow === undefined || subworkflow === null || subworkflow.id === undefined || subworkflow.actions === null || subworkflow.actions === undefined || subworkflow.actions.length === 0 ? null : { + setNewWorkflowCategories([e.target.value]) + setUpdate("added "+e.target.value) + }} + value={newWorkflowCategories.length === 0 ? "Select a category" : newWorkflowCategories[0]} + style={{backgroundColor: inputColor, color: "white", height: "50px"}} + > + {categories.map(data => ( + + {data} + + ))} + +

Tags

+ { + newWorkflowTags.push(chip) + setNewWorkflowTags(newWorkflowTags) + setUpdate("added"+chip) + }} + onDelete={(chip, index) => { + newWorkflowTags.splice(index, 1) + setNewWorkflowTags(newWorkflowTags) + setUpdate("delete "+chip) + }} + /> const actionView =