Merge branch 'Romain' into dev
This commit is contained in:
commit
0478637dd6
|
@ -11,7 +11,8 @@ import { AdminPageComponent } from './pages/admin-page/admin-page.component';
|
||||||
import { AuthGuard } from './services/auth.guard';
|
import { AuthGuard } from './services/auth.guard';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'home', pathMatch: 'full' },
|
{ path: '', redirectTo: 'signin', pathMatch: 'full' },
|
||||||
|
{path: 'signin', component: SigninComponent},
|
||||||
{ path: 'home', component: HomePageComponent },
|
{ path: 'home', component: HomePageComponent },
|
||||||
{ path: 'categories', component: ListCategoriesComponent },
|
{ path: 'categories', component: ListCategoriesComponent },
|
||||||
{ path: 'favoris', component: FavorisUserComponent },
|
{ path: 'favoris', component: FavorisUserComponent },
|
||||||
|
@ -19,7 +20,6 @@ const routes: Routes = [
|
||||||
{ path: 'Deconnexion', redirectTo: 'home'},
|
{ path: 'Deconnexion', redirectTo: 'home'},
|
||||||
{path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent},
|
{path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent},
|
||||||
{path: 'page-not-found',component: PageNotFoundComponent},
|
{path: 'page-not-found',component: PageNotFoundComponent},
|
||||||
{path: 'signin', component: SigninComponent},
|
|
||||||
{path: 'admin', component: AdminPageComponent},
|
{path: 'admin', component: AdminPageComponent},
|
||||||
{path: '**', redirectTo: 'page-not-found' }
|
{path: '**', redirectTo: 'page-not-found' }
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<app-search-bar *ngIf="dontShow"></app-search-bar>
|
<app-search-bar *ngIf="router.url != '/signin'"></app-search-bar>
|
||||||
<app-nav-bar *ngIf="dontShow"></app-nav-bar>
|
<app-nav-bar *ngIf="router.url != '/signin'"></app-nav-bar>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
<app-footer *ngIf="dontShow"></app-footer>
|
<app-footer *ngIf="router.url != '/signin'"></app-footer>
|
||||||
|
|
|
@ -11,12 +11,12 @@ export class AppComponent {
|
||||||
title = 'simpleat';
|
title = 'simpleat';
|
||||||
dontShow: boolean = false;
|
dontShow: boolean = false;
|
||||||
|
|
||||||
constructor(private router:Router, private apiBackService : ApiBackService){
|
constructor(public router:Router, private apiBackService : ApiBackService){
|
||||||
this.router.events.subscribe(e=>{
|
this.router.events.subscribe(e=>{
|
||||||
//console.log(e);
|
//console.log(e);
|
||||||
if(e instanceof NavigationEnd){
|
if(e instanceof NavigationEnd){
|
||||||
console.log(e.url)
|
console.log(e.url)
|
||||||
if (e.url == "/signin") {
|
if (e.url == "/") {
|
||||||
this.dontShow = false;
|
this.dontShow = false;
|
||||||
} else {
|
} else {
|
||||||
this.dontShow = true;
|
this.dontShow = true;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-footer',
|
selector: 'app-footer',
|
||||||
|
@ -7,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class FooterComponent implements OnInit {
|
export class FooterComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor(public route : Router) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<a routerLink="categories" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Categories</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="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="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>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
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({
|
@Component({
|
||||||
selector: 'app-nav-bar',
|
selector: 'app-nav-bar',
|
||||||
|
@ -6,10 +9,17 @@ import { Component, OnInit } from '@angular/core';
|
||||||
styleUrls: ['./nav-bar.component.scss']
|
styleUrls: ['./nav-bar.component.scss']
|
||||||
})
|
})
|
||||||
export class NavBarComponent implements OnInit {
|
export class NavBarComponent implements OnInit {
|
||||||
|
tokenKey = environment.tokenKey;
|
||||||
|
|
||||||
constructor() { }
|
constructor( private tokenService : TokenService, public route: Router) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCloseSession() : void {
|
||||||
|
this.tokenService.destroyToken();
|
||||||
|
this.route.navigate(['signin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export class SearchBarComponent implements OnInit {
|
||||||
listRestau: any[];
|
listRestau: any[];
|
||||||
restauByName: any[];
|
restauByName: any[];
|
||||||
|
|
||||||
constructor(private apiBackService: ApiBackService, private route: Router) {
|
constructor(private apiBackService: ApiBackService, public route: Router) {
|
||||||
|
|
||||||
this.listRestau = [];
|
this.listRestau = [];
|
||||||
this.restauByName = [];
|
this.restauByName = [];
|
||||||
|
@ -39,5 +39,7 @@ export class SearchBarComponent implements OnInit {
|
||||||
//this.route.routeReuseStrategy.shouldReuseRoute= () => false;
|
//this.route.routeReuseStrategy.shouldReuseRoute= () => false;
|
||||||
//this.route.onSameUrlNavigation = 'reload';
|
//this.route.onSameUrlNavigation = 'reload';
|
||||||
this.route.navigate(['restaurants']);
|
this.route.navigate(['restaurants']);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,9 @@ export class TokenService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public destroyToken(): void {
|
||||||
|
localStorage.removeItem(this.tokenKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue