diff --git a/api/schema.graphqls b/api/schema.graphqls index f05ed16..13b2887 100644 --- a/api/schema.graphqls +++ b/api/schema.graphqls @@ -161,7 +161,6 @@ type Count { type User { username: String! name: String! - project: String email: String! } diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index 2b22169..959306d 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -72,7 +72,7 @@ func main() { 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.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`") - flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: `:[admin,support,api,user]:`") + flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: `:[admin,support,manager,api,user]:`") 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(&flagImportJob, "import-job", "", "Import a job. Argument format: `:,...`") @@ -141,9 +141,8 @@ func main() { log.Fatal("invalid argument format for user creation") } - var emptyPrj []string 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 { log.Fatalf("adding '%s' user authentication failed: %v", parts[0], err) } diff --git a/internal/auth/users.go b/internal/auth/users.go index 133307a..38c1e11 100644 --- a/internal/auth/users.go +++ b/internal/auth/users.go @@ -169,7 +169,7 @@ func (auth *Authentication) RemoveRole(ctx context.Context, username string, rol } 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 diff --git a/internal/graph/generated/generated.go b/internal/graph/generated/generated.go index cd23b5e..5b82186 100644 --- a/internal/graph/generated/generated.go +++ b/internal/graph/generated/generated.go @@ -256,7 +256,6 @@ type ComplexityRoot struct { User struct { Email func(childComplexity int) int Name func(childComplexity int) int - Project 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 - case "User.project": - if e.complexity.User.Project == nil { - break - } - - return e.complexity.User.Project(childComplexity), true - case "User.username": if e.complexity.User.Username == nil { break @@ -1560,7 +1552,6 @@ type Count { type User { username: String! name: String! - project: String email: String! } @@ -3904,8 +3895,6 @@ func (ec *executionContext) fieldContext_Job_userData(ctx context.Context, field return ec.fieldContext_User_username(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) - case "project": - return ec.fieldContext_User_project(ctx, field) case "email": 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) case "name": return ec.fieldContext_User_name(ctx, field) - case "project": - return ec.fieldContext_User_project(ctx, field) case "email": 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 } -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) { fc, err := ec.fieldContext_User_email(ctx, field) if err != nil { @@ -12444,10 +12390,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalids++ } - case "project": - - out.Values[i] = ec._User_project(ctx, field, obj) - case "email": out.Values[i] = ec._User_email(ctx, field, obj) diff --git a/internal/graph/model/models_gen.go b/internal/graph/model/models_gen.go index aacaae7..0828b88 100644 --- a/internal/graph/model/models_gen.go +++ b/internal/graph/model/models_gen.go @@ -116,10 +116,9 @@ type TimeRangeOutput struct { } type User struct { - Username string `json:"username"` - Name string `json:"name"` - Project *string `json:"project"` - Email string `json:"email"` + Username string `json:"username"` + Name string `json:"name"` + Email string `json:"email"` } type Aggregate string diff --git a/internal/repository/migrations/mysql/01_init-schema.down.sql b/internal/repository/migrations/mysql/01_init-schema.down.sql index 58617e1..68da646 100644 --- a/internal/repository/migrations/mysql/01_init-schema.down.sql +++ b/internal/repository/migrations/mysql/01_init-schema.down.sql @@ -2,4 +2,4 @@ DROP TABLE IF EXISTS job; DROP TABLE IF EXISTS tags; DROP TABLE IF EXISTS jobtag; DROP TABLE IF EXISTS configuration; -DROP TABLE IF EXISTS user; \ No newline at end of file +DROP TABLE IF EXISTS user; diff --git a/internal/repository/migrations/mysql/02_add-index.down.sql b/internal/repository/migrations/mysql/02_add-index.down.sql index 6c67b45..8129772 100644 --- a/internal/repository/migrations/mysql/02_add-index.down.sql +++ b/internal/repository/migrations/mysql/02_add-index.down.sql @@ -2,4 +2,4 @@ DROP INDEX IF EXISTS job_stats; DROP INDEX IF EXISTS job_by_user; DROP INDEX IF EXISTS job_by_starttime; DROP INDEX IF EXISTS job_by_job_id; -DROP INDEX IF EXISTS job_by_state; \ No newline at end of file +DROP INDEX IF EXISTS job_by_state; diff --git a/internal/repository/migrations/mysql/02_add-index.up.sql b/internal/repository/migrations/mysql/02_add-index.up.sql index ed7d79f..7d8d04a 100644 --- a/internal/repository/migrations/mysql/02_add-index.up.sql +++ b/internal/repository/migrations/mysql/02_add-index.up.sql @@ -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_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_state ON job (job_state); \ No newline at end of file +CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state); diff --git a/internal/repository/migrations/mysql/03_add-userprojects.down.sql b/internal/repository/migrations/mysql/03_add-userprojects.down.sql index a6d5b37..bbf1e64 100644 --- a/internal/repository/migrations/mysql/03_add-userprojects.down.sql +++ b/internal/repository/migrations/mysql/03_add-userprojects.down.sql @@ -1 +1 @@ -ALTER TABLE user DROP COLUMN projects; \ No newline at end of file +ALTER TABLE user DROP COLUMN projects; diff --git a/internal/repository/migrations/mysql/03_add-userprojects.up.sql b/internal/repository/migrations/mysql/03_add-userprojects.up.sql index 003cafd..d0f19c2 100644 --- a/internal/repository/migrations/mysql/03_add-userprojects.up.sql +++ b/internal/repository/migrations/mysql/03_add-userprojects.up.sql @@ -1 +1 @@ -ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]"; \ No newline at end of file +ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]"; diff --git a/internal/repository/migrations/sqlite3/01_init-schema.down.sql b/internal/repository/migrations/sqlite3/01_init-schema.down.sql index 58617e1..68da646 100644 --- a/internal/repository/migrations/sqlite3/01_init-schema.down.sql +++ b/internal/repository/migrations/sqlite3/01_init-schema.down.sql @@ -2,4 +2,4 @@ DROP TABLE IF EXISTS job; DROP TABLE IF EXISTS tags; DROP TABLE IF EXISTS jobtag; DROP TABLE IF EXISTS configuration; -DROP TABLE IF EXISTS user; \ No newline at end of file +DROP TABLE IF EXISTS user; diff --git a/internal/repository/migrations/sqlite3/02_add-index.down.sql b/internal/repository/migrations/sqlite3/02_add-index.down.sql index 6c67b45..8129772 100644 --- a/internal/repository/migrations/sqlite3/02_add-index.down.sql +++ b/internal/repository/migrations/sqlite3/02_add-index.down.sql @@ -2,4 +2,4 @@ DROP INDEX IF EXISTS job_stats; DROP INDEX IF EXISTS job_by_user; DROP INDEX IF EXISTS job_by_starttime; DROP INDEX IF EXISTS job_by_job_id; -DROP INDEX IF EXISTS job_by_state; \ No newline at end of file +DROP INDEX IF EXISTS job_by_state; diff --git a/internal/repository/migrations/sqlite3/02_add-index.up.sql b/internal/repository/migrations/sqlite3/02_add-index.up.sql index ed7d79f..7d8d04a 100644 --- a/internal/repository/migrations/sqlite3/02_add-index.up.sql +++ b/internal/repository/migrations/sqlite3/02_add-index.up.sql @@ -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_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_state ON job (job_state); \ No newline at end of file +CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state); diff --git a/internal/repository/migrations/sqlite3/03_add-userprojects.down.sql b/internal/repository/migrations/sqlite3/03_add-userprojects.down.sql index a6d5b37..bbf1e64 100644 --- a/internal/repository/migrations/sqlite3/03_add-userprojects.down.sql +++ b/internal/repository/migrations/sqlite3/03_add-userprojects.down.sql @@ -1 +1 @@ -ALTER TABLE user DROP COLUMN projects; \ No newline at end of file +ALTER TABLE user DROP COLUMN projects; diff --git a/internal/repository/migrations/sqlite3/03_add-userprojects.up.sql b/internal/repository/migrations/sqlite3/03_add-userprojects.up.sql index 003cafd..d0f19c2 100644 --- a/internal/repository/migrations/sqlite3/03_add-userprojects.up.sql +++ b/internal/repository/migrations/sqlite3/03_add-userprojects.up.sql @@ -1 +1 @@ -ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]"; \ No newline at end of file +ALTER TABLE user ADD COLUMN projects varchar(255) NOT NULL DEFAULT "[]"; diff --git a/web/frontend/src/Header.svelte b/web/frontend/src/Header.svelte index 0500862..3fbed14 100644 --- a/web/frontend/src/Header.svelte +++ b/web/frontend/src/Header.svelte @@ -92,7 +92,7 @@
- ' ..."} name="searchId"/> + = 4) ? "Example: 'projectId:a100cd', Types are: jobId | jobName | projectId | username | name" : "Example: 'jobName:myjob', Types are jobId | jobName | projectId"}> diff --git a/web/frontend/src/filters/UserOrProject.svelte b/web/frontend/src/filters/UserOrProject.svelte index fa5d123..7e29fcc 100644 --- a/web/frontend/src/filters/UserOrProject.svelte +++ b/web/frontend/src/filters/UserOrProject.svelte @@ -72,4 +72,4 @@ {:else} Unauthorized -{/if} \ No newline at end of file +{/if}