Fixed further user input issues

This commit is contained in:
Frikky
2024-03-19 23:56:16 +01:00
parent 06494a0093
commit 54b3687eef
9 changed files with 148 additions and 38 deletions
+9 -2
View File
@@ -1371,9 +1371,16 @@ class AppBase:
returns = [] returns = []
for item in value: for item in value:
self.logger.info("VALUE: %s" % item) self.logger.info("FILE VALUE: %s" % item)
# Check if item is a dict, and if it is, check if it has the key "id"
if isinstance(item, dict):
if "file_id" in item:
item = item["file_id"]
elif "id" in item:
item = item["id"]
if len(item) != 36 and not item.startswith("file_"): if len(item) != 36 and not item.startswith("file_"):
self.logger.info("Bad length for file value %s" % item) self.logger.info("Bad length for file value: '%s'" % item)
continue continue
#return { #return {
# "filename": "", # "filename": "",
+1 -3
View File
@@ -457,7 +457,7 @@ const CacheView = (props) => {
const validate = validateJson(data.value); const validate = validateJson(data.value);
return ( return (
<ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "hidden", }}> <ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "auto", }}>
<ListItemText <ListItemText
style={{ style={{
maxWidth: 250, maxWidth: 250,
@@ -470,8 +470,6 @@ const CacheView = (props) => {
style={{ style={{
minWidth: 400, minWidth: 400,
maxWidth: 400, maxWidth: 400,
overflowX: "auto",
overflowY: "hidden",
}} }}
primary={validate.valid ? primary={validate.valid ?
<ReactJson <ReactJson
+1 -1
View File
@@ -59,7 +59,7 @@ const Files = (props) => {
const [downloadFolder, setDownloadFolder] = React.useState("translation_standards"); const [downloadFolder, setDownloadFolder] = React.useState("translation_standards");
//const alert = useAlert(); //const alert = useAlert();
const allowedFileTypes = ["txt", "py", "yaml", "yml","json", "html", "js", "csv", "log"] const allowedFileTypes = ["txt", "py", "yaml", "yml","json", "html", "js", "csv", "log", "eml", "msg", "md", "xml", "sh", "bat", "ps1", "psm1", "psd1", "ps1xml", "pssc", "psc1"]
var upload = ""; var upload = "";
const handleKeyDown = (event) => { const handleKeyDown = (event) => {
+15 -8
View File
@@ -1155,7 +1155,7 @@ If you're interested, please let me know a time that works for you, or set up a
}) })
.then((responseJson) => { .then((responseJson) => {
if (responseJson.success === false) { if (responseJson.success === false) {
toast("Failed getting your org. If this persists, please contact support."); //toast("Failed getting your org. If this persists, please contact support.");
} else { } else {
const { subOrgs, parentOrg } = responseJson; const { subOrgs, parentOrg } = responseJson;
setSubOrgs(subOrgs); setSubOrgs(subOrgs);
@@ -1164,7 +1164,7 @@ If you're interested, please let me know a time that works for you, or set up a
}) })
.catch((error) => { .catch((error) => {
console.log("Error getting sub orgs: ", error); console.log("Error getting sub orgs: ", error);
toast("Error getting sub organizations"); //toast("Error getting sub organizations");
}); });
}; };
@@ -2846,13 +2846,20 @@ If you're interested, please let me know a time that works for you, or set up a
: null} : null}
{isCloud ? {isCloud ?
<Tooltip <Tooltip
title={`Organization is in ${regiontag}. Click to change!`} title={`Your organization is in ${regiontag}. Click to change!`}
style={{}} style={{
}}
> >
<Avatar <Avatar
style={{ top: -10, right: 50, position: "absolute", }} style={{ cursor: "pointer", top: -10, right: 50, position: "absolute", }}
onClick={() => { onClick={() => {
toast("Region change is not implemented yet for users. Please contact support.") toast("Region change is not directly implemented yet, and requires support help.")
if (window.drift !== undefined) {
window.drift.api.startInteraction({
interactionId: 386411,
})
}
}} }}
> >
{regiontag} {regiontag}
@@ -3924,7 +3931,7 @@ If you're interested, please let me know a time that works for you, or set up a
Schedules used in Workflows. Makes locating and control easier.{" "} Schedules used in Workflows. Makes locating and control easier.{" "}
<a <a
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
href="/docs/organizations#schedules" href="/docs/organizations#schedules"
style={{ textDecoration: "none", color: "#f85a3e" }} style={{ textDecoration: "none", color: "#f85a3e" }}
> >
@@ -4528,7 +4535,7 @@ If you're interested, please let me know a time that works for you, or set up a
style={{ minWidth: 150, maxWidth: 150 }} style={{ minWidth: 150, maxWidth: 150 }}
/> />
<ListItemText <ListItemText
primary="Orborus label" primary="Status"
style={{ minWidth: 150, maxWidth: 150 }} style={{ minWidth: 150, maxWidth: 150 }}
/> />
<ListItemText <ListItemText
+82 -3
View File
@@ -117,6 +117,7 @@ import {
Polyline as PolylineIcon, Polyline as PolylineIcon,
QueryStats as QueryStatsIcon, QueryStats as QueryStatsIcon,
AutoAwesome as AutoAwesomeIcon, AutoAwesome as AutoAwesomeIcon,
Add as AddIcon,
} from "@mui/icons-material"; } from "@mui/icons-material";
import * as cytoscape from "cytoscape"; import * as cytoscape from "cytoscape";
@@ -13026,6 +13027,35 @@ const AngularWorkflow = (defaultprops) => {
}); });
}; };
// POST to /api/v1/workflows
const createWorkflow = (workflow, trigger_index) => {
fetch(globalUrl + "/api/v1/workflows", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(workflow),
credentials: "include",
})
.then((response) => {
if (response.status === 200) {
getAvailableWorkflows(trigger_index)
}
return response.json();
})
.then((responseJson) => {
if (responseJson.id !== undefined && responseJson.id !== null && responseJson.id.length > 0) {
toast("Successfully created workflow");
handleWorkflowSelectionUpdate({ target: { value: responseJson } }, true)
}
})
.catch((error) => {
console.log("Create workflow error: ", error.toString())
})
}
const UserinputSidebar = () => { const UserinputSidebar = () => {
if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) { if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) {
if ( if (
@@ -13229,7 +13259,7 @@ const AngularWorkflow = (defaultprops) => {
/> />
</FormGroup> </FormGroup>
{workflow.triggers[selectedTriggerIndex].parameters[2] !== undefined && workflow.triggers[selectedTriggerIndex].parameters[2].value.includes("subflow") ? ( {workflow.triggers[selectedTriggerIndex].parameters[2] !== undefined && workflow.triggers[selectedTriggerIndex].parameters[2].value.includes("subflow") ? (
<div style={{ }}> <div style={{ }}>
{workflows === undefined || {workflows === undefined ||
workflows === null || workflows === null ||
workflows.length === 0 ? null : ( workflows.length === 0 ? null : (
@@ -13316,7 +13346,29 @@ const AngularWorkflow = (defaultprops) => {
}} }}
/> />
)} )}
</div>
{/* Button for making a new workflow to attach */}
<Button
variant="outlined"
style={{ marginTop: 10, }}
disabled={!(subworkflow === null || subworkflow === undefined || Object.getOwnPropertyNames(subworkflow).length === 0)}
onClick={() => {
toast("Setting up new workflow")
const newworkflow = {
name: "User Input subflow",
description: "",
}
createWorkflow(newworkflow, selectedTriggerIndex)
}}
color="primary"
>
<AddIcon /> New Subflow
</Button>
</div>
) : null} ) : null}
{workflow.triggers[selectedTriggerIndex].parameters[2] !== {workflow.triggers[selectedTriggerIndex].parameters[2] !==
undefined && undefined &&
@@ -16202,11 +16254,13 @@ const AngularWorkflow = (defaultprops) => {
<Typography variant="body1"> <Typography variant="body1">
<b>Env &nbsp;&nbsp;&nbsp;&nbsp;</b> <b>Env &nbsp;&nbsp;&nbsp;&nbsp;</b>
</Typography> </Typography>
<Typography variant="body1" color="textSecondary" style={{color: "#f85a3e", cursor: "pointer", }} onClick={() => { <Typography variant="body1" color="textSecondary" style={{color: "#f85a3e", cursor: "pointer", }} onClick={() => {
window.open("/admin?tab=environments", "_blank") window.open("/admin?tab=environments", "_blank")
}}> }}>
{executionData.workflow.actions[0].environment} {executionData.workflow.actions[0].environment}
</Typography> </Typography>
</div> </div>
: null} : null}
{executionData.status !== undefined && {executionData.status !== undefined &&
@@ -16877,6 +16931,30 @@ const AngularWorkflow = (defaultprops) => {
return "" return ""
} }
// Check if array with json inside to handle one item at a time~
if (typeof result === "object" && result.length !== undefined) {
if (result.length > 0) {
// Check type inside
if (typeof result[0] === "object") {
result = result[0]
}
}
}
if (result.success === true && result.status === 200) {
if (result.body !== undefined && result.body !== null) {
const stringbody = result.body.toString()
if ((stringbody.startsWith("{") && stringbody.endsWith("}")) || (stringbody.startsWith("[") && stringbody.endsWith("]"))) {
return ""
}
if (stringbody.length > 1000) {
return "Body looks to be big in a standard format. Consider using the 'To File' parameter to automatically make it into a file."
}
} else {
}
}
// Validate and check for newlines // Validate and check for newlines
if (result.success !== false) { if (result.success !== false) {
@@ -16894,7 +16972,8 @@ const AngularWorkflow = (defaultprops) => {
} }
return "" return ""
} }
try { try {
stringjson = JSON.stringify(result) stringjson = JSON.stringify(result)
+30 -18
View File
@@ -1018,9 +1018,9 @@ const Workflows = (props) => {
data.default_return_value, data.default_return_value,
data, data,
false, false,
[], [],
"", "",
data.status data.status
).then((response) => { ).then((response) => {
if (response !== undefined) { if (response !== undefined) {
toast(`Successfully imported ${data.name}`); toast(`Successfully imported ${data.name}`);
@@ -1483,17 +1483,9 @@ const Workflows = (props) => {
const sanitizeWorkflow = (data) => { const sanitizeWorkflow = (data) => {
data = JSON.parse(JSON.stringify(data)); data = JSON.parse(JSON.stringify(data));
data["owner"] = "";
console.log("Sanitize start: ", data); console.log("Sanitize start: ", data);
data = deduplicateIds(data); data = deduplicateIds(data);
data["org"] = [];
data["org_id"] = "";
data["execution_org"] = {};
// These are backwards.. True = saved before. Very confuse.
data["previously_saved"] = false;
data["first_save"] = false;
console.log("Sanitize end: ", data); console.log("Sanitize end: ", data);
return data; return data;
@@ -1508,14 +1500,24 @@ const Workflows = (props) => {
let exportFileDefaultName = data.name + ".json"; let exportFileDefaultName = data.name + ".json";
data["owner"] = "";
data["org"] = [];
data["org_id"] = "";
data["execution_org"] = {};
// These are backwards.. True = saved before. Very confuse.
data["previously_saved"] = false;
data["first_save"] = false;
if (sanitize === true) { if (sanitize === true) {
data = sanitizeWorkflow(data); data = sanitizeWorkflow(data);
if (data.subflows !== null && data.subflows !== undefined) { if (data.subflows !== null && data.subflows !== undefined) {
toast( toast(
"Not exporting with subflows when sanitizing. Please manually export them." "Not exporting with subflows when sanitizing. Please manually export them."
); )
data.subflows = [];
data.subflows = []
} }
// for (var key in data.subflows) { // for (var key in data.subflows) {
@@ -1527,7 +1529,7 @@ const Workflows = (props) => {
// Add correct ID's for triggers // Add correct ID's for triggers
// Add mag // Add mag
data.status = "test" data.status = "test"
let dataStr = JSON.stringify(data); let dataStr = JSON.stringify(data);
let dataUri = let dataUri =
"data:application/json;charset=utf-8," + encodeURIComponent(dataStr); "data:application/json;charset=utf-8," + encodeURIComponent(dataStr);
@@ -2220,6 +2222,7 @@ const Workflows = (props) => {
inputblogpost, inputblogpost,
inputstatus, inputstatus,
) => { ) => {
var method = "POST"; var method = "POST";
var extraData = ""; var extraData = "";
var workflowdata = {}; var workflowdata = {};
@@ -2232,6 +2235,10 @@ const Workflows = (props) => {
console.log("REMOVING OWNER"); console.log("REMOVING OWNER");
workflowdata["owner"] = ""; workflowdata["owner"] = "";
workflowdata["org"] = [];
workflowdata["org_id"] = "";
workflowdata["execution_org"] = {};
workflowdata["previously_saved"] = false;
// FIXME: Loop triggers and turn them off? // FIXME: Loop triggers and turn them off?
} }
@@ -2240,8 +2247,9 @@ const Workflows = (props) => {
if (tags !== undefined) { if (tags !== undefined) {
workflowdata["tags"] = tags; workflowdata["tags"] = tags;
} }
workflowdata["blogpost"] = inputblogpost
workflowdata["status"] = inputstatus workflowdata["blogpost"] = inputblogpost
workflowdata["status"] = inputstatus
if (defaultReturnValue !== undefined) { if (defaultReturnValue !== undefined) {
workflowdata["default_return_value"] = defaultReturnValue; workflowdata["default_return_value"] = defaultReturnValue;
@@ -2320,7 +2328,7 @@ const Workflows = (props) => {
if (file.type !== "application/json") { if (file.type !== "application/json") {
if (file.type !== undefined) { if (file.type !== undefined) {
toast("File has to contain valid json"); toast("File has to contain valid json");
setSubmitLoading(false) setSubmitLoading(false)
} }
continue; continue;
@@ -2338,7 +2346,7 @@ const Workflows = (props) => {
return; return;
} }
console.log("File being loaded: ", data.name); console.log("File being loaded: ", data.name);
// Initialize the workflow itself // Initialize the workflow itself
setNewWorkflow( setNewWorkflow(
@@ -2359,6 +2367,10 @@ const Workflows = (props) => {
data.first_save = false; data.first_save = false;
data.previously_saved = false; data.previously_saved = false;
data.is_valid = false; data.is_valid = false;
data.org_id = userdata.active_org.id
data.org = []
data.execution_org = {}
// Actually create it // Actually create it
setNewWorkflow( setNewWorkflow(
+1 -1
View File
@@ -7,7 +7,7 @@ go 1.19
require ( require (
github.com/docker/docker v23.0.3+incompatible github.com/docker/docker v23.0.3+incompatible
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.5.93 github.com/shuffle/shuffle-shared v0.5.98
k8s.io/api v0.28.1 k8s.io/api v0.28.1
k8s.io/apimachinery v0.28.1 k8s.io/apimachinery v0.28.1
k8s.io/client-go v0.28.1 k8s.io/client-go v0.28.1
+2
View File
@@ -350,6 +350,8 @@ github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shuffle/shuffle-shared v0.5.93 h1:fZf9s2cEgDoyYXXvPYVeNh8UysuSlywQkc54IXkNL0k= github.com/shuffle/shuffle-shared v0.5.93 h1:fZf9s2cEgDoyYXXvPYVeNh8UysuSlywQkc54IXkNL0k=
github.com/shuffle/shuffle-shared v0.5.93/go.mod h1:Lg6/+qjQlWzNKwj4/4ATpvScyP2JQGLkTPlNlRM6RJk= github.com/shuffle/shuffle-shared v0.5.93/go.mod h1:Lg6/+qjQlWzNKwj4/4ATpvScyP2JQGLkTPlNlRM6RJk=
github.com/shuffle/shuffle-shared v0.5.98 h1:0qG/1UZZVmY+wIJBuC9bnFjCITJBr7iKLG5ZibpBkTI=
github.com/shuffle/shuffle-shared v0.5.98/go.mod h1:Lg6/+qjQlWzNKwj4/4ATpvScyP2JQGLkTPlNlRM6RJk=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
+7 -2
View File
@@ -829,7 +829,7 @@ func deployWorker(image string, identifier string, env []string, executionReques
} }
if err != nil { if err != nil {
log.Printf("[ERROR] Failed to start worker container in environment %s: %s", environment, err) log.Printf("[ERROR] Failed to start worker container in environment '%s': %s", environment, err)
return err return err
} else { } else {
log.Printf("[INFO][%s] Worker Container created (2). Environment %s: docker logs %s", executionRequest.ExecutionId, environment, cont.ID) log.Printf("[INFO][%s] Worker Container created (2). Environment %s: docker logs %s", executionRequest.ExecutionId, environment, cont.ID)
@@ -1672,6 +1672,11 @@ func main() {
continue continue
} }
if len(execution.ExecutionId) == 0 {
log.Printf("[WARNING] Execution ID is empty: %#v", execution)
continue
}
if execution.Status == "ABORT" || execution.Status == "FAILED" { if execution.Status == "ABORT" || execution.Status == "FAILED" {
log.Printf("[INFO] Executionstatus issue: ", execution.Status) log.Printf("[INFO] Executionstatus issue: ", execution.Status)
} }
@@ -1767,7 +1772,7 @@ func main() {
toBeRemoved.Data = append(toBeRemoved.Data, execution) toBeRemoved.Data = append(toBeRemoved.Data, execution)
executionIds = append(executionIds, execution.ExecutionId) executionIds = append(executionIds, execution.ExecutionId)
} else { } else {
log.Printf("[WARNING] Execution ID %s failed to deploy: %s", execution.ExecutionId, err) log.Printf("[WARNING] Execution ID '%s' failed to deploy: %s", execution.ExecutionId, err)
} }
} }