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