merge dev vers Romain

This commit is contained in:
Romain Verger 2022-02-16 14:07:27 +01:00
commit 0d9546fff0
8 changed files with 192 additions and 35 deletions

View File

@ -34,7 +34,8 @@ import { TemplatePageComponent } from './components/template-page/template-page.
FiltersPageComponent, FiltersPageComponent,
AvisBarComponent, AvisBarComponent,
IconComponent, IconComponent,
SigninComponent SigninComponent,
TemplatePageComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ApiBackService } from '../services/api-back.service'; import { ApiBackService } from '../services/api-back.service';
@Component({ @Component({
@ -11,20 +11,18 @@ export class CardCategoryComponent implements OnInit {
@Input() categoryData : any; @Input() categoryData : any;
constructor(private apiBackService : ApiBackService, private route : Router) { } constructor(private apiBackService : ApiBackService, private route : Router, private activatedRoute : ActivatedRoute) { }
ngOnInit(): void { ngOnInit(): void {
} }
onClickCateg(id : number){ onClickCateg(id : number){
this.apiBackService.getRestaurantsByCateg(id , this.activatedRoute.snapshot.routeConfig?.path);
this.apiBackService.getRestaurantsByCateg(id); // on fait passer en second parametre le path de la route c'est a dire "home"(pour l'instant)
this.route.navigate(['restaurants']); this.route.navigate(['restaurants']);
//console.log('salut les copains');
} }
} }

View File

@ -48,7 +48,11 @@
</p> </p>
</div> </div>
<!-- le else de notre *ngIf plus haut--> <!-- le else de notre *ngIf plus haut-->
<ng-template #noWebsite class="description pe-1" style="font-style: italic;font-weight: bold;">Pas de site Web</ng-template> <ng-template #noWebsite class="description pe-1" style="font-style: italic;font-weight: bold;">
<div>
<p class="description pt-3 ps-1 pe-1 text-justify d-block" style="font-size:0.9em; color:#545454"> Pas de site Web </p>
</div>
</ng-template>
<!-- ------------------------------------ --> <!-- ------------------------------------ -->
<div class="trait-rouge pt-2 pb-0"></div> <div class="trait-rouge pt-2 pb-0"></div>

View File

@ -4,6 +4,7 @@
<div class="accordion"> <div class="accordion">
<<<<<<< HEAD
<!-------------------------------------------------------------------------- Accordéon Distance --------------------------------------------------------------------------> <!-------------------------------------------------------------------------- Accordéon Distance -------------------------------------------------------------------------->
<div class="accordion-item"> <div class="accordion-item">
@ -48,8 +49,61 @@
<span>20€</span> <span>20€</span>
</div> </div>
</div> </div>
=======
<!-------------------------------------------------------------------------- Accordéon Distance -------------------------------------------------------------------------->
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseOne">
<p style="font-family:'Roboto';font-size: 20px;">Distance</p>
</button>
</h2>
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse"
aria-labelledby="panelsStayOpen-headingOne">
<div class="accordion-body">
<div class="distance p-3">
<span>Veuillez sélectionner la distance souhaitée</span>
</div>
<input type="range" class="form-range" min="{{minDistance}}" max="{{maxDistance}}"
(change)="OnChangeValueDistance($event)">
<div class="valuesDistance d-flex d-flex justify-content-between">
<span>0 KM</span>
<span>2 KM</span>
<span>4 KM</span>
</div> </div>
</div> </div>
</div>
</div>
<!-------------------------------------------------------------------------- Accordéon Prix -------------------------------------------------------------------------->
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseTwo">
<p style="font-family:'Roboto'; font-size: 20px;">Prix</p>
</button>
</h2>
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse"
aria-labelledby="panelsStayOpen-headingTwo">
<div class="accordion-body">
<div class="minMax p-3">
<span>Veuillez sélectionner le prix souhaité</span>
>>>>>>> dev
</div>
<input type="range" class="form-range" ng-model="valuePrix" min="{{minPrice}}" max="{{maxPrice}}"
(change)="OnChangeValuePrice($event)">
<div class="valuesPrix d-flex d-flex justify-content-between">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
</div>
</div>
</div>
<<<<<<< HEAD
<!-------------------------------------------------------------------------- Accordéon Place/Emporter --------------------------------------------------------------------------> <!-------------------------------------------------------------------------- Accordéon Place/Emporter -------------------------------------------------------------------------->
@ -109,6 +163,77 @@
<span>Choisissez parmi les avis déjà donnés</span> <span>Choisissez parmi les avis déjà donnés</span>
</div> </div>
<app-avis-bar (stateNumber)="onStateNumberChange($event)"></app-avis-bar> <app-avis-bar (stateNumber)="onStateNumberChange($event)"></app-avis-bar>
=======
</div>
<!-------------------------------------------------------------------------- Accordéon Place/Emporter -------------------------------------------------------------------------->
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingThree">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseThree">
<p style="font-family:'Roboto'; font-size: 20px;">Sur Place / A Emporter</p>
</button>
</h2>
<div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse"
aria-labelledby="panelsStayOpen-headingThree">
<div class="accordion-body">
<div class="Titles m-3 d-flex justify-content-around">
<span>Sur Place</span>
<span>A Emporter</span>
</div>
<div class="PlaceEmporterCheck m-3 d-flex justify-content-around">
<input class="surPlace-check-input" type="checkbox" value="surPlaceOption"
style="width: 25px; height: 25px; border-radius: 300px;" (change)="OnChangeValueSurPlace($event)">
<input class="Emporter-check-input" type="checkbox" value="aEmporterOption" style="width: 25px; height: 25px;"
(change)="OnChangeValueEmporter($event)">
</div>
</div>
</div>
</div>
<!-------------------------------------------------------------------------- Accordéon AccesPMR -------------------------------------------------------------------------->
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingFour">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseFour">
<p style="font-family:'Roboto'; font-size: 20px;">Accès PMR</p>
</button>
</h2>
<div id="panelsStayOpen-collapseFour" class="accordion-collapse collapse"
aria-labelledby="panelsStayOpen-headingFour">
<div class="accordion-body">
<div class="titrePmr m-3 d-flex justify-content-around">
<span>Accès PMR</span>
</div>
<div class="pmr-check d-flex justify-content-center p-2">
<input class="pmr-check-input mx-auto" type="checkbox" value="AccesPMR" style="width: 25px; height: 25px;"
(change)="OnChangeValuePMR($event)">
</div>
</div>
</div>
</div>
<!-------------------------------------------------------------------------- Accordéon Avis -------------------------------------------------------------------------->
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingFive">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseFive">
<p style="font-family:'Roboto'; font-size: 20px;">Avis</p>
</button>
</h2>
<div id="panelsStayOpen-collapseFive" class="accordion-collapse collapse"
aria-labelledby="panelsStayOpen-headingFive">
<div class="accordion-body">
<div class="titreAvis m-3 d-flex justify-content-around">
<span>Choisissez parmi les avis déjà donnés</span>
>>>>>>> dev
</div>
<app-avis-bar (stateNumber)="onStateNumberChange($event)"></app-avis-bar>
</div> </div>
</div> </div>
</div> </div>
@ -116,7 +241,12 @@
</div> </div>
<<<<<<< HEAD
<button class="btn-search btn-primary" type="button" <button class="btn-search btn-primary" type="button"
(click) = "onSendFilters($event, null, null, null, null, null)" (click) = "onSendFilters($event, null, null, null, null, null)"
(click) ="onSendRating()">LANCER LA RECHERCHE</button> (click) ="onSendRating()">LANCER LA RECHERCHE</button>
=======
<button class="btn-search btn-primary" type="button" (click)="onSendFilters()" (click)="onSendRating()">LANCER LA
RECHERCHE</button>
>>>>>>> dev

View File

@ -1,5 +1,5 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ApiBackService } from 'src/app/services/api-back.service'; import { ApiBackService } from 'src/app/services/api-back.service';
@Component({ @Component({
@ -14,7 +14,7 @@ export class FiltersPageComponent implements OnInit {
public minPrice : any; public minPrice : any;
public maxPrice: any; public maxPrice: any;
public selectPrice : any; public selectPrice : number;
public selectDistance : any; public selectDistance : any;
public selectPmr :any; public selectPmr :any;
public selectSurPlace : any; public selectSurPlace : any;
@ -24,18 +24,18 @@ export class FiltersPageComponent implements OnInit {
@Output() rangeNumber = new EventEmitter(); @Output() rangeNumber = new EventEmitter();
public selectRating: number; public selectRating: number;
public listRestau: string[]; public listRestau: any[];
constructor(private apiBackService : ApiBackService, private route : Router) { constructor(private apiBackService : ApiBackService, private route : Router, private activatedRoute : ActivatedRoute) {
this.minDistance = 0; this.minDistance = 0;
this.maxDistance = 4; this.maxDistance = 4;
this.selectDistance = null; this.selectDistance = null;
this.minPrice = 0; this.minPrice = 1;
this.maxPrice = 20; this.maxPrice = 4;
this.selectPrice = null; this.selectPrice = 0;
this.selectPmr = false; this.selectPmr = false;
this.selectEmporter = false; this.selectEmporter = false;
@ -51,8 +51,10 @@ export class FiltersPageComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => { this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
this.listRestau = restaurants; this.listRestau = restaurants;
console.log(this.listRestau);
}); });
console.log(this.listRestau);
} }
@ -85,13 +87,22 @@ onSendRating() {
} }
onSendFilters(){ onSendFilters() : void{
console.log("Distance :" ,this.selectDistance); let restaus = this.listRestau;
console.log("Prix :" ,this.selectPrice);
console.log("Sur Place :" ,this.selectSurPlace); restaus = restaus.filter((restau)=>
console.log("A emporter :" ,this.selectEmporter);
console.log("PMR :" ,this.selectPmr); this.selectPrice == restau.prix
console.log("avis :" ,this.selectRating);
),
console.log( this.activatedRoute.snapshot.routeConfig?.path);
this.apiBackService.setListRestau(restaus, this.activatedRoute.snapshot.routeConfig?.path);
// on fait passer en second parametre le path de la route c'est a dire "filtres"
this.route.navigate(['restaurants']);
} }
} }

View File

@ -18,16 +18,9 @@ export class HomePageComponent implements OnInit {
this.apiBackService.getCategories().subscribe((listCategories: any[]) => { this.apiBackService.getCategories().subscribe((listCategories: any[]) => {
console.log(listCategories); console.log(listCategories);
// const listCategoriesLibelle = listCategories.map(
// (category) => category.libelle
// );
this.listCategories = listCategories; this.listCategories = listCategories;
}); });
console.log(this.apiBackService);
} }

View File

@ -16,12 +16,22 @@ export class RestoPageComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.apiBackService.restoByCat.subscribe((restaurants: any[]) => { // arrivée sur la restau-page depuis filtres ou home(catégories) : appel a une méthode différente du service
if(this.apiBackService.routeParam === "filtres"){
this.listRestaurants = this.apiBackService.restoFilter;
}else if(this.apiBackService.routeParam === "home"){
this.apiBackService.restoByCat.subscribe((restaurants: any[]) => {
this.listRestaurants = restaurants;
});
}else{ // si on arrive sur l'url /restaurants directement = tous les restau affichés
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
this.listRestaurants = restaurants; this.listRestaurants = restaurants;
})
}
});
} }

