diff --git a/src/app/profile/profile.component.html b/src/app/profile/profile.component.html index 6ea1bd3a8b3939984ff94650b0c124703ffb8e6f..8931777b912e42eeda72cd0ed4def69618daf435 100644 --- a/src/app/profile/profile.component.html +++ b/src/app/profile/profile.component.html @@ -1,8 +1,6 @@ -<p>profile works!</p> <p *ngIf="(currentUser$ | async) as user"> {{ user.email }} - {{ user.pseudo }} </p> <p> <button mat-raised-button routerLink="/bars" color="primary">Liste des bars</button> - <button mat-raised-button routerLink="/photos" color="accent">photos</button> </p> \ No newline at end of file diff --git a/src/app/share/components/topbar/topbar.component.css b/src/app/share/components/topbar/topbar.component.css index 1376150f1e2188f2cc37a46d213cdd96c5b02ed0..3b7aacdbb20b55542e24c86375f1280f66a9a83e 100644 --- a/src/app/share/components/topbar/topbar.component.css +++ b/src/app/share/components/topbar/topbar.component.css @@ -4,4 +4,37 @@ input { font-size: 14px; border-radius: 3px; border: 0; +} + +.menu-button { + margin-right: 24px; + min-width: 0; + padding: 0; + line-height: normal; +} + +.profile-pic { + height: 60px; + width: 60px; +} + +.sidenav-container { + flex: 1; +} + +.sidenav { + min-width: 240px; + +} + +a { + display: block; + padding: 6px 24px; + width: 100%; + text-align: left; +} + +main { + padding: 18px 24px; + height: 100%; } \ No newline at end of file diff --git a/src/app/share/components/topbar/topbar.component.html b/src/app/share/components/topbar/topbar.component.html index 8ab70b509498c7790a2c7a9dca3f1f90fb88956c..0e858e7f3e199a23f298a968d143ea8c790e1934 100644 --- a/src/app/share/components/topbar/topbar.component.html +++ b/src/app/share/components/topbar/topbar.component.html @@ -1,11 +1,31 @@ <mat-toolbar *ngIf="isLoggedIn$ | async" color="primary" fxLayoutGap="15px"> - <span routerLink="/welcome">Mon logo</span> + <button mat-button class="menu-button" (click)="sidenav.toggle()"> + <mat-icon>{{ isMenuOpen ? 'menu_open' : 'menu' }}</mat-icon> + </button> + + <span *ngIf="(currentUser$ | async) as user"> + {{ user.pseudo }} + </span> + + <img class="profile-pic" src="https://fakeimg.pl/300/" alt="fake-img"> + <!-- <span *ngIf="!(isLoggedIn$ | async)" fxLayoutGap="15px" fxLayout="row" fxLayoutAlign="center center"> <mat-icon class="link" routerLink="/signin">login</mat-icon> <mat-icon class="link" routerLink="/signup">launch</mat-icon> - </span> + </span> <span *ngIf="isLoggedIn$ | async" fxLayoutGap="15px" fxLayout="row" fxLayoutAlign="center center"> <mat-icon class="link" routerLink="/profile">account_circle</mat-icon> <mat-icon class="link" routerLink="/" (click)="onLogout()">power_settings_new</mat-icon> </span> --> -</mat-toolbar> \ No newline at end of file +</mat-toolbar> +<mat-sidenav-container class="sidenav-container"> + <mat-sidenav #sidenav autoFocus="false" mode="over" [(opened)]="isMenuOpen" class="sidenav" (click)="onSidenavClick()"> + <a mat-button routerLink="/profile">Profil</a> + <a mat-button (click)="onLogout()">Déconnexion</a> + </mat-sidenav> + <mat-sidenav-content> + <main> + <router-outlet></router-outlet> + </main> + </mat-sidenav-content> +</mat-sidenav-container> \ No newline at end of file diff --git a/src/app/share/components/topbar/topbar.component.ts b/src/app/share/components/topbar/topbar.component.ts index 65090091d86c7e9df60b021ee8dbdeac7b0e3299..c7bd968b1a054f0dcfd9566f073d5439ea3637a5 100644 --- a/src/app/share/components/topbar/topbar.component.ts +++ b/src/app/share/components/topbar/topbar.component.ts @@ -6,6 +6,9 @@ import { State } from '../../store'; import { Logout } from '../../store/actions/auth.actions'; import { isLoggedInAuthSelector } from '../../store/selectors/auth.selectors'; import { FetchPhotos, SetFilter } from 'src/app/photos/shared/store/photos.actions'; +import { TryFetchCurrentUser } from '../../store/actions/auth.actions'; +import { userAuthSelector } from '../../store/selectors/auth.selectors'; +import { User } from '../../models/user.model'; @Component({ selector: 'app-topbar', @@ -14,6 +17,9 @@ import { FetchPhotos, SetFilter } from 'src/app/photos/shared/store/photos.actio }) export class TopbarComponent implements OnInit { public isLoggedIn$: Observable<boolean>; + public isMenuOpen: boolean = false; + + public currentUser$: Observable<User>; constructor( private store: Store<State>, @@ -23,9 +29,15 @@ export class TopbarComponent implements OnInit { this.isLoggedIn$ = this.store.pipe( select(isLoggedInAuthSelector) ); + this.currentUser$ = this.store.pipe(select(userAuthSelector)); + this.store.dispatch(new TryFetchCurrentUser()); } public onLogout(): void { this.store.dispatch(new Logout()); } + + public onSidenavClick(): void { + this.isMenuOpen = false; + } } diff --git a/src/app/share/modules/material.module.ts b/src/app/share/modules/material.module.ts index 4795388897f89703d044add36393a7e9700b7dd8..371849e7f3ed5b43bb8524d40cd3b084aae3a363 100644 --- a/src/app/share/modules/material.module.ts +++ b/src/app/share/modules/material.module.ts @@ -6,6 +6,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatSidenavModule} from '@angular/material/sidenav'; const MODULES = [ MatToolbarModule, @@ -15,6 +16,7 @@ const MODULES = [ MatCardModule, MatIconModule, MatCheckboxModule, + MatSidenavModule, ]; @NgModule({ diff --git a/src/app/share/store/effects/auth.effects.ts b/src/app/share/store/effects/auth.effects.ts index 90b9043cdf892c32443870ba1a2d2460591f7d67..b9e5f84a91ab854e38004ac3d74636c650becb1a 100644 --- a/src/app/share/store/effects/auth.effects.ts +++ b/src/app/share/store/effects/auth.effects.ts @@ -120,7 +120,7 @@ export class AuthEffects { this.subscription.unsubscribe(); } localStorage.removeItem('jwt'); - this.router.navigate(['/']); + this.router.navigate(['/welcome']); }) )