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 = []
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_"):
self.logger.info("Bad length for file value %s" % item)
self.logger.info("Bad length for file value: '%s'" % item)
continue
#return {
# "filename": "",
+1 -3
View File
@@ -457,7 +457,7 @@ const CacheView = (props) => {
const validate = validateJson(data.value);
return (
<ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "hidden", }}>
<ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "auto", }}>
<ListItemText
style={{
maxWidth: 250,
@@ -470,8 +470,6 @@ const CacheView = (props) => {
style={{
minWidth: 400,
maxWidth: 400,
overflowX: "auto",
overflowY: "hidden",
}}
primary={validate.valid ?
<ReactJson
+1 -1
View File
@@ -59,7 +59,7 @@ const Files = (props) => {
const [downloadFolder, setDownloadFolder] = React.useState("translation_standards");
//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 = "";
const handleKeyDown = (event) => {
+14 -7
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) => {
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 {
const { subOrgs, parentOrg } = responseJson;
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) => {
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}
{isCloud ?
<Tooltip
title={`Organization is in ${regiontag}. Click to change!`}
style={{}}
title={`Your organization is in ${regiontag}. Click to change!`}
style={{
}}
>
<Avatar
style={{ top: -10, right: 50, position: "absolute", }}
style={{ cursor: "pointer", top: -10, right: 50, position: "absolute", }}
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}
@@ -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 }}
/>
<ListItemText
primary="Orborus label"
primary="Status"
style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
+79
View File
@@ -117,6 +117,7 @@ import {
Polyline as PolylineIcon,
QueryStats as QueryStatsIcon,
AutoAwesome as AutoAwesomeIcon,
Add as AddIcon,
} from "@mui/icons-material";
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 = () => {
if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) {
if (
@@ -13316,6 +13346,28 @@ const AngularWorkflow = (defaultprops) => {
}}
/>
)}
{/* 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}
{workflow.triggers[selectedTriggerIndex].parameters[2] !==
@@ -16202,11 +16254,13 @@ const AngularWorkflow = (defaultprops) => {
<Typography variant="body1">
<b>Env &nbsp;&nbsp;&nbsp;&nbsp;</b>
</Typography>
<Typography variant="body1" color="textSecondary" style={{color: "#f85a3e", cursor: "pointer", }} onClick={() => {
window.open("/admin?tab=environments", "_blank")
}}>
{executionData.workflow.actions[0].environment}
</Typography>
</div>
: null}
{executionData.status !== undefined &&
@@ -16877,6 +16931,30 @@ const AngularWorkflow = (defaultprops) => {
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
if (result.success !== false) {
@@ -16896,6 +16974,7 @@ const AngularWorkflow = (defaultprops) => {
return ""
}
try {
stringjson = JSON.stringify(result)
} catch (e) {
+22 -10
View File
@@ -1483,17 +1483,9 @@ const Workflows = (props) => {
const sanitizeWorkflow = (data) => {
data = JSON.parse(JSON.stringify(data));
data["owner"] = "";
console.log("Sanitize start: ", 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);
return data;
@@ -1508,14 +1500,24 @@ const Workflows = (props) => {
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) {
data = sanitizeWorkflow(data);
if (data.subflows !== null && data.subflows !== undefined) {
toast(
"Not exporting with subflows when sanitizing. Please manually export them."
);
data.subflows = [];
)
data.subflows = []
}
// for (var key in data.subflows) {
@@ -2220,6 +2222,7 @@ const Workflows = (props) => {
inputblogpost,
inputstatus,
) => {
var method = "POST";
var extraData = "";
var workflowdata = {};
@@ -2232,6 +2235,10 @@ const Workflows = (props) => {
console.log("REMOVING OWNER");
workflowdata["owner"] = "";
workflowdata["org"] = [];
workflowdata["org_id"] = "";
workflowdata["execution_org"] = {};
workflowdata["previously_saved"] = false;
// FIXME: Loop triggers and turn them off?
}
@@ -2240,6 +2247,7 @@ const Workflows = (props) => {
if (tags !== undefined) {
workflowdata["tags"] = tags;
}
workflowdata["blogpost"] = inputblogpost
workflowdata["status"] = inputstatus
@@ -2359,6 +2367,10 @@ const Workflows = (props) => {
data.first_save = false;
data.previously_saved = false;
data.is_valid = false;
data.org_id = userdata.active_org.id
data.org = []
data.execution_org = {}
// Actually create it
setNewWorkflow(
+1 -1
View File
@@ -7,7 +7,7 @@ go 1.19
require (
github.com/docker/docker v23.0.3+incompatible
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/apimachinery 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/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.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.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
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 {
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
} else {
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
}
if len(execution.ExecutionId) == 0 {
log.Printf("[WARNING] Execution ID is empty: %#v", execution)
continue
}
if execution.Status == "ABORT" || execution.Status == "FAILED" {
log.Printf("[INFO] Executionstatus issue: ", execution.Status)
}
@@ -1767,7 +1772,7 @@ func main() {
toBeRemoved.Data = append(toBeRemoved.Data, execution)
executionIds = append(executionIds, execution.ExecutionId)
} 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)
}
}