diff options
Diffstat (limited to 'frontend')
18 files changed, 19 insertions, 15 deletions
diff --git a/frontend/src/app/Shared.ts b/frontend/src/app/Shared.ts index 0adcd4d6..31afb1a6 100644 --- a/frontend/src/app/Shared.ts +++ b/frontend/src/app/Shared.ts @@ -1,7 +1,8 @@ class Shared { constructor( public loggedIn: boolean, - public username: string = '' + public username: string = '', + public photoId: string = '1' ) { } } diff --git a/frontend/src/app/_data/ProfilePictures.ts b/frontend/src/app/_data/ProfilePictures.ts index 42688b4d..217810d9 100644 --- a/frontend/src/app/_data/ProfilePictures.ts +++ b/frontend/src/app/_data/ProfilePictures.ts @@ -59,13 +59,5 @@ export const PICTURES = [ { photoId: 14, path: "/assets/profilePictures/14.png" - }, - { - photoId: 15, - path: "/assets/profilePictures/15.png" - }, - { - photoId: 16, - path: "/assets/profilePictures/16.png" } ]
\ No newline at end of file diff --git a/frontend/src/app/_data/User.ts b/frontend/src/app/_data/User.ts index 58383d38..be42ed0a 100644 --- a/frontend/src/app/_data/User.ts +++ b/frontend/src/app/_data/User.ts @@ -1,5 +1,5 @@ export default class User { - _id: string = ''; + _id?: string = ''; constructor( public username: string = '', public email: string = '', diff --git a/frontend/src/app/_elements/navbar/navbar.component.html b/frontend/src/app/_elements/navbar/navbar.component.html index 52e26e6b..82a1ea07 100644 --- a/frontend/src/app/_elements/navbar/navbar.component.html +++ b/frontend/src/app/_elements/navbar/navbar.component.html @@ -18,7 +18,7 @@ <div *ngIf="shared.loggedIn" class="dropdown text-end"> <a href="#" class="d-block link-light text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false"> - <img src="https://github.com/mdo.png" alt="mdo" width="32" height="32" class="rounded-circle"> + <img [src]="'/assets/profilePictures/'+ shared.photoId +'.png'" alt="mdo" width="32" height="32" class="rounded-circle"> </a> <ul class="dropdown-menu text-small" aria-labelledby="dropdownUser1" style="position: absolute; inset: 0px 0px auto auto; margin: 0px; transform: translate(0px, 34px);" diff --git a/frontend/src/app/_elements/navbar/navbar.component.ts b/frontend/src/app/_elements/navbar/navbar.component.ts index c16e3e9d..5fd98c8f 100644 --- a/frontend/src/app/_elements/navbar/navbar.component.ts +++ b/frontend/src/app/_elements/navbar/navbar.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Location } from '@angular/common'; import { AuthService } from '../../_services/auth.service'; import shared from 'src/app/Shared'; +import { UserInfoService } from 'src/app/_services/user-info.service'; @Component({ selector: 'app-navbar', @@ -13,7 +14,7 @@ export class NavbarComponent implements OnInit { currentUrl: string; shared = shared; - constructor(public location: Location, private auth: AuthService) { + constructor(public location: Location, private auth: AuthService, private userInfoService: UserInfoService) { this.currentUrl = this.location.path(); this.location.onUrlChange(() => { this.currentUrl = this.location.path(); @@ -22,6 +23,9 @@ export class NavbarComponent implements OnInit { ngOnInit(): void { this.auth.updateUser(); + this.userInfoService.getUserInfo().subscribe((response) => { + shared.photoId = response.photoId; + }); } logOut() { diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.ts b/frontend/src/app/_modals/register-modal/register-modal.component.ts index fe0de92f..13ef7eba 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.ts +++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { AuthService } from 'src/app/_services/auth.service'; +import User from 'src/app/_data/User'; @Component({ selector: 'app-register-modal', @@ -124,7 +125,7 @@ export class RegisterModalComponent implements OnInit { if (!(this.wrongFirstNameBool || this.wrongLastNameBool || this.wrongUsernameBool || this.wrongEmailBool || this.wrongPass1Bool || this.wrongPass2Bool)) { //sve ok, registruj ga - let user = { + let user: User = { firstName: this.firstName, lastName: this.lastName, username: this.username, diff --git a/frontend/src/app/_pages/profile/profile.component.html b/frontend/src/app/_pages/profile/profile.component.html index 24efaeb5..d082a003 100644 --- a/frontend/src/app/_pages/profile/profile.component.html +++ b/frontend/src/app/_pages/profile/profile.component.html @@ -104,7 +104,7 @@ <div class="row overflow-auto" style="max-height: 200px;"> <div class="card col-md-3" *ngFor="let picture of this.pictures" (click)="this.photoId = picture.photoId.toString()" [ngClass]="{'selectedPicture': this.photoId == picture.photoId.toString()}"> - <img class="card-img-top" src="{{picture.path}}"> + <img src="{{picture.path}}"> </div> </div> </div> diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts index cb4b095e..3e9a0d11 100644 --- a/frontend/src/app/_pages/profile/profile.component.ts +++ b/frontend/src/app/_pages/profile/profile.component.ts @@ -5,6 +5,8 @@ import { AuthService } from 'src/app/_services/auth.service'; import { Router } from '@angular/router'; import { PICTURES } from 'src/app/_data/ProfilePictures'; import { Picture } from 'src/app/_data/ProfilePictures'; +import shared from '../../Shared'; + @Component({ selector: 'app-profile', @@ -50,6 +52,7 @@ export class ProfileComponent implements OnInit { this.userInfoService.getUserInfo().subscribe((response) => { this.user = response; + shared.photoId = this.user.photoId; this.username = this.user.username; this.email = this.user.email; @@ -155,6 +158,7 @@ export class ProfileComponent implements OnInit { break; } } + shared.photoId = this.photoId; } diff --git a/frontend/src/app/_services/auth.service.ts b/frontend/src/app/_services/auth.service.ts index 20ff45f3..449b8802 100644 --- a/frontend/src/app/_services/auth.service.ts +++ b/frontend/src/app/_services/auth.service.ts @@ -61,8 +61,10 @@ export class AuthService { updateUser() { if (this.cookie.check('token')) { const token = this.cookie.get('token'); + const decodedToken = jwtHelper.decodeToken(token); + console.log("decoded:", decodedToken); this.shared.loggedIn = this.isAuthenticated(); - this.shared.username = jwtHelper.decodeToken(token).name; + this.shared.username = decodedToken.name; this.enableAutoRefresh(); } } diff --git a/frontend/src/assets/profilePictures/1.png b/frontend/src/assets/profilePictures/1.png Binary files differindex 27f46e7f..6e2f8b73 100644 --- a/frontend/src/assets/profilePictures/1.png +++ b/frontend/src/assets/profilePictures/1.png diff --git a/frontend/src/assets/profilePictures/10.png b/frontend/src/assets/profilePictures/10.png Binary files differindex 8523f582..cbd270ca 100644 --- a/frontend/src/assets/profilePictures/10.png +++ b/frontend/src/assets/profilePictures/10.png diff --git a/frontend/src/assets/profilePictures/11.png b/frontend/src/assets/profilePictures/11.png Binary files differindex 37fa560b..982fdae4 100644 --- a/frontend/src/assets/profilePictures/11.png +++ b/frontend/src/assets/profilePictures/11.png diff --git a/frontend/src/assets/profilePictures/15.png b/frontend/src/assets/profilePictures/15.png Binary files differdeleted file mode 100644 index 835ba0ab..00000000 --- a/frontend/src/assets/profilePictures/15.png +++ /dev/null diff --git a/frontend/src/assets/profilePictures/16.png b/frontend/src/assets/profilePictures/16.png Binary files differdeleted file mode 100644 index 6cdf285f..00000000 --- a/frontend/src/assets/profilePictures/16.png +++ /dev/null diff --git a/frontend/src/assets/profilePictures/2.png b/frontend/src/assets/profilePictures/2.png Binary files differindex a99fad8a..d8dc7967 100644 --- a/frontend/src/assets/profilePictures/2.png +++ b/frontend/src/assets/profilePictures/2.png diff --git a/frontend/src/assets/profilePictures/5.png b/frontend/src/assets/profilePictures/5.png Binary files differindex d8dc7967..8523f582 100644 --- a/frontend/src/assets/profilePictures/5.png +++ b/frontend/src/assets/profilePictures/5.png diff --git a/frontend/src/assets/profilePictures/8.png b/frontend/src/assets/profilePictures/8.png Binary files differindex 982fdae4..835ba0ab 100644 --- a/frontend/src/assets/profilePictures/8.png +++ b/frontend/src/assets/profilePictures/8.png diff --git a/frontend/src/assets/profilePictures/9.png b/frontend/src/assets/profilePictures/9.png Binary files differindex b7d99523..fd38fac4 100644 --- a/frontend/src/assets/profilePictures/9.png +++ b/frontend/src/assets/profilePictures/9.png |