From ab5b35532b75605b7972079a01297080c4a56811 Mon Sep 17 00:00:00 2001 From: frikky Date: Tue, 28 Jun 2022 18:14:02 +0200 Subject: [PATCH] Added minor fix to app generation --- backend/app_sdk/app_base.py | 26 ++++++- backend/app_sdk/build.sh | 2 +- backend/go-app/go.mod | 4 +- frontend/src/components/WorkflowPaper.jsx | 3 +- frontend/src/defaultCytoscapeStyle.js | 4 +- frontend/src/views/AngularWorkflow.jsx | 87 +++++++++++++++++------ frontend/src/views/AppCreator.jsx | 33 ++++++--- 7 files changed, 119 insertions(+), 40 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index ab3e88e5..354a6c55 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -2714,6 +2714,8 @@ class AppBase: if parameter["name"] == "body": bodyindex = counter #self.logger.info("PARAM: %s" % parameter) + + # FIXMe: This should also happen after liquid & param parsing.. try: values = parameter["value_replace"] if values != None: @@ -2721,16 +2723,24 @@ class AppBase: for val in values: replace_value = val["value"] replace_key = val["key"] + if (val["value"].startswith("{") and val["value"].endswith("}")) or (val["value"].startswith("[") and val["value"].endswith("]")): self.logger.info(f"""Trying to parse as JSON: {val["value"]}""") try: - value_replace = json.loads(val["value"]) - # If it gets here, remove the "" infront and behind the key as well since this is preventing the JSON from being loaded + newval = val["value"] + + # If it gets here, remove the "" infront and behind the key as well + # since this is preventing the JSON from being loaded + tmpvalue = json.loads(newval) replace_key = f"\"{replace_key}\"" except json.decoder.JSONDecodeError as e: - self.logger.info("Failed JSON replacement for OpenAPI %s", val["key"]) + self.logger.info("[WARNING] Failed JSON replacement for OpenAPI %s", val["key"]) + elif val["value"].lower() == "true" or val["value"].lower() == "false": replace_key = f"\"{replace_key}\"" + else: + if "\"" in replace_value and not "\\\"" in replace_value: + replace_value = replace_value.replace("\"", "\\\"", -1) action["parameters"][counter]["value"] = action["parameters"][counter]["value"].replace(replace_key, replace_value, 1) @@ -2787,6 +2797,9 @@ class AppBase: "exception": f"Value Error: {check}", })) + if parameter["name"] == "body": + self.logger.info("[INFO] Should debug field with liquid and other checks as it's BODY: %s" % value) + # Custom format for ${name[0,1,2,...]}$ #submatch = "([${]{2}([0-9a-zA-Z_-]+)(\[.*\])[}$]{2})" #self.logger.info(f"Returnedvalue: {value}") @@ -3126,6 +3139,13 @@ class AppBase: # FIXME: add this to Multi exec as well. try: for key, value in params.items(): + if "-" in key: + try: + newkey = key.replace("-", "_", -1).lower() + params[newkey] = params[key] + except Exception as e: + self.logger.info("[DEBUG] Failed updating key with dash in it: %s" % e) + try: if isinstance(value, str) and ((value.startswith("{") and value.endswith("}")) or (value.startswith("[") and value.endswith("]"))): params[key] = json.loads(value) diff --git a/backend/app_sdk/build.sh b/backend/app_sdk/build.sh index afa1987a..4c39c74a 100644 --- a/backend/app_sdk/build.sh +++ b/backend/app_sdk/build.sh @@ -2,7 +2,7 @@ ### DEFAULT NAME=shuffle-app_sdk -VERSION=1.0.2 +VERSION=1.0.4 docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION -t ghcr.io/frikky/$NAME:nightly diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 9eb2f94b..4b0b46c8 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -2,7 +2,7 @@ module main go 1.16 -//replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared +replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi //replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch @@ -24,7 +24,7 @@ require ( github.com/h2non/filetype v1.1.3 github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da // indirect github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.2.52 + github.com/shuffle/shuffle-shared v0.2.53 go4.org v0.0.0-20201209231011-d4a079459e60 // indirect golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce google.golang.org/api v0.65.0 diff --git a/frontend/src/components/WorkflowPaper.jsx b/frontend/src/components/WorkflowPaper.jsx index 21a9d7ea..f0a06e87 100644 --- a/frontend/src/components/WorkflowPaper.jsx +++ b/frontend/src/components/WorkflowPaper.jsx @@ -91,8 +91,7 @@ const WorkflowPaper = (props) => { } //console.log("IMG: ", data) - var parsedUrl = `workflows/${data.objectID}` - + var parsedUrl = `/workflows/${data.objectID}` if (data.__queryID !== undefined && data.__queryID !== null) { parsedUrl += `?queryID=${data.__queryID}` } diff --git a/frontend/src/defaultCytoscapeStyle.js b/frontend/src/defaultCytoscapeStyle.js index b95680a4..3871db40 100644 --- a/frontend/src/defaultCytoscapeStyle.js +++ b/frontend/src/defaultCytoscapeStyle.js @@ -163,8 +163,8 @@ const data = [ selector: "node[?isSuggestion]", css: { shape: "ellipse", - width: "30px", - height: "30px", + width: "50px", + height: "50px", "z-index": "5002", "font-size": "0px", border: "1px solid rgba(255,255,255,0.9)", diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 8bbb1aa1..962f3090 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -3752,6 +3752,7 @@ const AngularWorkflow = (defaultprops) => { ) { cy.getElementById(currentNode.data.id).remove(); } + } } @@ -3892,7 +3893,7 @@ const AngularWorkflow = (defaultprops) => { if (parentNode.data("isButton") || parentNode.data("buttonId")) return; const px = parentNode.position("x") + 300; - const py = parentNode.position("y") + 0; + const py = parentNode.position("y") + 100; const circleId = (newNodeId = uuidv4()); parentNode.data("circleId", circleId); @@ -3920,8 +3921,51 @@ const AngularWorkflow = (defaultprops) => { position: { x: px, y: py }, locked: true, }); + + //suggestions[0].id = uuidv4() + //cy.add({ + // group: "nodes", + // data: suggestions[0], + // position: { x: parentNode.position("x") + 300, y: parentNode.position("y") - 100}, + // locked: true, + //}); } + const addDeleteButton2 = (event) => { + var parentNode = cy.$("#" + event.target.data("id")); + if (parentNode.data("isButton") || parentNode.data("buttonId")) return; + + const px = parentNode.position("x") + 100; + const py = parentNode.position("y") + 35; + const circleId = (newNodeId = uuidv4()); + + parentNode.data("circleId", circleId); + + const iconInfo = { + icon: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", + iconColor: buttonColor, + iconBackgroundColor: buttonBackgroundColor, + }; + const svg_pin = ``; + const svgpin_Url = encodeURI("data:image/svg+xml;utf-8," + svg_pin); + + cy.add({ + group: "nodes", + data: { + weight: 30, + id: circleId, + name: "This is autocomplete", + buttonType: "delete", + attachedTo: event.target.data("id"), + icon: svgpin_Url, + iconBackground: iconInfo.iconBackgroundColor, + is_valid: true, + }, + position: { x: px, y: py }, + locked: true, + }); + }; + const addDeleteButton = (event) => { var parentNode = cy.$("#" + event.target.data("id")); if (parentNode.data("isButton") || parentNode.data("buttonId")) return; @@ -3981,12 +4025,19 @@ const AngularWorkflow = (defaultprops) => { for (var key in allNodes) { const currentNode = allNodes[key]; if ( - currentNode.data.isButton && + (currentNode.data.isButton || currentNode.data.isSuggestion) && currentNode.data.attachedTo !== nodedata.id ) { cy.getElementById(currentNode.data.id).remove(); } + /*if ( + currentNode.data.isSuggestion && + currentNode.data.attachedTo !== nodedata.id + ) { + cy.getElementById(currentNode.data.id).remove(); + }*/ + if ( currentNode.data.isButton && currentNode.data.attachedTo === nodedata.id @@ -4007,7 +4058,10 @@ const AngularWorkflow = (defaultprops) => { addStartnodeButton(event); } - //addSuggestionButtons(event) + // autocomplete + // right click + // suggestions + //addSuggestionButtons(event); } } @@ -5037,7 +5091,7 @@ const AngularWorkflow = (defaultprops) => { var thisview = ( @@ -5825,15 +5879,10 @@ const AngularWorkflow = (defaultprops) => { if (value.length > 0) { var newApps = allApps.filter( (app) => - app.name - .toLowerCase() - .includes( - value.trim().toLowerCase() || - app.description - .toLowerCase() - .includes(value.trim().toLowerCase()) - ) && !(!app.activated && app.generated) - ); + app.name.toLowerCase().includes(value.trim().toLowerCase()) + || + app.description.toLowerCase().includes(value.trim().toLowerCase()) + ) // Extend search if (newApps.length === 0) { @@ -6914,7 +6963,7 @@ const AngularWorkflow = (defaultprops) => { > contains any of - { conditionValue.value = "matches regex"; @@ -6924,7 +6973,7 @@ const AngularWorkflow = (defaultprops) => { key={"matches regex"} > matches regex - + */} { @@ -10665,11 +10714,7 @@ const AngularWorkflow = (defaultprops) => { }; const BottomCytoscapeBar = () => { - if ( - workflow.id === undefined || - workflow.id === null || - apps.length === 0 - ) { + if (workflow.id === undefined || workflow.id === null || (!workflow.public && apps.length === 0)) { return null; } @@ -11333,7 +11378,7 @@ const AngularWorkflow = (defaultprops) => { : null} - {userdata.avatar === creatorProfile.github_avatar ? + {userdata.avatar === creatorProfile.github_avatar && userdata.avatar !== undefined ?