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 FRONTEND_PORT_HTTPS=3443
# CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS: # CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS:
OUTER_HOSTNAME=shuffle-backend 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. # Proxy configurations. SHUFFLE_PASS_WORKER_PROXY must be FALSE to not pass the proxy information to sub-apps.
# PS: It will skip proxy for # 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-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
github.com/frikky/kin-openapi v0.38.0 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/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.0.0 github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/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.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 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.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 h1:a6TQjTqwkyscC4/hShJX7WhCVE+4bi9lzw61XHQW5hE=
github.com/getkin/kin-openapi v0.8.0/go.mod h1:zZQMFkVgRHCdhgb6ihCTIo9dyDZFvX0k/xAKqw1FhPw= github.com/getkin/kin-openapi v0.8.0/go.mod h1:zZQMFkVgRHCdhgb6ihCTIo9dyDZFvX0k/xAKqw1FhPw=
github.com/getkin/kin-openapi v0.52.0 h1:6WqsF5d6PfJ8AscdD+9Rtb2RP2iBWyC7V6GcjssWg7M= github.com/getkin/kin-openapi v0.52.0 h1:6WqsF5d6PfJ8AscdD+9Rtb2RP2iBWyC7V6GcjssWg7M=
+5 -2
View File
@@ -1366,13 +1366,16 @@ func deleteWorkflow(resp http.ResponseWriter, request *http.Request) {
return return
} }
// FIXME - have a check for org etc too.. if user.Id != workflow.Owner || len(user.Id) == 0 {
if user.Id != workflow.Owner { 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) log.Printf("Wrong user (%s) for workflow %s", user.Username, workflow.ID)
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(`{"success": false}`)) resp.Write([]byte(`{"success": false}`))
return return
} }
}
// Clean up triggers and executions // Clean up triggers and executions
for _, item := range workflow.Triggers { for _, item := range workflow.Triggers {
+2 -2
View File
@@ -2,7 +2,7 @@ version: '3'
services: services:
frontend: frontend:
#build: ./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 container_name: shuffle-frontend
hostname: shuffle-frontend hostname: shuffle-frontend
ports: ports:
@@ -17,7 +17,7 @@ services:
- backend - backend
backend: backend:
#build: ./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 container_name: shuffle-backend
hostname: ${BACKEND_HOSTNAME} hostname: ${BACKEND_HOSTNAME}
# Here for debugging: # Here for debugging:
+14 -11
View File
@@ -373,7 +373,11 @@ const Admin = (props) => {
.then(response => .then(response =>
response.json().then(responseJson => { response.json().then(responseJson => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
if (responseJson.reason !== undefined) {
alert.error(responseJson.reason)
} else {
alert.error("Failed setting new password") alert.error("Failed setting new password")
}
} else { } else {
alert.success("Successfully updated password!") alert.success("Successfully updated password!")
setSelectedUserModalOpen(false) setSelectedUserModalOpen(false)
@@ -387,7 +391,7 @@ const Admin = (props) => {
const deleteUser = (data) => { const deleteUser = (data) => {
// Just use this one? // Just use this one?
const userId = isCloud ? data.username : data.id const userId = data.id
const url = globalUrl + '/api/v1/users/' + userId const url = globalUrl + '/api/v1/users/' + userId
fetch(url, { fetch(url, {
@@ -1076,7 +1080,6 @@ const Admin = (props) => {
const setUser = (userId, field, value) => { const setUser = (userId, field, value) => {
const data = { "user_id": userId } const data = { "user_id": userId }
data[field] = value data[field] = value
console.log("DATA: ", data)
fetch(globalUrl + "/api/v1/users/updateuser", { fetch(globalUrl + "/api/v1/users/updateuser", {
method: 'PUT', method: 'PUT',
@@ -1238,8 +1241,11 @@ 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> <DialogContent>
{isCloud ?
null
:
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<TextField <TextField
style={{ marginTop: 0, backgroundColor: theme.palette.inputColor, flex: 3 , marginRight: 10,}} style={{ marginTop: 0, backgroundColor: theme.palette.inputColor, flex: 3 , marginRight: 10,}}
@@ -1269,6 +1275,7 @@ const Admin = (props) => {
Submit Submit
</Button> </Button>
</div> </div>
}
<Divider style={{ marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor }} /> <Divider style={{ marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor }} />
<Button <Button
style={{}} style={{}}
@@ -1848,12 +1855,12 @@ const Admin = (props) => {
<ListItem> <ListItem>
<ListItemText <ListItemText
primary="Username" primary="Username"
style={{ minWidth: 300, maxWidth: 300}} style={{ minWidth: 350, maxWidth: 350}}
/> />
<ListItemText <ListItemText
primary="API key" primary="API key"
style={{ minWidth: 100, maxWidth: 100, overflow: "hidden" }} style={{ marginleft: 10, minWidth: 100, maxWidth: 100, overflow: "hidden" }}
/> />
<ListItemText <ListItemText
@@ -1879,11 +1886,11 @@ const Admin = (props) => {
<ListItem key={index} style={{backgroundColor: bgColor}}> <ListItem key={index} style={{backgroundColor: bgColor}}>
<ListItemText <ListItemText
primary={data.username} primary={data.username}
style={{ minWidth: 300, maxWidth: 300, overflow: "hidden",}} style={{ minWidth: 350, maxWidth: 350, overflow: "hidden",}}
/> />
<ListItemText <ListItemText
style={{ maxWidth: 100, minWidth: 100, }} style={{ marginLeft: 10, maxWidth: 100, minWidth: 100, }}
primary={data.apikey === undefined || data.apikey.length === 0 ? "" : primary={data.apikey === undefined || data.apikey.length === 0 ? "" :
<Tooltip title={"Copy Api Key"} style={{}} aria-label={"Copy APIkey"}> <Tooltip title={"Copy Api Key"} style={{}} aria-label={"Copy APIkey"}>
<IconButton style={{}} onClick={() => { <IconButton style={{}} onClick={() => {
@@ -1918,11 +1925,7 @@ const Admin = (props) => {
onChange={(e) => { onChange={(e) => {
console.log("VALUE: ", e.target.value) 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" }} style={{ backgroundColor: theme.palette.surfaceColor, color: "white", height: "50px" }}
> >
+2 -1
View File
@@ -785,6 +785,7 @@ const AngularWorkflow = (props) => {
// Errors are backend defined // Errors are backend defined
useworkflow.errors = [] useworkflow.errors = []
useworkflow.previously_saved = true
setLastSaved(true) setLastSaved(true)
fetch(globalUrl+"/api/v1/workflows/"+props.match.params.key, { fetch(globalUrl+"/api/v1/workflows/"+props.match.params.key, {
@@ -1170,7 +1171,7 @@ const AngularWorkflow = (props) => {
//console.log(responseJson) //console.log(responseJson)
// Add error checks // Add error checks
console.log(responseJson) console.log("Workflow: ", responseJson)
if (!responseJson.public) { if (!responseJson.public) {
if ((!responseJson.previously_saved || (!responseJson.is_valid || (responseJson.errors !== undefined || responseJson.errors !== null || responseJson.errors !== responseJson.errors.length > 0)))) { if ((!responseJson.previously_saved || (!responseJson.is_valid || (responseJson.errors !== undefined || responseJson.errors !== null || responseJson.errors !== responseJson.errors.length > 0)))) {
setConfigureWorkflowModalOpen(true) setConfigureWorkflowModalOpen(true)
+8 -1
View File
@@ -436,7 +436,14 @@ const AppCreator = (props) => {
setBasedata(data) setBasedata(data)
if (data.info !== null && data.info !== undefined) { if (data.info !== null && data.info !== undefined) {
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) setName(data.info.title)
}
}
setDescription(data.info.description) setDescription(data.info.description)
document.title = "Apps - "+data.info.title 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.") alert.error("Choose a shorter name.")
return return
} }