merge resolution

This commit is contained in:
Thomas Cardon 2022-03-02 14:20:51 +01:00
commit 829c8333f6
8 changed files with 34 additions and 10 deletions

View File

@ -11,7 +11,8 @@ import { AdminPageComponent } from './pages/admin-page/admin-page.component';
import { AuthGuard } from './services/auth.guard';
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: '', redirectTo: 'signin', pathMatch: 'full' },
{path: 'signin', component: SigninComponent},
{ path: 'home', component: HomePageComponent },
{ path: 'categories', component: ListCategoriesComponent },
{ path: 'favoris', component: FavorisUserComponent },
@ -19,7 +20,6 @@ const routes: Routes = [
{ path: 'Deconnexion', redirectTo: 'home'},
{path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent},
{path: 'page-not-found',component: PageNotFoundComponent},
{path: 'signin', component: SigninComponent},
{path: 'admin', component: AdminPageComponent},
{path: '**', redirectTo: 'page-not-found' }
];

View File

@ -1,4 +1,6 @@
<app-header-logo *ngIf="dontShow"></app-header-logo>
<app-nav-bar *ngIf="dontShow"></app-nav-bar>
<!-- <app-header-logo *ngIf="dontShow"></app-header-logo>
<app-nav-bar *ngIf="dontShow"></app-nav-bar> -->
<app-search-bar *ngIf="router.url != '/signin'"></app-search-bar>
<app-nav-bar *ngIf="router.url != '/signin'"></app-nav-bar>
<router-outlet></router-outlet>
<app-footer *ngIf="dontShow"></app-footer>
<app-footer *ngIf="router.url != '/signin'"></app-footer>

View File

@ -11,12 +11,12 @@ export class AppComponent {
title = 'simpleat';
dontShow: boolean = false;
constructor(private router:Router, private apiBackService : ApiBackService){
constructor(public router:Router, private apiBackService : ApiBackService){
this.router.events.subscribe(e=>{
//console.log(e);
if(e instanceof NavigationEnd){
console.log(e.url)
if (e.url == "/signin") {
if (e.url == "/") {
this.dontShow = false;
} else {
this.dontShow = true;

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

@ -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="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>

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

@ -15,10 +15,14 @@ export class SearchBarComponent implements OnInit {
restauByName: any[];
@Output() resultSearch = new EventEmitter<Restaurant[]>();
constructor(private apiBackService: ApiBackService,
private route: Router,
private activatedRoute : ActivatedRoute) {
this.listRestau = [];
this.restauByName = [];
}
@ -49,5 +53,7 @@ export class SearchBarComponent implements OnInit {
// this.route.onSameUrlNavigation = 'reload';
this.route.navigate(['restaurants']);
}
}
}

View File

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