From 5c19b92b5030433788565b2abbc93a951a0a1e56 Mon Sep 17 00:00:00 2001 From: Paula-Kli Date: Tue, 17 Oct 2023 11:51:09 +0200 Subject: [PATCH] feat: Add user profile page --- backend/capellacollab/projects/routes.py | 34 ++++++++++++++++++ frontend/src/app/app-routing.module.ts | 6 ++++ frontend/src/app/app.module.ts | 2 ++ .../app/general/header/header.component.html | 10 +++++- .../project-user-settings.component.html | 8 +++-- .../app/projects/service/project.service.ts | 9 +++++ .../src/app/services/user/user.service.ts | 4 +++ .../users-profile/users-profile.component.css | 4 +++ .../users-profile.component.html | 25 +++++++++++++ .../users-profile/users-profile.component.ts | 36 +++++++++++++++++++ 10 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 frontend/src/app/users/users-profile/users-profile.component.css create mode 100644 frontend/src/app/users/users-profile/users-profile.component.html create mode 100644 frontend/src/app/users/users-profile/users-profile.component.ts diff --git a/backend/capellacollab/projects/routes.py b/backend/capellacollab/projects/routes.py index 34f703d1ef..3663068420 100644 --- a/backend/capellacollab/projects/routes.py +++ b/backend/capellacollab/projects/routes.py @@ -68,6 +68,40 @@ def get_projects( return projects +@router.get( + "/common/{user_id}", response_model=models.Project, tags=["Projects"] +) +def get_common_projects( + user_for_common_projects: users_models.DatabaseUser = fastapi.Depends( + users_injectables.get_existing_user + ), + user: users_models.DatabaseUser = fastapi.Depends( + users_injectables.get_own_user + ), + log: logging.LoggerAdapter = fastapi.Depends( + core_logging.get_request_logger + ), +) -> list[models.DatabaseProject]: + current_users_projects = [ + association.project + for association in user.projects + if not association.project.visibility == models.Visibility.INTERNAL + ] + projects_for_common = [ + association.project + for association in user_for_common_projects.projects + if not association.project.visibility == models.Visibility.INTERNAL + ] + + projects = [ + project + for project in current_users_projects + if project in projects_for_common + ] + log.info("Fetching the following projects: %s", projects) + return projects + + @router.patch( "/{project_slug}", response_model=models.Project, diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 5dc705859d..fc3bbef665 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -14,6 +14,7 @@ import { EditProjectMetadataComponent } from 'src/app/projects/project-detail/ed import { SessionComponent } from 'src/app/sessions/session/session.component'; import { PipelinesOverviewComponent } from 'src/app/settings/core/pipelines-overview/pipelines-overview.component'; import { BasicAuthTokenComponent } from 'src/app/users/basic-auth-token/basic-auth-token.component'; +import { UsersProfileComponent } from 'src/app/users/users-profile/users-profile.component'; import { EventsComponent } from './events/events.component'; import { AuthComponent } from './general/auth/auth/auth.component'; import { AuthGuardService } from './general/auth/auth-guard/auth-guard.service'; @@ -442,6 +443,11 @@ const routes: Routes = [ data: { breadcrumb: 'Events' }, component: EventsComponent, }, + { + path: 'user', + data: { breadcrumb: (data: Data) => data?.user?.name || 'User' }, + component: UsersProfileComponent, + }, { path: 'tokens', data: { breadcrumb: 'Tokens' }, diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 8715ca6a66..bb194e57ee 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -136,6 +136,7 @@ import { T4CRepoDeletionDialogComponent } from './settings/modelsources/t4c-sett import { T4CSettingsWrapperComponent } from './settings/modelsources/t4c-settings/t4c-settings-wrapper/t4c-settings-wrapper.component'; import { T4CSettingsComponent } from './settings/modelsources/t4c-settings/t4c-settings.component'; import { SettingsComponent } from './settings/settings.component'; +import { UsersProfileComponent } from './users/users-profile/users-profile.component'; @NgModule({ declarations: [ @@ -223,6 +224,7 @@ import { SettingsComponent } from './settings/settings.component'; TriggerPipelineComponent, UserSessionsWrapperComponent, UserSettingsComponent, + UsersProfileComponent, VersionComponent, ViewLogsDialogComponent, ], diff --git a/frontend/src/app/general/header/header.component.html b/frontend/src/app/general/header/header.component.html index 9c18f0a11f..8aeca41840 100644 --- a/frontend/src/app/general/header/header.component.html +++ b/frontend/src/app/general/header/header.component.html @@ -48,6 +48,14 @@ + + Profile account_circle + - Profile account_circle + Menu menu diff --git a/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.html b/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.html index 2e6fc39a5f..994c4ddd3b 100644 --- a/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.html +++ b/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.html @@ -50,7 +50,11 @@

Project members

) " > -
- +