mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-13 02:17:25 +01:00
Small fixes after full file review
- Remove unnecessary field 'project' from GQl and regenerate - Add newlines to file ends - Fix command-line manager user addition
This commit is contained in:
parent
a7d2d2666a
commit
8bd72ce807
@ -161,7 +161,6 @@ type Count {
|
|||||||
type User {
|
type User {
|
||||||
username: String!
|
username: String!
|
||||||
name: String!
|
name: String!
|
||||||
project: String
|
|
||||||
email: String!
|
email: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func main() {
|
|||||||
flag.BoolVar(&flagMigrateDB, "migrate-db", false, "Migrate database to supported version and exit")
|
flag.BoolVar(&flagMigrateDB, "migrate-db", false, "Migrate database to supported version and exit")
|
||||||
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
|
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
|
||||||
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
|
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
|
||||||
flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: `<username>:[admin,support,api,user]:<password>`")
|
flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: `<username>:[admin,support,manager,api,user]:<password>`")
|
||||||
flag.StringVar(&flagDelUser, "del-user", "", "Remove user by `username`")
|
flag.StringVar(&flagDelUser, "del-user", "", "Remove user by `username`")
|
||||||
flag.StringVar(&flagGenJWT, "jwt", "", "Generate and print a JWT for the user specified by its `username`")
|
flag.StringVar(&flagGenJWT, "jwt", "", "Generate and print a JWT for the user specified by its `username`")
|
||||||
flag.StringVar(&flagImportJob, "import-job", "", "Import a job. Argument format: `<path-to-meta.json>:<path-to-data.json>,...`")
|
flag.StringVar(&flagImportJob, "import-job", "", "Import a job. Argument format: `<path-to-meta.json>:<path-to-data.json>,...`")
|
||||||
@ -141,9 +141,8 @@ func main() {
|
|||||||
log.Fatal("invalid argument format for user creation")
|
log.Fatal("invalid argument format for user creation")
|
||||||
}
|
}
|
||||||
|
|
||||||
var emptyPrj []string
|
|
||||||
if err := authentication.AddUser(&auth.User{
|
if err := authentication.AddUser(&auth.User{
|
||||||
Username: parts[0], Projects: emptyPrj, Password: parts[2], Roles: strings.Split(parts[1], ","),
|
Username: parts[0], Projects: make([]string, 0), Password: parts[2], Roles: strings.Split(parts[1], ","),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Fatalf("adding '%s' user authentication failed: %v", parts[0], err)
|
log.Fatalf("adding '%s' user authentication failed: %v", parts[0], err)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func (auth *Authentication) RemoveRole(ctx context.Context, username string, rol
|
|||||||
}
|
}
|
||||||
|
|
||||||
if role == RoleManager && len(user.Projects) != 0 {
|
if role == RoleManager && len(user.Projects) != 0 {
|
||||||
return fmt.Errorf("Cannot remove role 'manager' while user %s still has an assigned project(s) : %v", username, user.Projects)
|
return fmt.Errorf("Cannot remove role 'manager' while user %s still has assigned project(s) : %v", username, user.Projects)
|
||||||
}
|
}
|
||||||
|
|
||||||
var exists bool
|
var exists bool
|
||||||
|
@ -256,7 +256,6 @@ type ComplexityRoot struct {
|
|||||||
User struct {
|
User struct {
|
||||||
Email func(childComplexity int) int
|
Email func(childComplexity int) int
|
||||||
Name func(childComplexity int) int
|
Name func(childComplexity int) int
|
||||||
Project func(childComplexity int) int
|
|
||||||
Username func(childComplexity int) int
|
Username func(childComplexity int) int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1308,13 +1307,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.User.Name(childComplexity), true
|
return e.complexity.User.Name(childComplexity), true
|
||||||
|
|
||||||
case "User.project":
|
|
||||||
if e.complexity.User.Project == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.User.Project(childComplexity), true
|
|
||||||
|
|
||||||
case "User.username":
|
case "User.username":
|
||||||
if e.complexity.User.Username == nil {
|
if e.complexity.User.Username == nil {
|
||||||
break
|
break
|
||||||
@ -1560,7 +1552,6 @@ type Count {
|
|||||||
type User {
|
type User {
|
||||||
username: String!
|
username: String!
|
||||||
name: String!
|
name: String!
|
||||||
project: String
|
|
||||||
email: String!
|
email: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3904,8 +3895,6 @@ func (ec *executionContext) fieldContext_Job_userData(ctx context.Context, field
|
|||||||
return ec.fieldContext_User_username(ctx, field)
|
return ec.fieldContext_User_username(ctx, field)
|
||||||
case "name":
|
case "name":
|
||||||
return ec.fieldContext_User_name(ctx, field)
|
return ec.fieldContext_User_name(ctx, field)
|
||||||
case "project":
|
|
||||||
return ec.fieldContext_User_project(ctx, field)
|
|
||||||
case "email":
|
case "email":
|
||||||
return ec.fieldContext_User_email(ctx, field)
|
return ec.fieldContext_User_email(ctx, field)
|
||||||
}
|
}
|
||||||
@ -6049,8 +6038,6 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g
|
|||||||
return ec.fieldContext_User_username(ctx, field)
|
return ec.fieldContext_User_username(ctx, field)
|
||||||
case "name":
|
case "name":
|
||||||
return ec.fieldContext_User_name(ctx, field)
|
return ec.fieldContext_User_name(ctx, field)
|
||||||
case "project":
|
|
||||||
return ec.fieldContext_User_project(ctx, field)
|
|
||||||
case "email":
|
case "email":
|
||||||
return ec.fieldContext_User_email(ctx, field)
|
return ec.fieldContext_User_email(ctx, field)
|
||||||
}
|
}
|
||||||
@ -8543,47 +8530,6 @@ func (ec *executionContext) fieldContext_User_name(ctx context.Context, field gr
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _User_project(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
|
|
||||||
fc, err := ec.fieldContext_User_project(ctx, field)
|
|
||||||
if err != nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
ret = graphql.Null
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
||||||
ctx = rctx // use context from middleware stack in children
|
|
||||||
return obj.Project, nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ec.Error(ctx, err)
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
if resTmp == nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
res := resTmp.(*string)
|
|
||||||
fc.Result = res
|
|
||||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_User_project(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
||||||
fc = &graphql.FieldContext{
|
|
||||||
Object: "User",
|
|
||||||
Field: field,
|
|
||||||
IsMethod: false,
|
|
||||||
IsResolver: false,
|
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
||||||
return nil, errors.New("field of type String does not have child fields")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return fc, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
|
func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_User_email(ctx, field)
|
fc, err := ec.fieldContext_User_email(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -12444,10 +12390,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
|
|||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
case "project":
|
|
||||||
|
|
||||||
out.Values[i] = ec._User_project(ctx, field, obj)
|
|
||||||
|
|
||||||
case "email":
|
case "email":
|
||||||
|
|
||||||
out.Values[i] = ec._User_email(ctx, field, obj)
|
out.Values[i] = ec._User_email(ctx, field, obj)
|
||||||
|
@ -116,10 +116,9 @@ type TimeRangeOutput struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Project *string `json:"project"`
|
Email string `json:"email"`
|
||||||
Email string `json:"email"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Aggregate string
|
type Aggregate string
|
||||||
|
@ -2,4 +2,4 @@ DROP TABLE IF EXISTS job;
|
|||||||
DROP TABLE IF EXISTS tags;
|
DROP TABLE IF EXISTS tags;
|
||||||
DROP TABLE IF EXISTS jobtag;
|
DROP TABLE IF EXISTS jobtag;
|
||||||
DROP TABLE IF EXISTS configuration;
|
DROP TABLE IF EXISTS configuration;
|
||||||
DROP TABLE IF EXISTS user;
|
DROP TABLE IF EXISTS user;
|
||||||
|
@ -2,4 +2,4 @@ DROP INDEX IF EXISTS job_stats;
|
|||||||
DROP INDEX IF EXISTS job_by_user;
|
DROP INDEX IF EXISTS job_by_user;
|
||||||
DROP INDEX IF EXISTS job_by_starttime;
|
DROP INDEX IF EXISTS job_by_starttime;
|
||||||
DROP INDEX IF EXISTS job_by_job_id;
|
DROP INDEX IF EXISTS job_by_job_id;
|
||||||
DROP INDEX IF EXISTS job_by_state;
|
DROP INDEX IF EXISTS job_by_state;
|
||||||
|
@ -2,4 +2,4 @@ CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user);
|
|||||||
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id);
|
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state);
|
CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state);
|
||||||
|
@ -1 +1 @@
|
|||||||
ALTER TABLE user DROP COLUMN projects;
|
ALTER TABLE user DROP COLUMN projects;
|
||||||
|
@ -1 +1 @@
|
|||||||
ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]";
|
ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]";
|
||||||
|
@ -2,4 +2,4 @@ DROP TABLE IF EXISTS job;
|
|||||||
DROP TABLE IF EXISTS tags;
|
DROP TABLE IF EXISTS tags;
|
||||||
DROP TABLE IF EXISTS jobtag;
|
DROP TABLE IF EXISTS jobtag;
|
||||||
DROP TABLE IF EXISTS configuration;
|
DROP TABLE IF EXISTS configuration;
|
||||||
DROP TABLE IF EXISTS user;
|
DROP TABLE IF EXISTS user;
|
||||||
|
@ -2,4 +2,4 @@ DROP INDEX IF EXISTS job_stats;
|
|||||||
DROP INDEX IF EXISTS job_by_user;
|
DROP INDEX IF EXISTS job_by_user;
|
||||||
DROP INDEX IF EXISTS job_by_starttime;
|
DROP INDEX IF EXISTS job_by_starttime;
|
||||||
DROP INDEX IF EXISTS job_by_job_id;
|
DROP INDEX IF EXISTS job_by_job_id;
|
||||||
DROP INDEX IF EXISTS job_by_state;
|
DROP INDEX IF EXISTS job_by_state;
|
||||||
|
@ -2,4 +2,4 @@ CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user);
|
|||||||
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id);
|
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id);
|
||||||
CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state);
|
CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state);
|
||||||
|
@ -1 +1 @@
|
|||||||
ALTER TABLE user DROP COLUMN projects;
|
ALTER TABLE user DROP COLUMN projects;
|
||||||
|
@ -1 +1 @@
|
|||||||
ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]";
|
ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]";
|
||||||
|
@ -92,7 +92,7 @@
|
|||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<form method="GET" action="/search">
|
<form method="GET" action="/search">
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<Input type="text" placeholder={"Search 'type:<query>' ..."} name="searchId"/>
|
<Input type="text" placeholder="Search 'type:<query>' ..." name="searchId"/>
|
||||||
<Button outline type="submit"><Icon name="search"/></Button>
|
<Button outline type="submit"><Icon name="search"/></Button>
|
||||||
<InputGroupText style="cursor:help;" title={(authlevel >= 4) ? "Example: 'projectId:a100cd', Types are: jobId | jobName | projectId | username | name" : "Example: 'jobName:myjob', Types are jobId | jobName | projectId"}><Icon name="info-circle"/></InputGroupText>
|
<InputGroupText style="cursor:help;" title={(authlevel >= 4) ? "Example: 'projectId:a100cd', Types are: jobId | jobName | projectId | username | name" : "Example: 'jobName:myjob', Types are jobId | jobName | projectId"}><Icon name="info-circle"/></InputGroupText>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
@ -72,4 +72,4 @@
|
|||||||
</InputGroup>
|
</InputGroup>
|
||||||
{:else}
|
{:else}
|
||||||
Unauthorized
|
Unauthorized
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user