Fixed small frontend issues in workflow and app creator
This commit is contained in:
@@ -3188,13 +3188,15 @@ class AppBase:
|
||||
try:
|
||||
result += json.dumps(newres, indent=4)
|
||||
except json.JSONDecodeError as e:
|
||||
self.logger.info("Failed decoding result: %s" % e)
|
||||
|
||||
self.logger.info("[WARNING] Failed decoding result: %s" % e)
|
||||
try:
|
||||
result += str(newres)
|
||||
except ValueError:
|
||||
result += "Failed autocasting. Can't handle %s type from function. Must be string" % type(newres)
|
||||
self.logger.info("Can't handle type %s value from function" % (type(newres)))
|
||||
except Exception as e:
|
||||
self.logger.info("[ERROR] Failed to json dump. Returning as string.")
|
||||
result += str(newres)
|
||||
else:
|
||||
try:
|
||||
result += str(newres)
|
||||
@@ -3299,7 +3301,7 @@ class AppBase:
|
||||
|
||||
self.action_result["result"] = json.dumps({
|
||||
"success": False,
|
||||
"reason": f"General exception",
|
||||
"reason": f"General exception in the app. See shuffle action logs for more details.",
|
||||
"details": e,
|
||||
})
|
||||
|
||||
|
||||
@@ -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.15
|
||||
github.com/shuffle/shuffle-shared v0.2.17
|
||||
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
|
||||
google.golang.org/api v0.65.0
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
frontend:
|
||||
#build: ./frontend
|
||||
build: ./frontend
|
||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||
container_name: shuffle-frontend
|
||||
hostname: shuffle-frontend
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
#build: ./backend
|
||||
build: ./backend
|
||||
image: ghcr.io/frikky/shuffle-backend:nightly
|
||||
container_name: shuffle-backend
|
||||
hostname: ${BACKEND_HOSTNAME}
|
||||
|
||||
@@ -489,7 +489,6 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
|
||||
var exampledata = item.example === undefined || item.example === null ? "" : item.example;
|
||||
console.log("EXAMPLE: ", exampledata)
|
||||
// Find previous execution and their variables
|
||||
//exampledata === "" &&
|
||||
if (workflowExecutions.length > 0) {
|
||||
@@ -513,7 +512,6 @@ const ParsedAction = (props) => {
|
||||
if (foundResult.result !== undefined && foundResult.result !== null) {
|
||||
foundResult = foundResult.result
|
||||
}
|
||||
console.log("VALID RESULT: ", foundResult)
|
||||
|
||||
const valid = validateJson(foundResult)
|
||||
if (valid.valid) {
|
||||
@@ -2249,7 +2247,8 @@ const ParsedAction = (props) => {
|
||||
// const classes = useStyles()
|
||||
// return <Popper {...props} className={classes.root} placement="bottom" />
|
||||
//}
|
||||
|
||||
//console.log("env: ", selectedActionEnvironment)
|
||||
|
||||
const baselabel = selectedAction.label;
|
||||
return (
|
||||
<div style={appApiViewStyle} id="parsed_action_view">
|
||||
|
||||
@@ -1100,6 +1100,17 @@ const AngularWorkflow = (defaultprops) => {
|
||||
|
||||
if (curworkflowComment === undefined) {
|
||||
curworkflowComment = cyelements[key].data();
|
||||
try {
|
||||
curworkflowComment.position.x = parseInt(curworkflowComment.position.x)
|
||||
} catch (e) {
|
||||
console.log("Failed to parse position Y of comment: ", curworkflowComment.position.x)
|
||||
}
|
||||
|
||||
try {
|
||||
curworkflowComment.position.y = parseInt(curworkflowComment.position.y)
|
||||
} catch (e) {
|
||||
console.log("Failed to parse position Y of comment: ", curworkflowComment.position.y)
|
||||
}
|
||||
}
|
||||
|
||||
const parsedHeight = parseInt(curworkflowComment["height"])
|
||||
@@ -10909,7 +10920,6 @@ const AngularWorkflow = (defaultprops) => {
|
||||
|
||||
const drawerBleeding = 56;
|
||||
if (defaultReturn === undefined || defaultReturn === null) {
|
||||
console.log("DEFAULT RETURN: ", defaultReturn)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -12410,7 +12420,6 @@ const parsedExecutionArgument = () => {
|
||||
? ""
|
||||
: validateJson(selectedResult.result.trim());
|
||||
|
||||
console.log("RESULT: ", validate.result)
|
||||
if (validate.valid && typeof validate.result === "string") {
|
||||
validate.result = JSON.parse(validate.result);
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ const AppCreator = (defaultprops) => {
|
||||
}
|
||||
|
||||
setBasedata(data);
|
||||
console.log("DATA: ", data)
|
||||
console.log("Info: ", data)
|
||||
if (data.info !== null && data.info !== undefined) {
|
||||
if (data.info.title !== undefined && data.info.title !== null) {
|
||||
if (data.info.title.length > 29) {
|
||||
@@ -571,6 +571,7 @@ const AppCreator = (defaultprops) => {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Tags: ", data.tags)
|
||||
if (data.tags !== undefined && data.tags.length > 0) {
|
||||
var newtags = [];
|
||||
for (var key in data.tags) {
|
||||
@@ -616,6 +617,7 @@ const AppCreator = (defaultprops) => {
|
||||
var newActions = [];
|
||||
var wordlist = {};
|
||||
var all_categories = [];
|
||||
console.log("Paths: ", data.paths)
|
||||
if (data.paths !== null && data.paths !== undefined) {
|
||||
for (let [path, pathvalue] of Object.entries(data.paths)) {
|
||||
for (let [method, methodvalue] of Object.entries(pathvalue)) {
|
||||
@@ -711,23 +713,13 @@ const AppCreator = (defaultprops) => {
|
||||
//newaction["headers"] = ""
|
||||
//"Content-Type=application/json\nAccept=application/json";
|
||||
if (
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
] !== undefined &&
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
] !== null
|
||||
methodvalue["requestBody"]["content"]["application/json"]["schema"] !== undefined && methodvalue["requestBody"]["content"]["application/json"]["schema"] !== null
|
||||
) {
|
||||
if (
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
]["properties"] !== undefined
|
||||
) {
|
||||
console.log("Schema: ", methodvalue["requestBody"]["content"]["application/json"]["schema"])
|
||||
if (methodvalue["requestBody"]["content"]["application/json"]["schema"]["properties"] !== undefined) {
|
||||
var tmpobject = {};
|
||||
for (let [prop, propvalue] of Object.entries(
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
]["properties"]
|
||||
methodvalue["requestBody"]["content"]["application/json"]["schema"]["properties"]
|
||||
)) {
|
||||
tmpobject[prop] = `\$\{${prop}\}`;
|
||||
}
|
||||
@@ -745,13 +737,7 @@ const AppCreator = (defaultprops) => {
|
||||
|
||||
newaction["body"] = JSON.stringify(tmpobject, null, 2);
|
||||
} else if (
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
]["$ref"] !== undefined &&
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
]["$ref"] !== null
|
||||
) {
|
||||
methodvalue["requestBody"]["content"]["application/json"]["schema"]["$ref"] !== undefined && methodvalue["requestBody"]["content"]["application/json"]["schema"]["$ref"] !== null) {
|
||||
const retRef = handleGetRef(
|
||||
methodvalue["requestBody"]["content"]["application/json"][
|
||||
"schema"
|
||||
@@ -879,11 +865,11 @@ const AppCreator = (defaultprops) => {
|
||||
if (content !== undefined && content !== null) {
|
||||
//console.log("CONTENT: ", content)
|
||||
for (const [subkey, subvalue] of Object.entries(content)) {
|
||||
if (subvalue["schema"] !== undefined) {
|
||||
//console.log("SCHEMA: ", subvalue["schema"])
|
||||
if (subvalue["schema"]["$ref"] !== undefined) {
|
||||
//console.log("SCHEMA FOUND REF!")
|
||||
if (subvalue["schema"] !== undefined && subvalue["schema"] !== null) {
|
||||
console.log("SCHEMA: ", subvalue["schema"])
|
||||
if (subvalue["schema"]["$ref"] !== undefined && subvalue["schema"]["$ref"] !== null) {
|
||||
|
||||
console.log("SCHEMA FOUND REF!")
|
||||
if (!schemas.includes(subvalue["schema"]["$ref"])) {
|
||||
schemas.push(subvalue["schema"]["$ref"]);
|
||||
}
|
||||
@@ -1016,18 +1002,11 @@ const AppCreator = (defaultprops) => {
|
||||
selectedExample["content"]["application/json"] !== undefined
|
||||
) {
|
||||
if (
|
||||
selectedExample["content"]["application/json"][
|
||||
"schema"
|
||||
] !== undefined &&
|
||||
selectedExample["content"]["application/json"][
|
||||
"schema"
|
||||
] !== null
|
||||
selectedExample["content"]["application/json"]["schema"] !== undefined &&
|
||||
selectedExample["content"]["application/json"]["schema"] !== null
|
||||
) {
|
||||
if (
|
||||
selectedExample["content"]["application/json"][
|
||||
"schema"
|
||||
]["$ref"] !== undefined
|
||||
) {
|
||||
console.log("JSON: ", selectedExample["content"]["application/json"]["schema"])
|
||||
if (selectedExample["content"]["application/json"]["schema"]["$ref"] !== undefined) {
|
||||
//console.log("REF EXAMPLE: ", selectedExample["content"]["application/json"]["schema"])
|
||||
const parameter = handleGetRef(
|
||||
selectedExample["content"]["application/json"][
|
||||
|
||||
@@ -394,7 +394,6 @@ const chipStyle = {
|
||||
};
|
||||
|
||||
export const validateJson = (showResult) => {
|
||||
console.log("INPUT: ", showResult, typeof showResult)
|
||||
if (typeof showResult === 'string') {
|
||||
showResult = showResult.split(" False").join(" false")
|
||||
showResult = showResult.split(" True").join(" true")
|
||||
@@ -1976,7 +1975,9 @@ const Workflows = (props) => {
|
||||
//workflows[0].usecase_ids = ["Correlate tickets"]
|
||||
}
|
||||
|
||||
return fetch(globalUrl + "/api/v1/workflows" + extraData, {
|
||||
const new_url = `${globalUrl}/api/v1/workflows${extraData}`
|
||||
console.log("Got new url: ", new_url)
|
||||
return fetch(new_url, {
|
||||
method: method,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -2012,7 +2013,7 @@ const Workflows = (props) => {
|
||||
// Update :)
|
||||
setTimeout(() => {
|
||||
getAvailableWorkflows();
|
||||
}, 1000);
|
||||
}, 2500);
|
||||
setImportLoading(false);
|
||||
setModalOpen(false);
|
||||
} else {
|
||||
@@ -2035,6 +2036,7 @@ const Workflows = (props) => {
|
||||
|
||||
setImportLoading(true);
|
||||
if (event.target.files.length > 0) {
|
||||
console.log("Files: !", event.target.files.length);
|
||||
for (var key in event.target.files) {
|
||||
const file = event.target.files[key];
|
||||
if (file.type !== "application/json") {
|
||||
@@ -2057,6 +2059,8 @@ const Workflows = (props) => {
|
||||
setImportLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("File being loaded: ", data.name);
|
||||
|
||||
// Initialize the workflow itself
|
||||
setNewWorkflow(
|
||||
|
||||
Reference in New Issue
Block a user