-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12 change structure of settings.json to conform with backend structure
- Loading branch information
1 parent
6440591
commit 845bcd8
Showing
7 changed files
with
101 additions
and
66 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
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,10 +1,40 @@ | ||
[ | ||
{ | ||
"username": "THEA", | ||
"avatar": "assets/images/avatar_female.png" | ||
"@id": "/api/users/1", | ||
"@type": "User", | ||
"id": 1, | ||
"email": "[email protected]", | ||
"name": "THEA", | ||
"roles": ["ROLE_USER"], | ||
"password": "$2y$13$oPKDGHh.3nTCe0ZKHzGVIuIihrx90RMgCtoX7.b1mvZCFD60L9TWq", | ||
"allowance": 310, | ||
"avatar": "/build/assets/images/avatar_female.png", | ||
"transactions": [ | ||
"/api/transactions/1", | ||
"/api/transactions/4", | ||
"/api/transactions/6", | ||
"/api/transactions/7", | ||
"/api/transactions/8", | ||
"/api/transactions/10" | ||
], | ||
"userIdentifier": "[email protected]" | ||
}, | ||
{ | ||
"username": "ROBERT", | ||
"avatar": "assets/images/avatar_male.png" | ||
"@id": "/api/users/2", | ||
"@type": "User", | ||
"id": 2, | ||
"email": "[email protected]", | ||
"name": "ROBERT", | ||
"roles": ["ROLE_USER"], | ||
"password": "$2y$13$VNdZsI6clow.zdau7OErJOcp/HFEYwPWtEuIuNoTYYIdXD7pgZX7G", | ||
"allowance": 921, | ||
"avatar": "/build/assets/images/avatar_male.png", | ||
"transactions": [ | ||
"/api/transactions/2", | ||
"/api/transactions/3", | ||
"/api/transactions/5", | ||
"/api/transactions/9" | ||
], | ||
"userIdentifier": "[email protected]" | ||
} | ||
] | ||
] |
108 changes: 54 additions & 54 deletions
108
apps/client/src/shared/page-header/page-header.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 |
---|---|---|
@@ -1,71 +1,71 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
import { UserService } from '../../app/services/user.service'; | ||
import { Observable } from 'rxjs'; | ||
import { Observable, of } from 'rxjs'; | ||
import { User } from '@money-sprouts/shared/domain'; | ||
|
||
@Component({ | ||
selector: 'money-sprouts-page-header', | ||
templateUrl: './page-header.component.html', | ||
styleUrls: ['./page-header.component.scss'], | ||
selector: 'money-sprouts-page-header', | ||
templateUrl: './page-header.component.html', | ||
styleUrls: ['./page-header.component.scss'], | ||
}) | ||
export class PageHeaderComponent implements OnInit { | ||
childClass: string; | ||
username: string; | ||
user$: Observable<User | null>; | ||
urlSegments: string; | ||
logout = 'Logout'; | ||
childClass: string; | ||
username: string; | ||
user$: Observable<User | null>; | ||
urlSegments: string; | ||
logout = 'Logout'; | ||
|
||
constructor(private router: Router, private settings: UserService) {} | ||
constructor(private router: Router, private settings: UserService) {} | ||
|
||
ngOnInit() { | ||
const urlSegments = this.router.url.split('/'); | ||
this.username = urlSegments[2]; | ||
ngOnInit() { | ||
const urlSegments = this.router.url.split('/'); | ||
this.username = urlSegments[2]; | ||
|
||
this.settings.user$.subscribe((user: User | null) => { | ||
// Only fetch the user if no user is present or the username has changed | ||
if (!user || user.username !== this.username) { | ||
this.settings | ||
.fetchUser(this.username) | ||
.subscribe((fetchedUser: User | null) => { | ||
this.user$ = of(fetchedUser); | ||
}); | ||
} else { | ||
// Assign the user to this.user$ | ||
this.user$ = of(user); | ||
} | ||
}); | ||
} | ||
this.settings.user$.subscribe((user: User | null) => { | ||
// Only fetch the user if no user is present or the username has changed | ||
if (!user || user.name !== this.username) { | ||
this.settings | ||
.fetchUser(this.username) | ||
.subscribe((fetchedUser: User | null) => { | ||
this.user$ = of(fetchedUser); | ||
}); | ||
} else { | ||
// Assign the user to this.user$ | ||
this.user$ = of(user); | ||
} | ||
}); | ||
} | ||
|
||
backToDashboard() { | ||
if (this.urlSegments !== 'dashboard') { | ||
this.router.navigate([`user/${this.username}/dashboard`]); | ||
} else { | ||
return; | ||
} | ||
backToDashboard() { | ||
if (this.urlSegments !== 'dashboard') { | ||
this.router.navigate([`user/${this.username}/dashboard`]); | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
backToSelection() { | ||
this.router.navigate(['userselection']); | ||
} | ||
backToSelection() { | ||
this.router.navigate(['userselection']); | ||
} | ||
|
||
get pageTitle(): string { | ||
const pageName = this.router.url.split('/')[3]; | ||
switch (pageName) { | ||
case 'dashboard': | ||
return 'Dashboard'; | ||
case 'overview': | ||
return 'Overview'; | ||
case 'history': | ||
return 'History'; | ||
case 'plan': | ||
return 'Plan'; | ||
default: | ||
return ''; | ||
} | ||
get pageTitle(): string { | ||
const pageName = this.router.url.split('/')[3]; | ||
switch (pageName) { | ||
case 'dashboard': | ||
return 'Dashboard'; | ||
case 'overview': | ||
return 'Overview'; | ||
case 'history': | ||
return 'History'; | ||
case 'plan': | ||
return 'Plan'; | ||
default: | ||
return ''; | ||
} | ||
} | ||
|
||
handleClassChange(cssClass: string) { | ||
this.childClass = cssClass; | ||
} | ||
handleClassChange(cssClass: string) { | ||
this.childClass = cssClass; | ||
} | ||
} |
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