Fixed minor bugs in app creator bodies and action names + added auto addition of headers

This commit is contained in:
frikky
2022-07-14 01:16:27 +02:00
parent 76bfff84da
commit 16e7bfcb58
11 changed files with 340 additions and 269 deletions
+115 -107
View File
@@ -1120,6 +1120,9 @@ const AngularWorkflow = (defaultprops) => {
}
curworkflowTrigger.position = cyelements[key].position();
if (curworkflowTrigger.canConnect === false) {
continue
}
newTriggers.push(curworkflowTrigger);
} else if (type === "COMMENT") {
@@ -11433,114 +11436,114 @@ const AngularWorkflow = (defaultprops) => {
<HandleLeftView />
</div>
) : (
<div
style={{
minWidth: leftBarSize,
maxWidth: leftBarSize,
borderRight: "1px solid rgb(91, 96, 100)",
}}
>
<div
style={{ cursor: "pointer", height: 20, marginTop: 10, marginLeft: 10 }}
onClick={() => {
setLeftViewOpen(true);
setLeftBarSize(350);
}}
>
<Tooltip color="primary" title="Maximize" placement="top">
<KeyboardArrowRightIcon />
</Tooltip>
</div>
</div>
);
const executionPaperStyle = {
minWidth: "95%",
maxWidth: "95%",
marginTop: "5px",
color: "white",
marginBottom: 10,
padding: 5,
backgroundColor: surfaceColor,
cursor: "pointer",
display: "flex",
minHeight: 40,
maxHeight: 40,
};
const parsedExecutionArgument = () => {
var showResult = executionData.execution_argument.trim();
const validate = validateJson(showResult);
if (validate.valid) {
if (typeof validate.result === "string") {
try {
validate.result = JSON.parse(validate.result);
} catch (e) {
console.log("Error: ", e);
validate.valid = false;
}
}
return (
<div style={{display: "flex"}}>
<IconButton
style={{
marginTop: "auto",
marginBottom: "auto",
height: 30,
paddingLeft: 0,
width: 30,
}}
onClick={() => {
setSelectedResult({
"action": {
"label": "Execution Argument",
"name": "Execution Argument",
"large_image": theme.palette.defaultImage,
"image": theme.palette.defaultImage,
},
"result": validate.valid ? JSON.stringify(validate.result) : validate.result,
"status": "SUCCESS"
})
setCodeModalOpen(true);
}}
>
<Tooltip
color="primary"
title="Expand result window"
placement="top"
style={{ zIndex: 10011 }}
>
<ArrowLeftIcon style={{ color: "white" }} />
</Tooltip>
</IconButton>
<ReactJson
src={validate.result}
theme={theme.palette.jsonTheme}
style={theme.palette.reactJsonStyle}
collapsed={true}
enableClipboard={(copy) => {
handleReactJsonClipboard(copy);
}}
displayDataTypes={false}
onSelect={(select) => {
HandleJsonCopy(validate.result, select, "exec");
}}
name={"Execution Argument"}
/>
<div
style={{
minWidth: leftBarSize,
maxWidth: leftBarSize,
borderRight: "1px solid rgb(91, 96, 100)",
}}
>
<div
style={{ cursor: "pointer", height: 20, marginTop: 10, marginLeft: 10 }}
onClick={() => {
setLeftViewOpen(true);
setLeftBarSize(350);
}}
>
<Tooltip color="primary" title="Maximize" placement="top">
<KeyboardArrowRightIcon />
</Tooltip>
</div>
)
}
</div>
);
return (
<div>
<h3>Execution Argument</h3>
<div style={{ maxHeight: 200, overflowY: "auto" }}>
{executionData.execution_argument}
</div>
</div>
);
const executionPaperStyle = {
minWidth: "95%",
maxWidth: "95%",
marginTop: "5px",
color: "white",
marginBottom: 10,
padding: 5,
backgroundColor: surfaceColor,
cursor: "pointer",
display: "flex",
minHeight: 40,
maxHeight: 40,
};
const parsedExecutionArgument = () => {
var showResult = executionData.execution_argument.trim();
const validate = validateJson(showResult);
if (validate.valid) {
if (typeof validate.result === "string") {
try {
validate.result = JSON.parse(validate.result);
} catch (e) {
console.log("Error: ", e);
validate.valid = false;
}
}
return (
<div style={{display: "flex"}}>
<IconButton
style={{
marginTop: "auto",
marginBottom: "auto",
height: 30,
paddingLeft: 0,
width: 30,
}}
onClick={() => {
setSelectedResult({
"action": {
"label": "Execution Argument",
"name": "Execution Argument",
"large_image": theme.palette.defaultImage,
"image": theme.palette.defaultImage,
},
"result": validate.valid ? JSON.stringify(validate.result) : validate.result,
"status": "SUCCESS"
})
setCodeModalOpen(true);
}}
>
<Tooltip
color="primary"
title="Expand result window"
placement="top"
style={{ zIndex: 10011 }}
>
<ArrowLeftIcon style={{ color: "white" }} />
</Tooltip>
</IconButton>
<ReactJson
src={validate.result}
theme={theme.palette.jsonTheme}
style={theme.palette.reactJsonStyle}
collapsed={true}
enableClipboard={(copy) => {
handleReactJsonClipboard(copy);
}}
displayDataTypes={false}
onSelect={(select) => {
HandleJsonCopy(validate.result, select, "exec");
}}
name={"Execution Argument"}
/>
</div>
)
}
return (
<div>
<h3>Execution Argument</h3>
<div style={{ maxHeight: 200, overflowY: "auto" }}>
{executionData.execution_argument}
</div>
</div>
);
};
const getExecutionSourceImage = (execution) => {
@@ -12175,7 +12178,12 @@ const parsedExecutionArgument = () => {
executionData.execution_argument,
executionData.start,
lastSaved
);
)
if (executionText === undefined || executionText === null || executionText.length === 0) {
setExecutionText(executionData.execution_argument)
}
setExecutionModalOpen(false);
}}
>
+70 -60
View File
@@ -1814,6 +1814,10 @@ const AppCreator = (defaultprops) => {
for (var querykey in item.queries) {
const queryitem = item.queries[querykey];
if (queryitem === undefined || queryitem === null || queryitem.name === undefined || queryitem.name === null) {
continue
}
// A fix for duplicate items
if (querynames.includes(queryitem.name.toLowerCase())) {
continue
@@ -1967,70 +1971,76 @@ const AppCreator = (defaultprops) => {
}
}
if (
item.body !== undefined &&
item.body !== null &&
item.body.length > 0
) {
const required = false;
newitem = {
in: "body",
name: "body",
multiline: true,
description: "Generated by shuffler.io OpenAPI",
required: required,
example: item.body,
schema: {
type: "string",
},
};
const methodname = item.method.toLowerCase()
if (methodname === "post" || methodname === "put" || methodname === "patch") {
if (
item.body !== undefined &&
item.body !== null &&
item.body.length > 0
) {
console.log("GOT BODY: ", item.url, item.method)
//var pathjoin = item.url+"_"+item.method.toLowerCase()
// FIXME - add application/json if JSON example?
data.paths[item.url][item.method.toLowerCase()]["requestBody"] = {
description: "Generated by Shuffler.io",
required: required,
content: {
example: {
example: item.body,
},
},
};
const required = false;
newitem = {
in: "body",
name: "body",
multiline: true,
description: "Generated by shuffler.io OpenAPI",
required: required,
example: item.body,
schema: {
type: "string",
},
};
data.paths[item.url][item.method.toLowerCase()].parameters.push(
newitem
);
} else if (actionBodyRequest.includes(item.method.toUpperCase())) {
// Appending an empty field
const required = false;
newitem = {
in: "body",
name: "body",
multiline: true,
description: "Generated by shuffler.io OpenAPI",
required: required,
example: "",
schema: {
type: "string",
},
};
// FIXME - add application/json if JSON example?
data.paths[item.url][item.method.toLowerCase()]["requestBody"] = {
description: "Generated by Shuffler.io",
required: required,
content: {
example: {
example: item.body,
},
},
};
// FIXME - add application/json if JSON example?
data.paths[item.url][item.method.toLowerCase()]["requestBody"] = {
description: "Generated by Shuffler.io",
required: required,
content: {
example: {
example: "",
},
},
};
data.paths[item.url][item.method.toLowerCase()].parameters.push(
newitem
);
} else if (actionBodyRequest.includes(item.method.toUpperCase())) {
// Appending an empty field
const required = false;
newitem = {
in: "body",
name: "body",
multiline: true,
description: "Generated by shuffler.io OpenAPI",
required: required,
example: "",
schema: {
type: "string",
},
};
data.paths[item.url][item.method.toLowerCase()].parameters.push(
newitem
);
} else {
//console.log("Nothing to append?")
}
// FIXME - add application/json if JSON example?
data.paths[item.url][item.method.toLowerCase()]["requestBody"] = {
description: "Generated by Shuffler.io",
required: required,
content: {
example: {
example: "",
},
},
};
data.paths[item.url][item.method.toLowerCase()].parameters.push(
newitem
);
} else {
//console.log("Nothing to append?")
}
}
// https://swagger.io/docs/specification/describing-request-body/file-upload/
if (
+18 -9
View File
@@ -8,7 +8,6 @@ import SecurityFramework from '../components/SecurityFramework.jsx';
import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
import { isMobile } from "react-device-detect"
import {
Badge,
Avatar,
@@ -88,6 +87,7 @@ import { useAlert } from "react-alert";
import ChipInput from "material-ui-chip-input";
import { v4 as uuidv4 } from "uuid";
const inputColor = "#383B40";
const surfaceColor = "#27292D";
const svgSize = 24;
@@ -133,8 +133,8 @@ export const GetIconInfo = (action) => {
const iconList = [
{ key: "cache_add", values: ["set_cache"] },
{ key: "cache_get", values: ["get_cache"] },
{ key: "filter", values: ["filter", "route", "router"] },
{ key: "merge", values: ["join", "merge"] },
{ key: "filter", values: ["filter"] },
{ key: "merge", values: ["join", "merge", "route", "router"] },
{
key: "search",
values: ["search", "find", "locate", "index", "analyze", "anal", "match", "check cache", "check", "verify", "validate"],
@@ -412,6 +412,7 @@ export const validateJson = (showResult) => {
jsonvalid = false
}
} catch (e) {
console.log("Bug1: ", e)
showResult = showResult.split("'").join('"');
try {
@@ -419,14 +420,17 @@ export const validateJson = (showResult) => {
jsonvalid = false;
}
} catch (e) {
console.log("Bug2: ", e)
jsonvalid = false;
}
}
var result = showResult;
try {
result = jsonvalid ? JSON.parse(showResult) : showResult;
result = jsonvalid ? JSON.parse(showResult, {"storeAsString": true}) : showResult;
} catch (e) {
console.log("Bug3: ", e)
////console.log("Failed parsing JSON even though its valid: ", e)
jsonvalid = false;
}
@@ -444,6 +448,7 @@ export const validateJson = (showResult) => {
result = JSON.parse(newstr)
jsonvalid = true
} catch (e) {
console.log("Bug4: ", e)
//console.log("Failed parsing JSON even though its valid (2): ", e)
jsonvalid = false
@@ -477,7 +482,6 @@ export const validateJson = (showResult) => {
}
}
//console.log("VALID: ", jsonvalid, result, typeof result)
return {
valid: jsonvalid,
result: result,
@@ -1116,10 +1120,15 @@ const Workflows = (props) => {
justifyContent: "space-between",
};
const exportAllWorkflows = () => {
for (var key in workflows) {
exportWorkflow(workflows[key], false);
const exportAllWorkflows = (allWorkflows) => {
for (var i = 0; i < allWorkflows.length; i++) {
setTimeout(() => {
console.log(workflows[i].name)
exportWorkflow(workflows[i], false)
}, i * 200);
}
alert.info(`exporting and keeping original for all ${workflows.length} workflows`);
};
const deduplicateIds = (data) => {
@@ -2811,7 +2820,7 @@ const Workflows = (props) => {
style={{}}
variant="text"
onClick={() => {
exportAllWorkflows();
exportAllWorkflows(workflows);
}}
>
<GetAppIcon />