modif restau manque checkbox
This commit is contained in:
parent
500ba0811a
commit
9fe71c85d9
@ -78,17 +78,17 @@
|
|||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<p class="text-left"> Sur Place :</p>
|
<p class="text-left"> Sur Place :</p>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxSurPlaceTrue" name="surPlaceFc" value=true
|
<input type="radio" class="form-check-input" id="checkboxSurPlaceTrue" name="surPlaceFc" [value]="true"
|
||||||
formControlName="surPlaceFc">
|
formControlName="surPlaceFc">
|
||||||
<label class="form-check-label" for="checkboxSurPlaceTrue">Oui</label>
|
<label class="form-check-label" for="checkboxSurPlaceTrue">Oui</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxSurPlaceFalse" name="surPlaceFc"
|
<input type="radio" class="form-check-input" id="checkboxSurPlaceFalse" name="surPlaceFc"
|
||||||
value=false formControlName="surPlaceFc">
|
[value]="false" formControlName="surPlaceFc">
|
||||||
<label class="form-check-label" for="checkboxSurPlaceFalse">Non</label>
|
<label class="form-check-label" for="checkboxSurPlaceFalse">Non</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxSurPlaceNull" name="surPlaceFc" value=null
|
<input type="radio" class="form-check-input" id="checkboxSurPlaceNull" name="surPlaceFc" [value]="null"
|
||||||
formControlName="surPlaceFc">
|
formControlName="surPlaceFc">
|
||||||
<label class="form-check-label" for="checkboxSurPlaceNull">Pas d'infos</label>
|
<label class="form-check-label" for="checkboxSurPlaceNull">Pas d'infos</label>
|
||||||
</div>
|
</div>
|
||||||
@ -98,17 +98,17 @@
|
|||||||
<p class="text-left"> A Emporter :</p>
|
<p class="text-left"> A Emporter :</p>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAEmporterTrue" name="aEmporterFc"
|
<input type="radio" class="form-check-input" id="checkboxAEmporterTrue" name="aEmporterFc"
|
||||||
value=true formControlName="aEmporterFc">
|
[value]="true" formControlName="aEmporterFc">
|
||||||
<label class="form-check-label" for="checkboxAEmporterTrue">Oui</label>
|
<label class="form-check-label" for="checkboxAEmporterTrue">Oui</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAEmporterFalse" name="aEmporterFc"
|
<input type="radio" class="form-check-input" id="checkboxAEmporterFalse" name="aEmporterFc"
|
||||||
value=false formControlName="aEmporterFc">
|
[value]="false" formControlName="aEmporterFc">
|
||||||
<label class="form-check-label" for="checkboxAEmporterFalse">Non</label>
|
<label class="form-check-label" for="checkboxAEmporterFalse">Non</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAEmporterNull" name="aEmporterFc"
|
<input type="radio" class="form-check-input" id="checkboxAEmporterNull" name="aEmporterFc"
|
||||||
value=null formControlName="aEmporterFc">
|
[value]="null" formControlName="aEmporterFc">
|
||||||
<label class="form-check-label" for="checkboxAEmporterNull">Pas d'infos</label>
|
<label class="form-check-label" for="checkboxAEmporterNull">Pas d'infos</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -116,17 +116,17 @@
|
|||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<p class="text-left"> Accès PMR :</p>
|
<p class="text-left"> Accès PMR :</p>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAccesPMRTrue" name="accesPMRFc" value=true
|
<input type="radio" class="form-check-input" id="checkboxAccesPMRTrue" name="accesPMRFc" [value]="true"
|
||||||
formControlName="accesPMRFc">
|
formControlName="accesPMRFc">
|
||||||
<label class="form-check-label" for="checkboxAccesPMRTrue">Oui</label>
|
<label class="form-check-label" for="checkboxAccesPMRTrue">Oui</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAccesPMRFalse" name="accesPMRFc"
|
<input type="radio" class="form-check-input" id="checkboxAccesPMRFalse" name="accesPMRFc"
|
||||||
value=false formControlName="accesPMRFc">
|
[value]="false" formControlName="accesPMRFc">
|
||||||
<label class="form-check-label" for="checkboxAccesPMRFalse">Non</label>
|
<label class="form-check-label" for="checkboxAccesPMRFalse">Non</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input type="radio" class="form-check-input" id="checkboxAccesPMRNull" name="accesPMRFc" value=null
|
<input type="radio" class="form-check-input" id="checkboxAccesPMRNull" name="accesPMRFc" [value]="null"
|
||||||
formControlName="accesPMRFc">
|
formControlName="accesPMRFc">
|
||||||
<label class="form-check-label" for="checkboxAccesPMRNull">Pas d'infos</label>
|
<label class="form-check-label" for="checkboxAccesPMRNull">Pas d'infos</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, Subscription } from 'rxjs';
|
||||||
import { Restaurant } from 'src/app/pages/models/restaurant';
|
import { Restaurant } from 'src/app/pages/models/restaurant';
|
||||||
import { ApiBackService } from 'src/app/services/api-back.service';
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ export class AddRestauComponent implements OnInit {
|
|||||||
public errorMessage?: string;
|
public errorMessage?: string;
|
||||||
public listCategories$: Observable<any[]>;
|
public listCategories$: Observable<any[]>;
|
||||||
public expanded = false;
|
public expanded = false;
|
||||||
|
public idRestau : Subscription | undefined;
|
||||||
|
|
||||||
constructor(private router: Router, private apiBackService: ApiBackService) {
|
constructor(private router: Router, private apiBackService: ApiBackService) {
|
||||||
this.signupForm = new FormGroup({});
|
this.signupForm = new FormGroup({});
|
||||||
@ -38,6 +39,36 @@ export class AddRestauComponent implements OnInit {
|
|||||||
accesPMRFc: new FormControl(''),
|
accesPMRFc: new FormControl(''),
|
||||||
typerestausFc: new FormArray([])
|
typerestausFc: new FormArray([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.idRestau = this.apiBackService.restauAModif.subscribe(restau => {
|
||||||
|
|
||||||
|
|
||||||
|
// const formArray: FormArray = this.signupForm.get('typerestausFc') as FormArray;
|
||||||
|
// if(restau.typerestaus != undefined){
|
||||||
|
// for (let index = 0; index < restau.typerestaus.length; index++) {
|
||||||
|
// //listCategories.filter(categorie => categorie.id == restau.typerestaus[index]['id'])
|
||||||
|
// this.signupForm.patchValue({typerestausFc : {restau.typerestaus[index]['id'] : true}});
|
||||||
|
// formArray.push(new FormControl(restau.typerestaus[index]['id'] : true));
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// console.log(formArray);
|
||||||
|
|
||||||
|
this.signupForm = new FormGroup({
|
||||||
|
nomFc: new FormControl(restau.nom, [Validators.required]),
|
||||||
|
prixFc: new FormControl(restau.prix),
|
||||||
|
longitudeFc: new FormControl(restau.longitude, [Validators.required,]), // chercher une meilleure regex
|
||||||
|
latitudeFc: new FormControl(restau.latitude, [Validators.required]),
|
||||||
|
adresseFc: new FormControl(restau.adresse, [Validators.required]),
|
||||||
|
telephoneFc: new FormControl(restau.telephone),
|
||||||
|
websiteFc: new FormControl(restau.website, [Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]),
|
||||||
|
surPlaceFc: new FormControl(restau.surPlace),
|
||||||
|
aEmporterFc: new FormControl(restau.aEmporter),
|
||||||
|
accesPMRFc: new FormControl(restau.accesPMR),
|
||||||
|
typerestausFc: new FormArray([])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCategories(): Observable<any[]> {
|
public getCategories(): Observable<any[]> {
|
||||||
@ -117,5 +148,12 @@ export class AddRestauComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
if (this.idRestau) {
|
||||||
|
this.idRestau.unsubscribe();
|
||||||
|
this.idRestau = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,8 @@
|
|||||||
{{restau.nom}}
|
{{restau.nom}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<button class="btn btn-warning" type="button" (click)="modifRestau(restau)"><i class="bi bi-gear"></i></button>
|
||||||
<button class="btn btn-danger" type="button" (click)="deleteRestau(restau.id)"><i class="bi bi-trash"></i></button>
|
<button class="btn btn-danger" type="button" (click)="deleteRestau(restau.id)"><i class="bi bi-trash"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<button class="btn btn-warn" type="button" (click)="modifRestau(restau.id)"><i class="bi bi-gear"></i></button>
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
@ -10,7 +10,6 @@ import { ApiBackService } from 'src/app/services/api-back.service';
|
|||||||
export class UpdateDelRestauComponent implements OnInit {
|
export class UpdateDelRestauComponent implements OnInit {
|
||||||
|
|
||||||
restauList : Restaurant[];
|
restauList : Restaurant[];
|
||||||
@Output() idRestauAModif = new EventEmitter<number>();
|
|
||||||
|
|
||||||
constructor(private apiBackService : ApiBackService) {
|
constructor(private apiBackService : ApiBackService) {
|
||||||
this.restauList = [];
|
this.restauList = [];
|
||||||
@ -36,8 +35,8 @@ export class UpdateDelRestauComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
modifRestau(idRestau : number | undefined){
|
modifRestau(restau : Restaurant){
|
||||||
this.idRestauAModif.emit(idRestau);
|
this.apiBackService.idRestauAModifier(restau);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ const routes: Routes = [
|
|||||||
{ path: 'favoris', component: FavorisUserComponent },
|
{ path: 'favoris', component: FavorisUserComponent },
|
||||||
{ path: 'filtres', component: FiltersPageComponent },
|
{ path: 'filtres', component: FiltersPageComponent },
|
||||||
{ path: 'Deconnexion', redirectTo: 'home'},
|
{ path: 'Deconnexion', redirectTo: 'home'},
|
||||||
{path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent},
|
{path: 'restaurants', canActivate: [AuthGuard], /*data : {ROLE : "ROLE_ADMIN"},*/ component: RestoPageComponent},
|
||||||
{path: 'page-not-found',component: PageNotFoundComponent},
|
{path: 'page-not-found',component: PageNotFoundComponent},
|
||||||
{path: 'admin', component: AdminPageComponent},
|
{path: 'admin', component: AdminPageComponent},
|
||||||
{path: '**', redirectTo: 'page-not-found' }
|
{path: '**', redirectTo: 'page-not-found' }
|
||||||
|
@ -17,7 +17,7 @@ export class NavBarComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCloseSession() : void {
|
onCloseSession() : void {
|
||||||
this.tokenService.destroyToken();
|
this.tokenService.destroyToken(this.tokenKey);
|
||||||
this.route.navigate(['signin']);
|
this.route.navigate(['signin']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex flex-row justify-content-around"><div>
|
<div class="d-flex flex-row justify-content-around"><div>
|
||||||
<app-add-restau ></app-add-restau>
|
<app-add-restau (getIdRestau)="sendId"></app-add-restau>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<app-update-del-restau ></app-update-del-restau>
|
<app-update-del-restau ></app-update-del-restau>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, EventEmitter, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ApiBackService } from 'src/app/services/api-back.service';
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
@ -11,6 +11,7 @@ import { Restaurant } from '../models/restaurant';
|
|||||||
})
|
})
|
||||||
export class AdminPageComponent implements OnInit {
|
export class AdminPageComponent implements OnInit {
|
||||||
|
|
||||||
|
sendId = new EventEmitter<number>();
|
||||||
|
|
||||||
constructor( ) {
|
constructor( ) {
|
||||||
|
|
||||||
@ -18,6 +19,9 @@ export class AdminPageComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
sendIdRestau(idRestau : number){
|
||||||
|
this.sendId.emit(idRestau);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Injectable, Input } from '@angular/core';
|
import { EventEmitter, Injectable, Input } from '@angular/core';
|
||||||
import { Observable, of, Subject } from 'rxjs';
|
import { Observable, of, Subject } from 'rxjs';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
@ -15,6 +15,7 @@ export class ApiBackService {
|
|||||||
public restoFilter: any[];
|
public restoFilter: any[];
|
||||||
public routeParam?: string;
|
public routeParam?: string;
|
||||||
@Input() restaurant: any;
|
@Input() restaurant: any;
|
||||||
|
public restauAModif = new EventEmitter<Restaurant>();
|
||||||
|
|
||||||
constructor(private httpClient: HttpClient) {
|
constructor(private httpClient: HttpClient) {
|
||||||
this.restoFilter = [];
|
this.restoFilter = [];
|
||||||
@ -70,4 +71,10 @@ export class ApiBackService {
|
|||||||
return this.httpClient.get<User>(`${environment.apiUrl}/user/${id}`);
|
return this.httpClient.get<User>(`${environment.apiUrl}/user/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public idRestauAModifier(restau:Restaurant): void {
|
||||||
|
|
||||||
|
this.restauAModif.emit(restau);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import { TokenService } from './token.service';
|
|||||||
})
|
})
|
||||||
export class AuthGuard implements CanActivate {
|
export class AuthGuard implements CanActivate {
|
||||||
private tokenKey: string;
|
private tokenKey: string;
|
||||||
|
|
||||||
constructor(private router: Router, private tokenService : TokenService){
|
constructor(private router: Router, private tokenService : TokenService){
|
||||||
this.tokenKey = environment.tokenKey;
|
this.tokenKey = environment.tokenKey;
|
||||||
}
|
}
|
||||||
@ -23,6 +24,9 @@ export class AuthGuard implements CanActivate {
|
|||||||
|
|
||||||
if(token) {
|
if(token) {
|
||||||
const decodedToken = jwt_decode<any>(token);
|
const decodedToken = jwt_decode<any>(token);
|
||||||
|
|
||||||
|
// TODO boucle sur le ['auth'] pour controler le role et en fonction de ca renvoyer true ou false ac redirection page403
|
||||||
|
|
||||||
|
|
||||||
console.log('decodedToken : ', decodedToken);
|
console.log('decodedToken : ', decodedToken);
|
||||||
|
|
||||||
@ -31,7 +35,7 @@ export class AuthGuard implements CanActivate {
|
|||||||
const dateExp = new Date(decodedToken.exp * 1000);
|
const dateExp = new Date(decodedToken.exp * 1000);
|
||||||
if(new Date() >= dateExp) {
|
if(new Date() >= dateExp) {
|
||||||
// le token a expiré, je n'autorise pas l'accès
|
// le token a expiré, je n'autorise pas l'accès
|
||||||
this.tokenService.destroyToken();
|
this.tokenService.destroyToken(this.tokenKey);
|
||||||
this.router.navigate(['signin']);
|
this.router.navigate(['signin']);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ export class AuthService {
|
|||||||
console.log('Service : ', x.token);
|
console.log('Service : ', x.token);
|
||||||
// Modification à faire ici
|
// Modification à faire ici
|
||||||
localStorage.setItem(this.tokenKey, x.token);
|
localStorage.setItem(this.tokenKey, x.token);
|
||||||
|
//localStorage.setItem('ROLE', "ROLE_READER");
|
||||||
return x; // permet de renvoyer la réponse à l'initiateur (page Signin) après le traitement du map
|
return x; // permet de renvoyer la réponse à l'initiateur (page Signin) après le traitement du map
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -33,7 +33,8 @@ export class TokenService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public destroyToken(): void {
|
public destroyToken(tokenKey : string): void {
|
||||||
localStorage.removeItem(this.tokenKey);
|
localStorage.removeItem(tokenKey);
|
||||||
|
localStorage.removeItem('ROLE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user