From 476cc12cc0033db7e29da2aa89abb1cdafe8f75c Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Tue, 1 Mar 2022 17:32:16 +0100 Subject: [PATCH] trucs de menu et token --- src/app/components/card-menu/card-menu.component.ts | 9 +++++---- src/app/components/header/header.component.html | 1 + src/app/components/header/header.component.ts | 12 ++++++++++-- .../pages/page-account/page-account.component.html | 1 - .../page-dashboard/page-dashboard.component.html | 3 --- src/app/services/menus.service.ts | 2 +- src/app/services/token.service.ts | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/app/components/card-menu/card-menu.component.ts b/src/app/components/card-menu/card-menu.component.ts index 9865447..9e95b6e 100644 --- a/src/app/components/card-menu/card-menu.component.ts +++ b/src/app/components/card-menu/card-menu.component.ts @@ -50,11 +50,12 @@ public upMenuForm : FormGroup; //delete d'un menu deleteMenu(id_menu : number): void { - window.alert("Le menu a bien été supprimé!") + // window.alert("Le menu a bien été supprimé!") this.menusService.deleteMenu(id_menu)?.subscribe((resp) => { - // this.router.navigate(['menu']); + // this.router.navigate(['menu']); + window.location.reload(); }); -window.location.reload(); + } //updateMenu @@ -76,8 +77,8 @@ updateMenu(id_menu : number): void { this.menusService.updateMenu(menu, id_menu)?.subscribe((resp) => { console.log(menu, id_menu); + window.location.reload(); }); - window.location.reload(); } diff --git a/src/app/components/header/header.component.html b/src/app/components/header/header.component.html index 09c2a30..7749b01 100644 --- a/src/app/components/header/header.component.html +++ b/src/app/components/header/header.component.html @@ -14,4 +14,5 @@ Organizee + diff --git a/src/app/components/header/header.component.ts b/src/app/components/header/header.component.ts index ce674e1..e0f454a 100644 --- a/src/app/components/header/header.component.ts +++ b/src/app/components/header/header.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { TokenService } from 'src/app/services/token.service'; @Component({ @@ -7,12 +8,19 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./header.component.scss'] }) export class HeaderComponent implements OnInit { +isLogged=false; - constructor(){ - } + constructor(public tokenService : TokenService){ + + } ngOnInit(): void { + + if(this.tokenService.getToken()){ + this.isLogged=true; + } + } } diff --git a/src/app/pages/page-account/page-account.component.html b/src/app/pages/page-account/page-account.component.html index 9b8fa86..5fbe7e2 100644 --- a/src/app/pages/page-account/page-account.component.html +++ b/src/app/pages/page-account/page-account.component.html @@ -1,5 +1,4 @@ -
diff --git a/src/app/pages/page-dashboard/page-dashboard.component.html b/src/app/pages/page-dashboard/page-dashboard.component.html index 46b1458..95545c6 100644 --- a/src/app/pages/page-dashboard/page-dashboard.component.html +++ b/src/app/pages/page-dashboard/page-dashboard.component.html @@ -1,9 +1,6 @@ - - -

Bienvenue {{ conectedUser.prenom }}!!

diff --git a/src/app/services/menus.service.ts b/src/app/services/menus.service.ts index 7bb9dbc..846f68b 100644 --- a/src/app/services/menus.service.ts +++ b/src/app/services/menus.service.ts @@ -45,7 +45,7 @@ apiUrl: string; } deleteMenu(id:number): Observable { - return this.http.delete(`${this.apiUrl}/menus/delete/${id}`); + return this.http.delete(`${this.apiUrl}/menus/delete/${id}`, {responseType:"text"}); } diff --git a/src/app/services/token.service.ts b/src/app/services/token.service.ts index 0ef68bd..378e3a6 100644 --- a/src/app/services/token.service.ts +++ b/src/app/services/token.service.ts @@ -23,7 +23,7 @@ tokenKey = environment.tokenKey; public eraseToken(): string | null { const token = localStorage.getItem(this.tokenKey); if(token) { - this.tokenKey = ''; + localStorage.removeItem(this.tokenKey); return token; }else { return null;