Fixed app creation, RE: json issue
This commit is contained in:
@@ -339,14 +339,7 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
|||||||
bodyAddin = ", data=body"
|
bodyAddin = ", data=body"
|
||||||
|
|
||||||
// FIXME: Does JSON data work?
|
// FIXME: Does JSON data work?
|
||||||
bodyFormatter = `
|
bodyFormatter = `body = " ".join(body.strip().split())`
|
||||||
if (body.startswith("{") and body.endswith("}")) or (body.startswith("[") and body.endswith("]")):
|
|
||||||
try:
|
|
||||||
body = json.dumps(body)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
`
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,13 +368,14 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
|||||||
|
|
||||||
// Extra param for url if it's changeable
|
// Extra param for url if it's changeable
|
||||||
// Extra param for authentication scheme(s)
|
// Extra param for authentication scheme(s)
|
||||||
|
// The last weird one is the body.. Tabs & spaces sucks.
|
||||||
data := fmt.Sprintf(` async def %s(self%s%s%s%s%s%s):
|
data := fmt.Sprintf(` async def %s(self%s%s%s%s%s%s):
|
||||||
%s
|
%s
|
||||||
url=f"%s%s"
|
url=f"%s%s"
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
return requests.%s(url, headers=headers%s%s%s).text
|
return requests.%s(url, headers=headers%s%s%s).text
|
||||||
`,
|
`,
|
||||||
functionname,
|
functionname,
|
||||||
|
|||||||
+13
-1
@@ -161,6 +161,7 @@ type User struct {
|
|||||||
Verified bool `datastore:"verified,noindex" json:"verified"`
|
Verified bool `datastore:"verified,noindex" json:"verified"`
|
||||||
PrivateApps []WorkflowApp `datastore:"privateapps" json:"privateapps":`
|
PrivateApps []WorkflowApp `datastore:"privateapps" json:"privateapps":`
|
||||||
Role string `datastore:"role" json:"role"`
|
Role string `datastore:"role" json:"role"`
|
||||||
|
Roles []string `datastore:"roles" json:"roles"`
|
||||||
VerificationToken string `datastore:"verification_token" json:"verification_token"`
|
VerificationToken string `datastore:"verification_token" json:"verification_token"`
|
||||||
ApiKey string `datastore:"apikey" json:"apikey"`
|
ApiKey string `datastore:"apikey" json:"apikey"`
|
||||||
ResetReference string `datastore:"reset_reference" json:"reset_reference"`
|
ResetReference string `datastore:"reset_reference" json:"reset_reference"`
|
||||||
@@ -169,7 +170,7 @@ type User struct {
|
|||||||
Authentication []UserAuth `datastore:"authentication,noindex" json:"authentication"`
|
Authentication []UserAuth `datastore:"authentication,noindex" json:"authentication"`
|
||||||
ResetTimeout int64 `datastore:"reset_timeout,noindex" json:"reset_timeout"`
|
ResetTimeout int64 `datastore:"reset_timeout,noindex" json:"reset_timeout"`
|
||||||
Id string `datastore:"id" json:"id"`
|
Id string `datastore:"id" json:"id"`
|
||||||
Orgs string `datastore:"orgs" json:"orgs"`
|
Orgs []string `datastore:"orgs" json:"orgs"`
|
||||||
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
||||||
Active bool `datastore:"active" json:"active"`
|
Active bool `datastore:"active" json:"active"`
|
||||||
}
|
}
|
||||||
@@ -1077,12 +1078,15 @@ func handleRegister(resp http.ResponseWriter, request *http.Request) {
|
|||||||
newUser.Verified = false
|
newUser.Verified = false
|
||||||
newUser.CreationTime = time.Now().Unix()
|
newUser.CreationTime = time.Now().Unix()
|
||||||
newUser.Active = true
|
newUser.Active = true
|
||||||
|
newUser.Orgs = []string{"default"}
|
||||||
|
|
||||||
// FIXME - Remove this later
|
// FIXME - Remove this later
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
newUser.Role = "admin"
|
newUser.Role = "admin"
|
||||||
|
newUser.Roles = []string{"admin"}
|
||||||
} else {
|
} else {
|
||||||
newUser.Role = "user"
|
newUser.Role = "user"
|
||||||
|
newUser.Roles = []string{"user"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set limits
|
// set limits
|
||||||
@@ -5953,6 +5957,14 @@ func runInit(ctx context.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(user.Role) > 0 {
|
||||||
|
user.Roles = append(user.Roles, user.Role)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Orgs) == 0 {
|
||||||
|
user.Orgs = []string{"default"}
|
||||||
|
}
|
||||||
|
|
||||||
err = setUser(ctx, &user)
|
err = setUser(ctx, &user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to reset user")
|
log.Printf("Failed to reset user")
|
||||||
|
|||||||
@@ -2923,8 +2923,8 @@ func getWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.Printf("%#v", parsedApi)
|
// log.Printf("%#v", parsedApi)
|
||||||
log.Printf("API LEN: %d, ID: %s", len(parsedApi.Body), fileId)
|
// log.Printf("API LEN: %d, ID: %s", len(parsedApi.Body), fileId)
|
||||||
|
|
||||||
//log.Printf("Parsed API: %#v", parsedApi)
|
//log.Printf("Parsed API: %#v", parsedApi)
|
||||||
if len(parsedApi.ID) > 0 {
|
if len(parsedApi.ID) > 0 {
|
||||||
|
|||||||
+28
-3
@@ -31,6 +31,7 @@ const Admin = (props) => {
|
|||||||
const [users, setUsers] = React.useState([]);
|
const [users, setUsers] = React.useState([]);
|
||||||
const [environments, setEnvironments] = React.useState([]);
|
const [environments, setEnvironments] = React.useState([]);
|
||||||
const [schedules, setSchedules] = React.useState([])
|
const [schedules, setSchedules] = React.useState([])
|
||||||
|
const [selectedUser, setSelectedUser] = React.useState({})
|
||||||
|
|
||||||
const alert = useAlert()
|
const alert = useAlert()
|
||||||
|
|
||||||
@@ -286,6 +287,22 @@ const Admin = (props) => {
|
|||||||
modalUser[field] = value
|
modalUser[field] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const editUserModal =
|
||||||
|
<Dialog modal
|
||||||
|
open={modalOpen}
|
||||||
|
onClose={() => {setModalOpen(false)}}
|
||||||
|
PaperProps={{
|
||||||
|
style: {
|
||||||
|
backgroundColor: surfaceColor,
|
||||||
|
color: "white",
|
||||||
|
minWidth: "800px",
|
||||||
|
minHeight: "320px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogTitle><span style={{color: "white"}}>Add user</span></DialogTitle>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
const modalView =
|
const modalView =
|
||||||
<Dialog modal
|
<Dialog modal
|
||||||
open={modalOpen}
|
open={modalOpen}
|
||||||
@@ -452,17 +469,24 @@ const Admin = (props) => {
|
|||||||
<ListItemText
|
<ListItemText
|
||||||
primary={data.active ? "True" : "False"}
|
primary={data.active ? "True" : "False"}
|
||||||
style={{minWidth: 180, maxWidth: 180}}
|
style={{minWidth: 180, maxWidth: 180}}
|
||||||
onClick={() => console.log("Should set user to active")}
|
|
||||||
/>
|
/>
|
||||||
<ListItemText>
|
<ListItemText style={{display: "flex"}}>
|
||||||
<Button
|
<Button
|
||||||
style={{}}
|
style={{}}
|
||||||
variant="contained"
|
variant="outlined"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => deleteUser(data)}
|
onClick={() => deleteUser(data)}
|
||||||
>
|
>
|
||||||
{data.active ? "Deactivate" : "Activate"}
|
{data.active ? "Deactivate" : "Activate"}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
style={{}}
|
||||||
|
variant="outlined"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => deleteUser(data)}
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)
|
)
|
||||||
@@ -581,6 +605,7 @@ const Admin = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{modalView}
|
{modalView}
|
||||||
|
{editUserModal}
|
||||||
{data}
|
{data}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -639,7 +639,7 @@ const AppCreator = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.body.length > 0) {
|
if (item.body !== undefined && item.body.length > 0) {
|
||||||
const required = false
|
const required = false
|
||||||
newitem = {
|
newitem = {
|
||||||
"in": "body",
|
"in": "body",
|
||||||
@@ -1525,7 +1525,7 @@ const AppCreator = (props) => {
|
|||||||
// <img src={file} id="logo" style={{width: "100%", height: "100%"}} />
|
// <img src={file} id="logo" style={{width: "100%", height: "100%"}} />
|
||||||
|
|
||||||
const imageData = file.length > 0 ? file : fileBase64
|
const imageData = file.length > 0 ? file : fileBase64
|
||||||
const imageInfo = <img src={imageData} alt="Click to upload an image" id="logo" style={{maxWidth: 174, maxHeight: 174,}} />
|
const imageInfo = <img src={imageData} alt="Click to upload an image (174x174)" id="logo" style={{maxWidth: 174, maxHeight: 174,}} />
|
||||||
|
|
||||||
// Random names for type & autoComplete. Didn't research :^)
|
// Random names for type & autoComplete. Didn't research :^)
|
||||||
const landingpageDataBrowser =
|
const landingpageDataBrowser =
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ const Settings = (props) => {
|
|||||||
<div style={{display: "flex", marginTop: "80px"}}>
|
<div style={{display: "flex", marginTop: "80px"}}>
|
||||||
<Paper style={boxStyle}>
|
<Paper style={boxStyle}>
|
||||||
<h2>APIKEY</h2>
|
<h2>APIKEY</h2>
|
||||||
<Link to="/docs/api#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is the API key used for?</Link>
|
<Link to="/docs/API#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is the API key used for?</Link>
|
||||||
<TextField
|
<TextField
|
||||||
style={{backgroundColor: inputColor, flex: "1"}}
|
style={{backgroundColor: inputColor, flex: "1"}}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
|
|||||||
Reference in New Issue
Block a user