module deconnexion

This commit is contained in:
Romain Verger 2022-03-02 10:25:30 +01:00
parent 30f70296ba
commit 547f6aee58
8 changed files with 31 additions and 13 deletions

View File

@ -1,4 +1,4 @@
<app-search-bar *ngIf="dontShow"></app-search-bar>
<app-nav-bar *ngIf="dontShow"></app-nav-bar>
<app-search-bar></app-search-bar>
<app-nav-bar></app-nav-bar>
<router-outlet></router-outlet>
<app-footer *ngIf="dontShow"></app-footer>
<app-footer ></app-footer>

View File

@ -1,4 +1,4 @@
<footer class="d-flex">
<footer *ngIf="route.url != '/signin'" class="d-flex">
<div class = "logo d-inline-flex align-items-center">
<img src="../../assets/Logo_footer.png">

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-footer',
@ -7,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
})
export class FooterComponent implements OnInit {
constructor() { }
constructor(public route : Router) { }
ngOnInit(): void {
}

View File

@ -1,5 +1,5 @@
<nav class="navbar-expand-lg navbar-light">
<div class="container-fluid">
<div *ngIf="route.url != '/signin'" class="container-fluid">
<button class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
@ -10,16 +10,16 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="nav">
<div class="navbar-nav ">
<div *ngIf="route.url != '/signin'" class="navbar-nav ">
<a routerLink="home" routerLinkActive="active-custom" class="nav-link p-4 pe-5 " style="font-size: 21px;">Accueil</a>
<a routerLink="categories" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Categories</a>
<a routerLink="filtres" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Filtres</a>
<a routerLink="favoris" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Mes favoris</a>
<a routerLink="deconnexion" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Deconnexion</a>
<a routerLink="deconnexion" routerLinkActive="active-custom" (click) = "onCloseSession()" class="nav-link p-4 pe-5" style="font-size: 21px;">Deconnexion</a>
</div>
</div>
</div>
<div id="image-header">
<div *ngIf="route.url != '/signin'" id="image-header">
<img src="assets/images-header/bandeau2.png" alt="fond_header">
</div>

View File

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { TokenService } from 'src/app/services/token.service';
import { environment } from 'src/environments/environment';
@Component({
selector: 'app-nav-bar',
@ -6,10 +9,17 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./nav-bar.component.scss']
})
export class NavBarComponent implements OnInit {
tokenKey = environment.tokenKey;
constructor() { }
constructor( private tokenService : TokenService, public route: Router) { }
ngOnInit(): void {
}
onCloseSession() : void {
this.tokenService.destroyToken();
this.route.navigate(['signin']);
}
}

View File

@ -1,6 +1,6 @@
<nav class="navbar navbar-light p-0">
<div class="container-fluid d-flex align-items-center pt-3">
<div class="logo ps-4">
<div *ngIf="route.url != '/signin'" class="container-fluid d-flex align-items-center pt-3">
<div *ngIf="route.url != '/signin'" class="logo ps-4">
<img src="assets/images-header/LOGO2.png" alt="logo">
</div>
<form style="width: 30%;" class="d-flex align-items-center pe-2 pt-2">

View File

@ -13,7 +13,7 @@ export class SearchBarComponent implements OnInit {
listRestau: any[];
restauByName: any[];
constructor(private apiBackService: ApiBackService, private route: Router) {
constructor(private apiBackService: ApiBackService, public route: Router) {
this.listRestau = [];
this.restauByName = [];
@ -36,6 +36,8 @@ export class SearchBarComponent implements OnInit {
this.apiBackService.setListRestau(this.restauByName, "filtres");
this.route.navigate(['restaurants']);
}
}

View File

@ -29,4 +29,9 @@ export class TokenService {
return null;
}
}
public destroyToken(): void {
localStorage.removeItem(this.tokenKey);
}
}