Bugfixes to admin panel, workflow view and app creator

This commit is contained in:
frikky
2021-04-18 20:48:11 +02:00
parent 033124b6ec
commit 00323689e2
8 changed files with 71 additions and 55 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ FRONTEND_PORT=3001
FRONTEND_PORT_HTTPS=3443
# CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS:
OUTER_HOSTNAME=shuffle-backend
DB_LOCATION=./shuffle-database-new
DB_LOCATION=./shuffle-database
# Proxy configurations. SHUFFLE_PASS_WORKER_PROXY must be FALSE to not pass the proxy information to sub-apps.
# PS: It will skip proxy for
+1 -1
View File
@@ -20,7 +20,7 @@ require (
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/frikky/kin-openapi v0.38.0
github.com/frikky/shuffle-shared v0.0.28
github.com/frikky/shuffle-shared v0.0.32
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.0.0
+2
View File
@@ -104,6 +104,8 @@ github.com/frikky/shuffle-shared v0.0.27 h1:BbibbAv3a5GWR/DfaoSC4D9+fh2cwSEvn9H+
github.com/frikky/shuffle-shared v0.0.27/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ=
github.com/frikky/shuffle-shared v0.0.28 h1:VQqL3+ePwKSUxCOiCC8DpOEgbb2GhXI8XzFB/YlHbps=
github.com/frikky/shuffle-shared v0.0.28/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ=
github.com/frikky/shuffle-shared v0.0.32 h1:Uy/zcAetSVYtRr3HEkUb7aE7Ggm0oSFxVeUNsi6q4uc=
github.com/frikky/shuffle-shared v0.0.32/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ=
github.com/getkin/kin-openapi v0.8.0 h1:a6TQjTqwkyscC4/hShJX7WhCVE+4bi9lzw61XHQW5hE=
github.com/getkin/kin-openapi v0.8.0/go.mod h1:zZQMFkVgRHCdhgb6ihCTIo9dyDZFvX0k/xAKqw1FhPw=
github.com/getkin/kin-openapi v0.52.0 h1:6WqsF5d6PfJ8AscdD+9Rtb2RP2iBWyC7V6GcjssWg7M=
+9 -6
View File
@@ -1366,12 +1366,15 @@ func deleteWorkflow(resp http.ResponseWriter, request *http.Request) {
return
}
// FIXME - have a check for org etc too..
if user.Id != workflow.Owner {
log.Printf("Wrong user (%s) for workflow %s", user.Username, workflow.ID)
resp.WriteHeader(401)
resp.Write([]byte(`{"success": false}`))
return
if user.Id != workflow.Owner || len(user.Id) == 0 {
if workflow.OrgId == user.ActiveOrg.Id && user.Role == "admin" {
log.Printf("[INFO] User %s is deleting workflow %s as admin. Owner: %s", user.Username, workflow.ID, workflow.Owner)
} else {
log.Printf("Wrong user (%s) for workflow %s", user.Username, workflow.ID)
resp.WriteHeader(401)
resp.Write([]byte(`{"success": false}`))
return
}
}
// Clean up triggers and executions
+2 -2
View File
@@ -2,7 +2,7 @@ version: '3'
services:
frontend:
#build: ./frontend
image: ghcr.io/frikky/shuffle-frontend:0.8.73
image: ghcr.io/frikky/shuffle-frontend:0.8.74
container_name: shuffle-frontend
hostname: shuffle-frontend
ports:
@@ -17,7 +17,7 @@ services:
- backend
backend:
#build: ./backend
image: ghcr.io/frikky/shuffle-backend:0.8.73
image: ghcr.io/frikky/shuffle-backend:0.8.74
container_name: shuffle-backend
hostname: ${BACKEND_HOSTNAME}
# Here for debugging:
+45 -42
View File
@@ -373,7 +373,11 @@ const Admin = (props) => {
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
alert.error("Failed setting new password")
if (responseJson.reason !== undefined) {
alert.error(responseJson.reason)
} else {
alert.error("Failed setting new password")
}
} else {
alert.success("Successfully updated password!")
setSelectedUserModalOpen(false)
@@ -387,7 +391,7 @@ const Admin = (props) => {
const deleteUser = (data) => {
// Just use this one?
const userId = isCloud ? data.username : data.id
const userId = data.id
const url = globalUrl + '/api/v1/users/' + userId
fetch(url, {
@@ -1076,7 +1080,6 @@ const Admin = (props) => {
const setUser = (userId, field, value) => {
const data = { "user_id": userId }
data[field] = value
console.log("DATA: ", data)
fetch(globalUrl + "/api/v1/users/updateuser", {
method: 'PUT',
@@ -1238,37 +1241,41 @@ const Admin = (props) => {
},
}}
>
<DialogTitle><span style={{ color: "white" }}><EditIcon /> Edit user</span></DialogTitle>
<DialogTitle><span style={{ color: "white" }}><EditIcon style={{marginTop: 5}}/> Editing {selectedUser.username}</span></DialogTitle>
<DialogContent>
<div style={{ display: "flex" }}>
<TextField
style={{ marginTop: 0, backgroundColor: theme.palette.inputColor, flex: 3 , marginRight: 10,}}
InputProps={{
style: {
height: 50,
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="New password"
type="password"
id="standard-required"
autoComplete="password"
margin="normal"
variant="outlined"
onChange={e => setNewPassword(e.target.value)}
/>
<Button
style={{ maxHeight: 50, flex: 1 }}
variant="outlined"
color="primary"
onClick={() => onPasswordChange()}
>
Submit
</Button>
</div>
{isCloud ?
null
:
<div style={{ display: "flex" }}>
<TextField
style={{ marginTop: 0, backgroundColor: theme.palette.inputColor, flex: 3 , marginRight: 10,}}
InputProps={{
style: {
height: 50,
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="New password"
type="password"
id="standard-required"
autoComplete="password"
margin="normal"
variant="outlined"
onChange={e => setNewPassword(e.target.value)}
/>
<Button
style={{ maxHeight: 50, flex: 1 }}
variant="outlined"
color="primary"
onClick={() => onPasswordChange()}
>
Submit
</Button>
</div>
}
<Divider style={{ marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor }} />
<Button
style={{}}
@@ -1848,12 +1855,12 @@ const Admin = (props) => {
<ListItem>
<ListItemText
primary="Username"
style={{ minWidth: 300, maxWidth: 300}}
style={{ minWidth: 350, maxWidth: 350}}
/>
<ListItemText
primary="API key"
style={{ minWidth: 100, maxWidth: 100, overflow: "hidden" }}
style={{ marginleft: 10, minWidth: 100, maxWidth: 100, overflow: "hidden" }}
/>
<ListItemText
@@ -1879,11 +1886,11 @@ const Admin = (props) => {
<ListItem key={index} style={{backgroundColor: bgColor}}>
<ListItemText
primary={data.username}
style={{ minWidth: 300, maxWidth: 300, overflow: "hidden",}}
style={{ minWidth: 350, maxWidth: 350, overflow: "hidden",}}
/>
<ListItemText
style={{ maxWidth: 100, minWidth: 100, }}
style={{ marginLeft: 10, maxWidth: 100, minWidth: 100, }}
primary={data.apikey === undefined || data.apikey.length === 0 ? "" :
<Tooltip title={"Copy Api Key"} style={{}} aria-label={"Copy APIkey"}>
<IconButton style={{}} onClick={() => {
@@ -1918,11 +1925,7 @@ const Admin = (props) => {
onChange={(e) => {
console.log("VALUE: ", e.target.value)
if (isCloud) {
setUser(data.username, "role", e.target.value)
} else {
setUser(data.id, "role", e.target.value)
}
setUser(data.id, "role", e.target.value)
}}
style={{ backgroundColor: theme.palette.surfaceColor, color: "white", height: "50px" }}
>
+2 -1
View File
@@ -785,6 +785,7 @@ const AngularWorkflow = (props) => {
// Errors are backend defined
useworkflow.errors = []
useworkflow.previously_saved = true
setLastSaved(true)
fetch(globalUrl+"/api/v1/workflows/"+props.match.params.key, {
@@ -1170,7 +1171,7 @@ const AngularWorkflow = (props) => {
//console.log(responseJson)
// Add error checks
console.log(responseJson)
console.log("Workflow: ", responseJson)
if (!responseJson.public) {
if ((!responseJson.previously_saved || (!responseJson.is_valid || (responseJson.errors !== undefined || responseJson.errors !== null || responseJson.errors !== responseJson.errors.length > 0)))) {
setConfigureWorkflowModalOpen(true)
+9 -2
View File
@@ -436,7 +436,14 @@ const AppCreator = (props) => {
setBasedata(data)
if (data.info !== null && data.info !== undefined) {
setName(data.info.title)
if (data.info.title !== undefined && data.info.title !== null) {
if (data.info.title.length > 29) {
setName(data.info.title.slice(0, 29))
} else {
setName(data.info.title)
}
}
setDescription(data.info.description)
document.title = "Apps - "+data.info.title
@@ -2500,7 +2507,7 @@ const AppCreator = (props) => {
}
}
if (e.target.value.length > 100) {
if (e.target.value.length > 29) {
alert.error("Choose a shorter name.")
return
}