-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#705 change test data to new structure
+ load user in frontend on startup and set filters based on this user
- Loading branch information
1 parent
75b4de3
commit 0e87836
Showing
10 changed files
with
97 additions
and
9 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 |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
public record UserTeamDto( | ||
Long id, | ||
int version, | ||
TeamDto teamDto, | ||
TeamDto team, | ||
boolean isTeamAdmin | ||
) {} |
22 changes: 22 additions & 0 deletions
22
backend/src/main/resources/db/data-migration/V2_2_99__changeTeammanagement.sql
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,22 @@ | ||
-- add [email protected] as a user. we set it as champion in dev application properties | ||
INSERT INTO person (id, email, firstname, lastname, version, is_okr_champion) | ||
VALUES (61, '[email protected]', 'Jaya', 'Norris', 1, FALSE); | ||
|
||
-- map existing users to teams | ||
INSERT INTO person_team (id, version, person_id, team_id, is_team_admin) | ||
-- [email protected] | ||
VALUES (1, 1, 1, 4, TRUE), | ||
(2, 1, 1, 5, FALSE), | ||
-- [email protected] | ||
(3, 1, 11, 6, FALSE), | ||
-- [email protected] | ||
(4, 1, 21, 8, FALSE), | ||
-- [email protected] | ||
(5, 1, 31, 8, TRUE), | ||
-- egiman@puzzlech | ||
(6, 1, 41, 4, FALSE), | ||
-- [email protected] | ||
(7, 1, 51, 6, TRUE), | ||
-- [email protected] | ||
(8, 1, 61, 5, TRUE), | ||
(9, 1, 61, 6, FALSE); |
File renamed without changes.
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 |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { Observable, of, tap } from 'rxjs'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { User } from '../types/model/User'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class UserService { | ||
private readonly API_URL = 'api/v1/users'; | ||
|
||
private _user: User | undefined; | ||
|
||
constructor(private httpClient: HttpClient) {} | ||
|
||
public initCurrentUser(): Observable<User> { | ||
if (this._user) { | ||
return of(this._user); | ||
} | ||
return this.httpClient.get<User>(this.API_URL + '/current').pipe(tap((u) => (this._user = u))); | ||
} | ||
|
||
public getUsers(): Observable<User[]> { | ||
return this.httpClient.get<User[]>('api/v1/users'); | ||
return this.httpClient.get<User[]>(this.API_URL); | ||
} | ||
|
||
public getCurrentUser(): User { | ||
if (!this._user) { | ||
throw new Error('user should not be undefined here'); | ||
} | ||
return this._user; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import { Organisation } from './Organisation'; | ||
|
||
export interface Team { | ||
id: number; | ||
version: number; | ||
name: string; | ||
organisations: Organisation[]; | ||
filterIsActive: boolean; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import { UserTeam } from './UserTeam'; | ||
|
||
export interface User { | ||
id: number; | ||
firstname: string; | ||
lastname: string; | ||
email: string; | ||
userTeamList: UserTeam[]; | ||
isOkrChampion: boolean; | ||
isWriteable: boolean; | ||
} | ||
|
||
export const extractTeamsFromUser = (user: User) => { | ||
return user.userTeamList.map((u) => u.team); | ||
}; |
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,7 @@ | ||
import {Team} from "./Team"; | ||
|
||
export interface UserTeam { | ||
id: number; | ||
team: Team; | ||
isTeamAdmin: boolean; | ||
} |
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