View File

@ -9,22 +9,32 @@ import { environment } from 'src/environments/environment';
export class ApiBackService { export class ApiBackService {
public restoByCat : Observable<any[]> = of([]); public restoByCat : Observable<any[]> = of([]);
public restoFilter : any[];
public routeParam ?: string;
constructor(private httpClient: HttpClient) { constructor(private httpClient: HttpClient) {
this.restoFilter = [];
this.routeParam = "";
} }
getRestaurants(): Observable<any[]> { getRestaurants(): Observable<any[]> {
return this.httpClient.get<any[]>(`${environment.apiUrl}/restaurants`); return this.httpClient.get<any[]>(`${environment.apiUrl}/restaurants`);
} }
getRestaurantsByCateg(id : number): void { getRestaurantsByCateg(id : number, routeParam ?: string ): void {
this.restoByCat = this.httpClient.get<any[]>(`${environment.apiUrl}/restaurantbytype/${id}`); this.restoByCat = this.httpClient.get<any[]>(`${environment.apiUrl}/restaurantbytype/${id}`);
this.routeParam = routeParam;
} }
getCategories(): Observable<any[]>{ getCategories(): Observable<any[]>{
return this.httpClient.get<any[]>(`${environment.apiUrl}/types`); return this.httpClient.get<any[]>(`${environment.apiUrl}/types`);
} }
setListRestau(listRestau : any[], routeParam ?: string ) : void{
this.restoFilter = listRestau;
this.routeParam = routeParam;
}
} }