-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users can now look at common projects with another user or have a look at their personal profile page.
- Loading branch information
Showing
11 changed files
with
185 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
from fastapi import testclient | ||
from sqlalchemy import orm | ||
|
||
import capellacollab.projects.users.models as projects_users_models | ||
from capellacollab.projects import models as projects_models | ||
from capellacollab.projects.users import crud as projects_users_crud | ||
from capellacollab.users import crud as users_crud | ||
from capellacollab.users import models as users_models | ||
|
||
|
||
@pytest.mark.usefixtures("user") | ||
def test_get_no_common_projects( | ||
client: testclient.TestClient, db: orm.Session | ||
): | ||
user2 = users_crud.create_user(db, "user2") | ||
response = client.get(f"/api/v1/projects/common/{user2.id}") | ||
assert response.status_code == 200 | ||
assert len(response.json()) == 0 | ||
|
||
|
||
@pytest.mark.usefixtures("project_user") | ||
def test_get_common_projects( | ||
client: testclient.TestClient, | ||
db: orm.Session, | ||
project: projects_models.DatabaseProject, | ||
): | ||
user2 = users_crud.create_user(db, "user2") | ||
projects_users_crud.add_user_to_project( | ||
db, | ||
project, | ||
user2, | ||
role=projects_users_models.ProjectUserRole.USER, | ||
permission=projects_users_models.ProjectUserPermission.WRITE, | ||
) | ||
|
||
response = client.get(f"/api/v1/projects/common/{user2.id}") | ||
assert response.status_code == 200 | ||
assert len(response.json()) == 1 | ||
assert response.json()[0]["slug"] == project.slug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
frontend/src/app/users/users-profile/users-profile.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ |
27 changes: 27 additions & 0 deletions
27
frontend/src/app/users/users-profile/users-profile.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<h2>Profile of {{ userName }}</h2> | ||
|
||
<div *ngIf="userId !== currentUser?.id"> | ||
Common Projects | ||
|
||
<ng-container | ||
*ngIf="(projectService.projects$ | async)?.length; else elseBlock" | ||
> | ||
<mat-card | ||
*ngFor="let project of projectService.projects$ | async" | ||
class="!ml-0 cursor-pointer" | ||
[routerLink]="['/project', project.slug]" | ||
> | ||
<mat-card-content> | ||
<b>{{ project.name }}</b | ||
><br /> | ||
{{ project.description }} | ||
</mat-card-content> | ||
</mat-card> | ||
</ng-container> | ||
<ng-template #elseBlock>You do not have any common projects.</ng-template> | ||
</div> |
41 changes: 41 additions & 0 deletions
41
frontend/src/app/users/users-profile/users-profile.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { ProjectService } from 'src/app/projects/service/project.service'; | ||
import { User, UserService } from 'src/app/services/user/user.service'; | ||
|
||
@Component({ | ||
selector: 'app-users-profile', | ||
templateUrl: './users-profile.component.html', | ||
styleUrls: ['./users-profile.component.css'], | ||
}) | ||
export class UsersProfileComponent implements OnInit { | ||
userName: string | undefined; | ||
userId: number | undefined; | ||
currentUser: User | undefined; | ||
constructor( | ||
public userService: UserService, | ||
public projectService: ProjectService, | ||
private route: ActivatedRoute, | ||
) {} | ||
|
||
ngOnInit() { | ||
this.route.queryParams.subscribe((params) => { | ||
this.userId = params.userId; | ||
this.userName = params.userName; | ||
}); | ||
this.userService.getCurrentUser().subscribe((res) => { | ||
this.currentUser = res; | ||
if (!this.userId) { | ||
this.userId = res.id; | ||
this.userName = res.name; | ||
} else { | ||
this.projectService.loadCommonProjects(this.userId!); | ||
} | ||
}); | ||
} | ||
} |