Moved over relevant files

This commit is contained in:
Frikky
2024-11-27 10:46:59 +01:00
parent 11e313c885
commit cf7d744273
7 changed files with 459 additions and 369 deletions
+96 -53
View File
@@ -3793,6 +3793,20 @@ const releaseToConnectLabel = "Release to Connect"
}
}
// Ensuring overwriting
if (nodedata?.type === "ACTION") {
if (nodedata?.parameters !== undefined && nodedata.parameters !== null && nodedata.parameters.length > 0 && workflow?.actions !== undefined && workflow?.actions !== null && workflow?.actions.length > 0) {
for (var actionkey in workflow.actions) {
const action = workflow.actions[actionkey]
if (action.id === nodedata.id) {
workflow.actions[actionkey].parameters = nodedata.parameters
break
}
}
}
}
// Unselecting all
//cy.elements().unselect()
@@ -4164,6 +4178,7 @@ const releaseToConnectLabel = "Release to Connect"
const onNodeDrag = (event, selectedAction) => {
const nodedata = event.target.data();
if (nodedata.finished === false) {
console.log("NOT FINISHED - ADD EXAMPLE BRANCHES TO CLOSEST!!")
return
@@ -4450,11 +4465,15 @@ const releaseToConnectLabel = "Release to Connect"
var AppContext = []
var originalParams = []
var originalField = ""
if (inputAction !== undefined && inputAction !== null) {
// Reload the data without copying
inputAction = JSON.parse(JSON.stringify(inputAction))
originalParams = JSON.parse(JSON.stringify(inputAction.parameters))
if (originalParams.length > 0) {
originalField = originalParams[0].name
}
const parents = getParents(inputAction)
var actionlist = []
@@ -4590,7 +4609,6 @@ const releaseToConnectLabel = "Release to Connect"
credentials: "include",
})
.then((response) => {
setAiQueryModalOpen(false)
setAutocompleting(false)
if (setSuggestionLoading !== undefined) {
setSuggestionLoading(false)
@@ -4599,7 +4617,7 @@ const releaseToConnectLabel = "Release to Connect"
if (response.status !== 200) {
console.log("Status not 200 for stream results :O!");
} else {
toast("Completion finished. Please verify your action!")
toast("Completion finished. Please verify the output and run the workflow again!")
}
return response.json();
@@ -4611,47 +4629,49 @@ const releaseToConnectLabel = "Release to Connect"
if (setResponseMsg !== undefined) {
setResponseMsg(responseJson.reason)
}
toast.error(responseJson.reason)
}
return
} else {
setAiQueryModalOpen(false)
}
if (inputAction !== undefined) {
console.log("In input action! Should check params if they match, and add suggestions")
console.log("ORIGINAL PARAMS: ", originalParams)
console.log("RESPONSE PARAMS: ", responseJson.parameters)
if (responseJson.parameters === undefined || responseJson.parameters.length === 0) {
return
}
var changed = false
var codeeditorfound = false
for (let respParamKey in responseJson.parameters) {
var respParam = responseJson.parameters[respParamKey]
if (respParam.value === undefined || respParam.value === null || respParam.value === "" ) {
continue
}
for (let paramkey in originalParams) {
const actionParam = originalParams[paramkey]
/*
if (actionParam.value !== "" && actionParam.value !== actionParam.example) {
console.log("Skipping: ", actionParam)
continue
}
*/
if (respParam.name !== actionParam.name) {
for (var paramkey in selectedAction?.parameters) {
const actionParam = selectedAction.parameters[paramkey]
if (actionParam.name !== respParam.name) {
continue
}
const codeeditor = document.getElementById("shuffle-codeeditor")
if (codeeditor !== undefined && codeeditor !== null) {
if (codeeditor !== undefined && codeeditor !== null && actionParam.name === originalField) {
const editorInstance = window?.ace?.edit("shuffle-codeeditor")
if (editorInstance === undefined || editorInstance === null) {
toast.error("Failed to find code editor instance")
return
} else {
codeeditorfound = true
editorInstance.setValue(respParam.value)
originalParams[paramkey].autocompleted = true
//selectedAction.parameters[paramkey].value = respParam.value
changed = true
}
}
@@ -4659,26 +4679,25 @@ const releaseToConnectLabel = "Release to Connect"
if (!changed) {
console.log("Found match for param: ", respParam)
changed = true
originalParams[paramkey].autocompleted = true
originalParams[paramkey].value = respParam.value
selectedAction.parameters[paramkey].autocompleted = true
selectedAction.parameters[paramkey].value = respParam.value
}
break
}
}
if (changed === true) {
inputAction.parameters = originalParams
if (changed === true && codeeditorfound === false) {
//inputAction.parameters = JSON.parse(JSON.stringify(selectedAction.parameters))
selectedAction.parameters = JSON.parse(JSON.stringify(selectedAction.parameters))
console.log("Setting action! Force update pls :)")
setUpdate(Math.random())
setSelectedAction(inputAction)
setSelectedAction(selectedAction)
// Find it in cytoscape and update the action
if (cy !== undefined && cy !== null) {
const cyAction = cy.getElementById(inputAction.id)
if (cyAction !== undefined && cyAction !== null) {
cyAction.data("parameters", inputAction.parameters)
cyAction.data("parameters", selectedAction.parameters)
}
}
@@ -8871,8 +8890,8 @@ const releaseToConnectLabel = "Release to Connect"
const paperVariableStyle = {
borderRadius: theme.palette?.borderRadius,
minHeight: 50,
maxHeight: 50,
minHeight: 70,
maxHeight: 150,
minWidth: "100%",
maxWidth: "100%",
marginTop: "5px",
@@ -8960,7 +8979,7 @@ const releaseToConnectLabel = "Release to Connect"
}
}}
>
Name: {variable.name}
{variable.name}
</div>
<div style={{ flex: "1", marginLeft: "0px" }}>
<IconButton
@@ -9448,10 +9467,7 @@ const releaseToConnectLabel = "Release to Connect"
const handleDragStop = (e, app) => {
var currentnode = cy.getElementById(newNodeId);
if (
currentnode === undefined ||
currentnode === null ||
currentnode.length === 0
if (currentnode === undefined || currentnode === null || currentnode.length === 0
) {
return;
}
@@ -9464,16 +9480,37 @@ const releaseToConnectLabel = "Release to Connect"
// Using remove & replace, as this triggers the function
// onNodeAdded() with this node after it's added
console.log("Nodedata: ", parsedApp.data)
currentnode.remove()
currentnode.remove();
parsedApp.data.finished = true;
parsedApp.data.position = currentnode.renderedPosition();
parsedApp.position = currentnode.renderedPosition();
parsedApp.renderedPosition = currentnode.renderedPosition();
parsedApp.data.finished = true
parsedApp.data.position = currentnode.renderedPosition()
parsedApp.position = currentnode.renderedPosition()
parsedApp.renderedPosition = currentnode.renderedPosition()
var newAppData = parsedApp.data;
var newAppData = JSON.parse(JSON.stringify(parsedApp.data))
if (newAppData.type === "ACTION") {
if (newAppData.app_name === "Shuffle Tools") {
const iconInfo = GetIconInfo(newAppData)
const svg_pin = `<svg width="${svgSize}" height="${svgSize}" viewBox="0 0 ${svgSize} ${svgSize}" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="${iconInfo.icon}" fill="${iconInfo.iconColor}"></path></svg>`;
const svgpin_Url = encodeURI("data:image/svg+xml;utf-8," + svg_pin)
newAppData.large_image = svgpin_Url
newAppData.fillGradient = iconInfo.fillGradient
newAppData.fillstyle = "solid"
if (
newAppData.fillGradient !== undefined &&
newAppData.fillGradient !== null &&
newAppData.fillGradient.length > 0
) {
newAppData.fillstyle = "linear-gradient"
} else {
newAppData.iconBackground = iconInfo.iconBackgroundColor
}
}
//const activateApp = (appid) => {
if (newAppData.activated === false) {
activateApp(newAppData.app_id, false)
@@ -9556,13 +9593,13 @@ const releaseToConnectLabel = "Release to Connect"
}
parsedApp.data = newAppData;
cy.add(parsedApp);
cy.add(parsedApp)
} else if (newAppData.type === "TRIGGER") {
cy.add(parsedApp);
cy.add(parsedApp)
}
newNodeId = "";
parsedApp = {};
newNodeId = ""
parsedApp = {}
};
const barHeight = bodyHeight - appBarSize - 50;
@@ -9576,7 +9613,7 @@ const releaseToConnectLabel = "Release to Connect"
}
const handleAppDrag = (e, app) => {
const cycontainer = cy.container();
const cycontainer = cy.container()
// Handling drag of public apps
if (app.objectID !== undefined && app.objectID !== null && app.objectID.length > 0) {
@@ -9612,7 +9649,7 @@ const releaseToConnectLabel = "Release to Connect"
currentnode === null ||
currentnode.length === 0
) {
return;
return
}
currentnode[0].renderedPosition("x", e.pageX - cycontainer.offsetLeft)
@@ -9737,7 +9774,6 @@ const releaseToConnectLabel = "Release to Connect"
description: description,
environment: parsedEnvironments,
errors: [],
finished: false,
id_: newNodeId,
_id_: newNodeId,
id: newNodeId,
@@ -9758,8 +9794,10 @@ const releaseToConnectLabel = "Release to Connect"
? app.categories[0]
: "",
authentication_id: authId,
finished: false,
template: app.template === true ? true : false,
//finished: false,
finished: false,
}
// FIXME: Something is going wrong with params
@@ -11041,6 +11079,7 @@ const releaseToConnectLabel = "Release to Connect"
autocomplete: "exec",
example: "tmp",
})
actionlist.push({
type: "Shuffle DB",
name: "Shuffle DB",
@@ -13823,6 +13862,7 @@ const releaseToConnectLabel = "Release to Connect"
</div>
</div>
{/*
<div>
<div>
<div className="app">
@@ -13840,6 +13880,7 @@ const releaseToConnectLabel = "Release to Connect"
</div>
</div>
</div>
*/}
</div>
);
}
@@ -16152,7 +16193,7 @@ const releaseToConnectLabel = "Release to Connect"
</div>
{showEnvironment === true && environments.length > 1 && selectedActionEnvironment !== undefined && selectedActionEnvironment !== null && selectedActionEnvironment.Name !== undefined && selectedActionEnvironment.Name !== null ?
<FormControl fullWidth style={{marginTop: 15, marginleft: 10, pointerEvents: "auto", }}>
<FormControl fullWidth style={{marginTop: 15, marginleft: 10, pointerEvents: "auto", maxWidth: 250, }}>
<InputLabel
id="execution_location"
@@ -21758,11 +21799,11 @@ const releaseToConnectLabel = "Release to Connect"
}
const drawerData = originalWorkflow !== undefined && originalWorkflow !== null ?
<div style={{ height: "100%"}}>
<Typography variant="h4" style={{ paddingLeft: 25, paddingTop:25, backgroundColor: theme.palette.surfaceColor, }}>
<div style={{ height: "100%", backgroundColor: theme.palette.backgroundColor, }}>
<Typography variant="h4" style={{ paddingLeft: 25, paddingTop:25, backgroundColor: theme.palette.backgroundColor, }}>
Version History
</Typography>
<Typography variant="body2" color="textSecondary" style={{ paddingLeft: 25, paddingTop: 5, paddingBottom: 5, backgroundColor: theme.palette.surfaceColor, }}>
<Typography variant="body2" color="textSecondary" style={{ paddingLeft: 25, paddingTop: 5, paddingBottom: 5, }}>
Versions are stored for every change made, up to once per minute. When restoring a version, the changes will not take effect until you save the workflow.
</Typography>
<Divider style={{marginTop: 25, }}/>
@@ -21871,21 +21912,23 @@ const releaseToConnectLabel = "Release to Connect"
</Button>
: null*/}
</div>
<div style={{textAlign: "center", color: "white", flex: 1, paddingTop: 20, }}>
<div style={{textAlign: "center", color: "white", flex: 2, paddingTop: 20, }}>
<Typography variant="h6">
{selectedVersion?.name}
</Typography>
</div>
{/* Cross icon to close it */}
<div style={{flex: 1, itemAlign: "right", textAlign: "right", paddingRight: 25, paddingTop: 10, }}>
<IconButton
<Button
onClick={() => {
setShowWorkflowRevisions(false)
}}
style={{color: "white", height: 50, width: 50, }}
color="secondary"
variant="outlined"
style={{marginTop: 10, }}
>
<CloseIcon />
</IconButton>
Use Version
<CloseIcon style={{marginLeft: 10, }}/>
</Button>
</div>
</div>
</div>
+105 -98
View File
@@ -37,14 +37,15 @@ import {
AttachFile as AttachFileIcon,
Apps as AppsIcon,
ErrorOutline as ErrorOutlineIcon,
AddAPhoto as AddAPhotoIcon,
AddAPhotoOutlined as AddAPhotoOutlinedIcon,
ZoomInOutlined as ZoomInOutlinedIcon,
ZoomOutOutlined as ZoomOutOutlinedIcon,
Loop as LoopIcon,
AddPhotoAlternate as AddPhotoAlternateIcon,
CallMerge as CallMergeIcon,
AddAPhoto as AddAPhotoIcon,
AddAPhotoOutlined as AddAPhotoOutlinedIcon,
ZoomInOutlined as ZoomInOutlinedIcon,
ZoomOutOutlined as ZoomOutOutlinedIcon,
Loop as LoopIcon,
AddPhotoAlternate as AddPhotoAlternateIcon,
CallMerge as CallMergeIcon,
CloudDownload as CloudDownloadIcon,
OpenInNew as OpenInNewIcon,
} from "@mui/icons-material";
import { v4 as uuidv4 } from "uuid";
@@ -3172,7 +3173,7 @@ const AppCreator = (defaultprops) => {
<div style={{ color: "white", marginTop: 20 }}>
<Typography variant="body1">API key authentication</Typography>
<Typography variant="body2" color="textSecondary">
Add the name of the field used for authentication, e.g. "X-APIKEY". Should NOT be your actual API-key.
<b>Do NOT put your actual API-key.</b> Add the name of the field used for authentication, e.g. "X-APIKEY".
</Typography>
<div style={{display: "flex", marginTop: 10, }}>
<div style={{flex: 4,}}>
@@ -3848,7 +3849,7 @@ const AppCreator = (defaultprops) => {
required
style={{
flex: "1",
marginTop: "5px",
marginTop: 5,
marginRight: "15px",
backgroundColor: inputColor,
}}
@@ -4341,7 +4342,8 @@ const AppCreator = (defaultprops) => {
>
<ErrorOutlineIcon />
</Tooltip>
) : (
) : null
{/*
<Tooltip
color="secondary"
title={data.errors.join("\n")}
@@ -4349,7 +4351,7 @@ const AppCreator = (defaultprops) => {
>
<CheckCircleIcon style={{ marginTop: 6 }} />
</Tooltip>
);
*/}
var bgColor = "#61afee";
if (data.method === "POST") {
@@ -5800,19 +5802,35 @@ const AppCreator = (defaultprops) => {
General information
</h2>
</div>
<div style={{flex: 1, itemAlign: "right", textAlign: "right",}}>
<Tooltip title="Merge with another API (coming soon)" placement="bottom">
<IconButton
disabled
<div style={{flex: 1, itemAlign: "right", textAlign: "right", marginRight: 10, }}>
<Tooltip title="Try the API" placement="bottom">
<Button
variant="outlined"
color="secondary"
onClick={() => {
setOpenApiModal(true)
var urlParams = new URLSearchParams(window.location.search);
if (!urlParams.has("id")) {
window.open(`/apis/${app.id}`, "_blank")
} else {
toast.error("Build the app first.")
}
}}
>
<OpenInNewIcon style={{marginRight: 5, }}/>
Try the API
</Button>
</Tooltip>
<Tooltip title="Manage forks and Merge with another API (coming soon)" placement="bottom">
<IconButton
onClick={() => {
//setOpenApiModal(true)
toast.info("Action merging & fork management coming soon")
}}
style={{marginLeft: 10, }}
>
<CallMergeIcon
style={{}}
onClick={() => {
setOpenApiModal(true)
}}
/>
</IconButton>
</Tooltip>
@@ -5839,18 +5857,13 @@ const AppCreator = (defaultprops) => {
flex: "1",
margin: 10,
border: "1px solid #f85a3e",
borderRadius: theme.palette?.borderRadius,
cursor: "pointer",
backgroundColor: inputColor,
maxWidth: 174,
maxHeight: 174,
}}
onClick={() => {
/*
if (fileBase64.length === 0) {
upload.click()
}
*/
setOpenImageModal(true);
}}
>
@@ -5863,7 +5876,7 @@ const AppCreator = (defaultprops) => {
/>
</div>
</Tooltip>
<div style={{ flex: "3", color: "white" }}>
<div style={{ flex: "3", color: "white", marginLeft: 20, }}>
<div style={{ marginTop: "10px" }} />
Name
<TextField
@@ -5917,35 +5930,28 @@ const AppCreator = (defaultprops) => {
},
}}
/>
<div style={{ marginTop: "10px" }} />
<div style={{ marginTop: 10, }} />
Description
<TextField
required
style={{
flex: "1",
marginTop: "5px",
marginRight: "15px",
paddingTop: 5,
marginTop: 5,
marginRight: 15,
backgroundColor: inputColor,
maxHeight: 250,
overflow: "auto",
maxHeight: 250,
overflowY: "auto"
}}
fullWidth={true}
type="name"
id="outlined-with-placeholder"
margin="normal"
multiline
multiline
variant="outlined"
placeholder="A description for the service"
value={description}
onChange={(e) => setDescription(e.target.value)}
InputProps={{
classes: {
notchedOutline: classes.notchedOutline,
},
style: {
color: "white",
},
}}
defaultValue={description}
//onChange={(e) => setDescription(e.target.value)}
onBlur={(e) => setDescription(e.target.value)}
/>
</div>
</div>
@@ -6185,62 +6191,63 @@ const AppCreator = (defaultprops) => {
{testView}
*/}
<div style={{display: "flex", marginTop: 35, }}>
{appDownloadData.length > 0 ?
<Tooltip title="Download the OpenAPI specification for the App" placement="bottom">
<IconButton
style={{marginRight: 25, }}
onClick={() => {
toast(`Downloading OpenAPI JSON data for for ${name}`)
// Download as file
var blob = new Blob([appDownloadData], {
type: "application/octet-stream",
});
<div style={{height: 50, padding: 25, display: "flex", marginTop: 35, position: "fixed", bottom: 0, left: 0, width: "100%", backgroundColor: theme.palette?.backgroundColor, borderTop: "1px solid rgba(255,255,255,0.3)",}}>
<div style={{width: 450, margin: "auto", display: "flex", textAlign: "center", }}>
{appDownloadData.length > 0 ?
<Tooltip title="Download the OpenAPI specification for the App" placement="bottom">
<IconButton
style={{marginRight: 25, }}
onClick={() => {
toast(`Downloading OpenAPI JSON data for for ${name}`)
// Download as file
var blob = new Blob([appDownloadData], {
type: "application/octet-stream",
});
var url = URL.createObjectURL(blob);
var link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", `${name}.json`);
var event = document.createEvent("MouseEvents");
event.initMouseEvent(
"click",
true,
true,
window,
1,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
link.dispatchEvent(event);
}}
>
<CloudDownloadIcon />
</IconButton>
</Tooltip>
: null}
<Button
disabled={appBuilding}
color="primary"
variant="contained"
fullWidth
style={{ height: "50px", flex: 1, }}
onClick={() => {
submitApp();
}}
>
{appBuilding ? <CircularProgress /> : "Save"}
</Button>
{appDownloadData.length > 0 ?
<div style={{width: 50, }}/>
: null}
var url = URL.createObjectURL(blob);
var link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", `${name}.json`);
var event = document.createEvent("MouseEvents");
event.initMouseEvent(
"click",
true,
true,
window,
1,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
link.dispatchEvent(event);
}}
>
<CloudDownloadIcon />
</IconButton>
</Tooltip>
: null}
<Button
disabled={appBuilding}
color="primary"
variant="contained"
style={{ height: 50, flex: 1, minWidth: 400, maxWidth: 400, }}
onClick={() => {
submitApp();
}}
>
{appBuilding ? <CircularProgress /> : "Save API"}
</Button>
{appDownloadData.length > 0 ?
<div style={{width: 50, }}/>
: null}
</div>
</div>
<Typography style={{ marginTop: 25, textAlign: "center", }}>