Added download as file option to app creator and OpenAPI as a whole
This commit is contained in:
@@ -2820,6 +2820,7 @@ class AppBase:
|
|||||||
self.logger.info("[INFO] NO FILES TO HANDLE")
|
self.logger.info("[INFO] NO FILES TO HANDLE")
|
||||||
|
|
||||||
tmp_result = {
|
tmp_result = {
|
||||||
|
"success": True,
|
||||||
"result": newres[0],
|
"result": newres[0],
|
||||||
"file_ids": file_ids
|
"file_ids": file_ids
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,7 +699,7 @@ func getDockerImage(resp http.ResponseWriter, request *http.Request) {
|
|||||||
// REBUILDS THE APP
|
// REBUILDS THE APP
|
||||||
if len(img.ID) == 0 {
|
if len(img.ID) == 0 {
|
||||||
if len(img2.ID) == 0 {
|
if len(img2.ID) == 0 {
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 0)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 0, 0)
|
||||||
log.Printf("[INFO] Getting workflowapps for a rebuild. Got %d with err %#v", len(workflowapps), err)
|
log.Printf("[INFO] Getting workflowapps for a rebuild. Got %d with err %#v", len(workflowapps), err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
imageName := ""
|
imageName := ""
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module main
|
|||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
//replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared
|
replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared
|
||||||
|
|
||||||
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
||||||
//replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch
|
//replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch
|
||||||
|
|||||||
@@ -4075,7 +4075,7 @@ func runInitEs(ctx context.Context) {
|
|||||||
|
|
||||||
// Getting apps to see if we should initialize a test
|
// Getting apps to see if we should initialize a test
|
||||||
// FIXME: Isn't this a little backwards?
|
// FIXME: Isn't this a little backwards?
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
log.Printf("[INFO] Getting and validating workflowapps. Got %d with err %#v", len(workflowapps), err)
|
log.Printf("[INFO] Getting and validating workflowapps. Got %d with err %#v", len(workflowapps), err)
|
||||||
|
|
||||||
// accept any certificate (might be useful for testing)
|
// accept any certificate (might be useful for testing)
|
||||||
@@ -4727,7 +4727,7 @@ func runInit(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Getting apps to see if we should initialize a test
|
// Getting apps to see if we should initialize a test
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
log.Printf("[INFO] Getting and validating workflowapps. Got %d with err %s", len(workflowapps), err)
|
log.Printf("[INFO] Getting and validating workflowapps. Got %d with err %s", len(workflowapps), err)
|
||||||
if err != nil && len(workflowapps) == 0 {
|
if err != nil && len(workflowapps) == 0 {
|
||||||
log.Printf("[WARNING] Failed getting apps (runInit): %s", err)
|
log.Printf("[WARNING] Failed getting apps (runInit): %s", err)
|
||||||
@@ -5342,7 +5342,7 @@ func migrateDatabase(resp http.ResponseWriter, request *http.Request) {
|
|||||||
log.Printf("[DEBUG] Found %d workflows(s) to be migrated", len(workflows))
|
log.Printf("[DEBUG] Found %d workflows(s) to be migrated", len(workflows))
|
||||||
}
|
}
|
||||||
|
|
||||||
apps, err := shuffle.GetAllWorkflowApps(ctx, 0)
|
apps, err := shuffle.GetAllWorkflowApps(ctx, 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed getting apps: %#v", err)
|
log.Printf("[ERROR] Failed getting apps: %#v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1655,7 +1655,7 @@ func getWorkflowApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("{WARNING] Failed getting apps (getworkflowapps): %s", err)
|
log.Printf("{WARNING] Failed getting apps (getworkflowapps): %s", err)
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
@@ -1753,7 +1753,7 @@ func getSpecificApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
// FIXME - continue the search here with github repos etc.
|
// FIXME - continue the search here with github repos etc.
|
||||||
// Caching might be smart :D
|
// Caching might be smart :D
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error: Failed getting workflowapps: %s", err)
|
log.Printf("Error: Failed getting workflowapps: %s", err)
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
@@ -2030,7 +2030,7 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) {
|
|||||||
func iterateOpenApiGithub(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string) error {
|
func iterateOpenApiGithub(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string) error {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
appCounter := 0
|
appCounter := 0
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to get existing generated apps")
|
log.Printf("Failed to get existing generated apps")
|
||||||
@@ -2329,7 +2329,7 @@ func setNewWorkflowApp(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
allapps, err := shuffle.GetAllWorkflowApps(ctx, 1000)
|
allapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed getting apps to verify: %s", err)
|
log.Printf("Failed getting apps to verify: %s", err)
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
@@ -2797,7 +2797,7 @@ func IterateAppGithubFolders(ctx context.Context, fs billy.Filesystem, dir []os.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(allapps) == 0 {
|
if len(allapps) == 0 {
|
||||||
allapps, err = shuffle.GetAllWorkflowApps(ctx, 0)
|
allapps, err = shuffle.GetAllWorkflowApps(ctx, 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARNING] Failed getting apps to verify: %s", err)
|
log.Printf("[WARNING] Failed getting apps to verify: %s", err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1434,7 +1434,7 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
//);
|
//);
|
||||||
|
|
||||||
var tmpFiltered = responseJson.filter((app) => !internalIds.includes(app.name))
|
var tmpFiltered = responseJson.filter((app) => !internalIds.includes(app.name))
|
||||||
tmpFiltered = sortByKey(tmpFiltered, "activated")
|
//tmpFiltered = sortByKey(tmpFiltered, "activated")
|
||||||
setFilteredApps(tmpFiltered)
|
setFilteredApps(tmpFiltered)
|
||||||
|
|
||||||
//!(!app.activated && app.generated)
|
//!(!app.activated && app.generated)
|
||||||
@@ -1806,8 +1806,6 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
currentedge.style('control-point-distance', edgeCurve.distance)
|
currentedge.style('control-point-distance', edgeCurve.distance)
|
||||||
currentedge.style('control-point-weight', edgeCurve.weight)
|
currentedge.style('control-point-weight', edgeCurve.weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (styledElements.length === 1) {
|
if (styledElements.length === 1) {
|
||||||
@@ -4028,8 +4026,8 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
const destinationnode = actions.find(node => node.data._id === branch.destination_id)
|
const destinationnode = actions.find(node => node.data._id === branch.destination_id)
|
||||||
if (sourcenode !== undefined && destinationnode !== undefined && branch.source_id !== branch.destination_id) {
|
if (sourcenode !== undefined && destinationnode !== undefined && branch.source_id !== branch.destination_id) {
|
||||||
//node.data._id = action["id"]
|
//node.data._id = action["id"]
|
||||||
console.log("SOURCE: ", sourcenode.position)
|
//console.log("SOURCE: ", sourcenode.position)
|
||||||
console.log("DESTINATIONNODE: ", destinationnode.position)
|
//console.log("DESTINATIONNODE: ", destinationnode.position)
|
||||||
|
|
||||||
const edgeCurve = calculateEdgeCurve(sourcenode, destinationnode)
|
const edgeCurve = calculateEdgeCurve(sourcenode, destinationnode)
|
||||||
edge.style = {
|
edge.style = {
|
||||||
@@ -5184,11 +5182,15 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
const image = app.large_image;
|
const image = app.large_image;
|
||||||
const newAppStyle = JSON.parse(JSON.stringify(paperAppStyle));
|
const newAppStyle = JSON.parse(JSON.stringify(paperAppStyle));
|
||||||
const pixelSize = !hover ? "2px" : "4px";
|
const pixelSize = !hover ? "2px" : "4px";
|
||||||
//) && !(!app.activated && app.generated)
|
//newAppStyle.borderLeft = app.is_valid && app.actions !== null && app.actions !== undefined && app.actions.length > 0 && !(app.activated && app.generated)
|
||||||
newAppStyle.borderLeft = app.is_valid && app.actions !== null && app.actions !== undefined && app.actions.length > 0 && !(app.activated && app.generated)
|
newAppStyle.borderLeft = app.is_valid && app.actions !== null && app.actions !== undefined && app.actions.length > 0
|
||||||
? `${pixelSize} solid ${green}`
|
? `${pixelSize} solid ${green}`
|
||||||
: `${pixelSize} solid ${yellow}`;
|
: `${pixelSize} solid ${yellow}`;
|
||||||
|
|
||||||
|
if (!app.activated && app.generated) {
|
||||||
|
newAppStyle.borderLeft = `${pixelSize} solid ${yellow}`;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Draggable
|
<Draggable
|
||||||
onDrag={(e) => {
|
onDrag={(e) => {
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ const AppCreator = (defaultprops) => {
|
|||||||
const [appBuilding, setAppBuilding] = useState(false);
|
const [appBuilding, setAppBuilding] = useState(false);
|
||||||
const [extraBodyFields, setExtraBodyFields] = useState([]);
|
const [extraBodyFields, setExtraBodyFields] = useState([]);
|
||||||
const [fileUploadEnabled, setFileUploadEnabled] = useState(false);
|
const [fileUploadEnabled, setFileUploadEnabled] = useState(false);
|
||||||
|
const [fileDownloadEnabled, setFileDownloadEnabled] = useState(false);
|
||||||
const [actionAmount, setActionAmount] = useState(increaseAmount);
|
const [actionAmount, setActionAmount] = useState(increaseAmount);
|
||||||
const defaultAuth = {
|
const defaultAuth = {
|
||||||
name: "",
|
name: "",
|
||||||
@@ -954,6 +955,7 @@ const AppCreator = (defaultprops) => {
|
|||||||
methodvalue.responses.default.content["text/plain"] !==
|
methodvalue.responses.default.content["text/plain"] !==
|
||||||
undefined
|
undefined
|
||||||
) {
|
) {
|
||||||
|
console.log("RESP: ", path, methodvalue.responses.default.content["text/plain"])
|
||||||
if (
|
if (
|
||||||
methodvalue.responses.default.content["text/plain"][
|
methodvalue.responses.default.content["text/plain"][
|
||||||
"schema"
|
"schema"
|
||||||
@@ -967,8 +969,13 @@ const AppCreator = (defaultprops) => {
|
|||||||
newaction.example_response =
|
newaction.example_response =
|
||||||
methodvalue.responses.default.content["text/plain"][
|
methodvalue.responses.default.content["text/plain"][
|
||||||
"schema"
|
"schema"
|
||||||
]["example"];
|
]["example"]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (methodvalue.responses.default.content["text/plain"]["schema"]["format"] === "binary" && methodvalue.responses.default.content["text/plain"]["schema"]["type"] === "string") {
|
||||||
|
newaction.example_response = "shuffle_file_download"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1636,6 +1643,7 @@ const AppCreator = (defaultprops) => {
|
|||||||
item.name = item.description;
|
item.name = item.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Basic way to allow multiple of the same path
|
// Basic way to allow multiple of the same path
|
||||||
var pathjoin = item.url+"_"+item.method.toLowerCase()
|
var pathjoin = item.url+"_"+item.method.toLowerCase()
|
||||||
if (handledPaths.includes(pathjoin)) {
|
if (handledPaths.includes(pathjoin)) {
|
||||||
@@ -1699,38 +1707,60 @@ const AppCreator = (defaultprops) => {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
item.example_response !== undefined &&
|
item.example_response !== undefined &&
|
||||||
|
item.example_response !== null &&
|
||||||
item.example_response.length > 0
|
item.example_response.length > 0
|
||||||
) {
|
) {
|
||||||
// FIXME: Shallow copy of the string
|
|
||||||
var showResult = Object.assign("", item.example_response).trim();
|
|
||||||
showResult = showResult.split(" None").join(' "None"');
|
|
||||||
showResult = showResult.split("'").join('"');
|
|
||||||
showResult = showResult.split(" False").join(" false");
|
|
||||||
showResult = showResult.split(" True").join(" true");
|
|
||||||
|
|
||||||
var jsonvalid = true;
|
if (item["example_response"] === "shuffle_file_download") {
|
||||||
try {
|
console.log("Download as file: ", item)
|
||||||
const tmp = String(JSON.parse(showResult));
|
|
||||||
if (!showResult.includes("{") && !showResult.includes("[")) {
|
|
||||||
jsonvalid = false;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
jsonvalid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
data.paths[item.url][item.method.toLowerCase()].responses["default"]["content"]["text/plain"].schema.type = "string"
|
||||||
"content"
|
data.paths[item.url][item.method.toLowerCase()].responses["default"]["content"]["text/plain"].schema.format = "binary"
|
||||||
]["text/plain"].schema.type = "string";
|
|
||||||
if (jsonvalid) {
|
/*
|
||||||
// FIXME: Add a JSON parser here - don't run it as a string.
|
schema:
|
||||||
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
type: object
|
||||||
"content"
|
properties:
|
||||||
]["text/plain"].schema.example = showResult;
|
username:
|
||||||
} else {
|
type: string
|
||||||
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
avatar: # <-- image embedded into JSON
|
||||||
"content"
|
type: string
|
||||||
]["text/plain"].schema.example = item.example_response;
|
format: byte
|
||||||
}
|
description: Base64-encoded contents of the avatar image
|
||||||
|
*/
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// FIXME: Shallow copy of the string
|
||||||
|
var showResult = Object.assign("", item.example_response).trim();
|
||||||
|
showResult = showResult.split(" None").join(' "None"');
|
||||||
|
showResult = showResult.split("'").join('"');
|
||||||
|
showResult = showResult.split(" False").join(" false");
|
||||||
|
showResult = showResult.split(" True").join(" true");
|
||||||
|
|
||||||
|
var jsonvalid = true;
|
||||||
|
try {
|
||||||
|
const tmp = String(JSON.parse(showResult));
|
||||||
|
if (!showResult.includes("{") && !showResult.includes("[")) {
|
||||||
|
jsonvalid = false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
jsonvalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
||||||
|
"content"
|
||||||
|
]["text/plain"].schema.type = "string";
|
||||||
|
if (jsonvalid) {
|
||||||
|
// FIXME: Add a JSON parser here - don't run it as a string.
|
||||||
|
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
||||||
|
"content"
|
||||||
|
]["text/plain"].schema.example = showResult;
|
||||||
|
} else {
|
||||||
|
data.paths[item.url][item.method.toLowerCase()].responses["default"][
|
||||||
|
"content"
|
||||||
|
]["text/plain"].schema.example = item.example_response;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.queries.length > 0) {
|
if (item.queries.length > 0) {
|
||||||
@@ -2915,9 +2945,10 @@ const AppCreator = (defaultprops) => {
|
|||||||
|
|
||||||
const url = data.url;
|
const url = data.url;
|
||||||
const hasFile =
|
const hasFile =
|
||||||
data["file_field"] !== undefined &&
|
(data["file_field"] !== undefined &&
|
||||||
data["file_field"] !== null &&
|
data["file_field"] !== null &&
|
||||||
data["file_field"].length > 0;
|
data["file_field"].length > 0) || data["example_response"] === "shuffle_file_download"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper key={index} style={actionListStyle}>
|
<Paper key={index} style={actionListStyle}>
|
||||||
{error}
|
{error}
|
||||||
@@ -3135,7 +3166,7 @@ const AppCreator = (defaultprops) => {
|
|||||||
</div>
|
</div>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const exampleResponse = (
|
const exampleResponse = fileDownloadEnabled ? null : (
|
||||||
<div style={{}}>
|
<div style={{}}>
|
||||||
<b>Example success response</b>
|
<b>Example success response</b>
|
||||||
<TextField
|
<TextField
|
||||||
@@ -3749,6 +3780,29 @@ const AppCreator = (defaultprops) => {
|
|||||||
Enable Fileupload
|
Enable Fileupload
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
|
{currentActionMethod === "GET" ? (
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant={fileDownloadEnabled ? "contained" : "outlined"}
|
||||||
|
style={{
|
||||||
|
marginLeft: 10,
|
||||||
|
marginTop: "5px",
|
||||||
|
marginBottom: "10px",
|
||||||
|
borderRadius: "0px",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setFileDownloadEnabled(!fileDownloadEnabled);
|
||||||
|
if (fileDownloadEnabled) {
|
||||||
|
setActionField("example_response", "");
|
||||||
|
} else {
|
||||||
|
setActionField("example_response", "shuffle_file_download");
|
||||||
|
}
|
||||||
|
setUpdate(Math.random());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Download as file
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
{fileUploadEnabled ? (
|
{fileUploadEnabled ? (
|
||||||
<TextField
|
<TextField
|
||||||
required
|
required
|
||||||
|
|||||||
Reference in New Issue
Block a user