Merge branch 'Romain' into dev

This commit is contained in:
Romain Verger 2022-03-03 14:29:09 +01:00
commit 97e024afb3
6 changed files with 31 additions and 26 deletions

View File

@ -23,6 +23,7 @@ import { AddRestauComponent } from './admin-component/add-restau/add-restau.comp
import { UpdateDelRestauComponent } from './admin-component/update-del-restau/update-del-restau.component'; import { UpdateDelRestauComponent } from './admin-component/update-del-restau/update-del-restau.component';
import { HeaderLogoComponent } from './header/components/header-logo/header-logo.component'; import { HeaderLogoComponent } from './header/components/header-logo/header-logo.component';
import { AuthInterceptor } from './services/auth.interceptor'; import { AuthInterceptor } from './services/auth.interceptor';
import { FavorisUserComponent } from './pages/favoris-user/favoris-user.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -44,7 +45,9 @@ import { AuthInterceptor } from './services/auth.interceptor';
AdminPageComponent, AdminPageComponent,
AddRestauComponent, AddRestauComponent,
UpdateDelRestauComponent, UpdateDelRestauComponent,
HeaderLogoComponent HeaderLogoComponent,
FavorisUserComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -13,6 +13,7 @@
<div class="navbar-nav "> <div class="navbar-nav ">
<a routerLink="home" routerLinkActive="active-custom" class="nav-link p-4 pe-5 " style="font-size: 21px;">Accueil</a> <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="categories" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Categories</a>
<a routerLink="restaurants" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Restaurants</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" (click) = "onCloseSession()" 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>

View File

@ -1,8 +1,6 @@
<h2 class="titre ">Mes favoris :</h2> <app-template-page [title]="'Favoris :'">
<div class="separation"></div> <div *ngFor="let pref of restaurantData">
<div class="parent d-flex justify-content-center align-items-center"> <app-card-resto [restaurant]= "pref"></app-card-resto>
<div class="card">
<h3>Mon top</h3>
</div> </div>
</app-template-page>
</div>

View File

@ -9,24 +9,30 @@ import { TokenService } from 'src/app/services/token.service';
}) })
export class FavorisUserComponent implements OnInit { export class FavorisUserComponent implements OnInit {
personneConnectee : any;
constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { personneConnectee : any;
listPref: any;
restaurantData : any[];
constructor(private apiBackService : ApiBackService, private tokenService : TokenService) {
this.restaurantData = []
} }
ngOnInit(): void { ngOnInit(): void {
this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe( this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe(
resp =>{ user =>{
console.log(resp);
this.listPref = user.preference;
console.log(this.listPref);
for (let i = 0; i < this.listPref.length; i++) {
this.restaurantData.push(this.listPref[i]['preferencePK']['restau']);
}
this.personneConnectee = resp;
} }
); );
console.log(this.personneConnectee);
} }
} }

View File

@ -1,4 +1,4 @@
<app-template-page [title]="'Résultats :'"> <app-template-page [title]="'Restaurants :'">
<div *ngFor="let restaurantData of listRestaurants"> <div *ngFor="let restaurantData of listRestaurants">
<app-card-resto [restaurant]= "restaurantData"></app-card-resto> <app-card-resto [restaurant]= "restaurantData"></app-card-resto>
</div> </div>

View File

@ -34,14 +34,12 @@ export class ApiBackService {
} }
setListRestau(listRestau: any[], routeParam?: string): void { setListRestau(listRestau: any[], routeParam?: string): void {
this.restoFilter = listRestau; this.restoFilter = listRestau;
this.routeParam = routeParam; this.routeParam = routeParam;
} }
setDistance(lat1: number, lon1: number, lat2: number, lon2: number) { setDistance(lat1: number, lon1: number, lat2: number, lon2: number) {
let R = 6371; // Radius of the earth in km let R = 6371; // Radius of the earth in km
let dLat = this.deg2rad(lat2 - lat1); // deg2rad below let dLat = this.deg2rad(lat2 - lat1); // deg2rad below
let dLon = this.deg2rad(lon2 - lon1); let dLon = this.deg2rad(lon2 - lon1);
@ -65,12 +63,11 @@ export class ApiBackService {
} }
deleteRestau(idRestau: number | undefined): Observable<any> { deleteRestau(idRestau: number | undefined): Observable<any> {
return this.httpClient.delete<Restaurant>(`${environment.apiUrl}/delete-restaurant/${idRestau}`); return this.httpClient.delete<Restaurant>(`${environment.apiUrl}/delete-restaurant/${idRestau}`);
} }
getPersonneById(id: any) { getPersonneById(id: any) {
return this.httpClient.get<any[]>(`${environment.apiUrl}/user/${id}`); return this.httpClient.get<any>(`${environment.apiUrl}/user/${id}`);
} }
} }