From e72283e305ebc58ce40f2e4bfed6ac10f93ae407 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Wed, 2 Mar 2022 12:43:16 +0100 Subject: [PATCH] admin:crea suppr restau, search bar --- .../add-restau/add-restau.component.html | 165 ++++++------------ .../add-restau/add-restau.component.ts | 27 ++- .../update-del-restau.component.html | 12 ++ .../update-del-restau.component.scss | 0 .../update-del-restau.component.spec.ts | 25 +++ .../update-del-restau.component.ts | 38 ++++ src/app/app.component.html | 2 +- src/app/app.module.ts | 6 +- .../header-logo/header-logo.component.html | 13 ++ .../header-logo/header-logo.component.scss | 29 +++ .../header-logo/header-logo.component.spec.ts | 25 +++ .../header-logo/header-logo.component.ts | 15 ++ .../search-bar/search-bar.component.html | 19 +- .../search-bar/search-bar.component.scss | 32 ---- .../search-bar/search-bar.component.ts | 22 ++- .../admin-page/admin-page.component.html | 10 +- .../admin-page/admin-page.component.scss | 3 + src/app/pages/models/restaurant.ts | 1 + src/app/services/api-back.service.ts | 5 + 19 files changed, 276 insertions(+), 173 deletions(-) create mode 100644 src/app/admin-component/update-del-restau/update-del-restau.component.html create mode 100644 src/app/admin-component/update-del-restau/update-del-restau.component.scss create mode 100644 src/app/admin-component/update-del-restau/update-del-restau.component.spec.ts create mode 100644 src/app/admin-component/update-del-restau/update-del-restau.component.ts create mode 100644 src/app/header/components/header-logo/header-logo.component.html create mode 100644 src/app/header/components/header-logo/header-logo.component.scss create mode 100644 src/app/header/components/header-logo/header-logo.component.spec.ts create mode 100644 src/app/header/components/header-logo/header-logo.component.ts diff --git a/src/app/admin-component/add-restau/add-restau.component.html b/src/app/admin-component/add-restau/add-restau.component.html index 1c4213c..f9a446c 100644 --- a/src/app/admin-component/add-restau/add-restau.component.html +++ b/src/app/admin-component/add-restau/add-restau.component.html @@ -1,36 +1,33 @@
-

Enregistrer un restaurant

+

Enregistrer un restaurant

-
+
-
- @@ -39,44 +36,28 @@
-
-
- +
-
@@ -84,67 +65,37 @@

Sur Place :

- +
- +
- +
- +

A Emporter :

- +
- +
- +
@@ -152,43 +103,27 @@

Accès PMR :

- +
- +
- +
- +
- +
diff --git a/src/app/admin-component/add-restau/add-restau.component.ts b/src/app/admin-component/add-restau/add-restau.component.ts index bf2df6a..59c2225 100644 --- a/src/app/admin-component/add-restau/add-restau.component.ts +++ b/src/app/admin-component/add-restau/add-restau.component.ts @@ -1,7 +1,8 @@ import { Component, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; +import { Observable } from 'rxjs'; import { Restaurant } from 'src/app/pages/models/restaurant'; import { ApiBackService } from 'src/app/services/api-back.service'; @@ -15,12 +16,18 @@ export class AddRestauComponent implements OnInit { public signupForm: FormGroup; public errorMessage ?: string; + public listCategories : any[]; + public expanded = false; constructor( private router: Router, private apiBackService : ApiBackService) { this.signupForm = new FormGroup({}); + this.listCategories = []; } ngOnInit(): void { + + this.getCategories(); + this.signupForm = new FormGroup({ nomFc : new FormControl('', [Validators.required]), prixFc : new FormControl(''), @@ -31,10 +38,21 @@ export class AddRestauComponent implements OnInit { websiteFc : new FormControl('',[Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]), surPlaceFc : new FormControl(''), aEmporterFc : new FormControl(''), - accesPMRFc : new FormControl('') + accesPMRFc : new FormControl(''), + // typerestausFc : new FormControl('') }) } + public getCategories() : void{ + this.apiBackService.getCategories().subscribe((listCategories: any[]) => { + // console.log(listCategories); + + this.listCategories = listCategories; + + }); + + } + public onSubmit(): void { console.log("value : ", this.signupForm.value); console.log("form : ", this.signupForm); @@ -48,6 +66,7 @@ export class AddRestauComponent implements OnInit { const surPlaceFc = this.signupForm.value['surPlaceFc']; const aEmporterFc = this.signupForm.value['aEmporterFc']; const accesPMRFc = this.signupForm.value['accesPMRFc']; + // const typerestausFc = this.signupForm.value['typerestausFc']; const restaurant: Restaurant = { latitude: latitudeFc, @@ -59,8 +78,10 @@ export class AddRestauComponent implements OnInit { website : websiteFc, surPlace : surPlaceFc, aEmporter : aEmporterFc, - accesPMR : accesPMRFc + accesPMR : accesPMRFc, + // typerestaus : typerestausFc } + if( restaurant.latitude !== '' && restaurant.longitude !== '' && restaurant.nom !== '' && diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.html b/src/app/admin-component/update-del-restau/update-del-restau.component.html new file mode 100644 index 0000000..3a81ced --- /dev/null +++ b/src/app/admin-component/update-del-restau/update-del-restau.component.html @@ -0,0 +1,12 @@ +

Modifier/Supprimer un restaurant

+ + \ No newline at end of file diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.scss b/src/app/admin-component/update-del-restau/update-del-restau.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.spec.ts b/src/app/admin-component/update-del-restau/update-del-restau.component.spec.ts new file mode 100644 index 0000000..541118f --- /dev/null +++ b/src/app/admin-component/update-del-restau/update-del-restau.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UpdateDelRestauComponent } from './update-del-restau.component'; + +describe('UpdateDelRestauComponent', () => { + let component: UpdateDelRestauComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ UpdateDelRestauComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(UpdateDelRestauComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.ts b/src/app/admin-component/update-del-restau/update-del-restau.component.ts new file mode 100644 index 0000000..ea7d325 --- /dev/null +++ b/src/app/admin-component/update-del-restau/update-del-restau.component.ts @@ -0,0 +1,38 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Restaurant } from 'src/app/pages/models/restaurant'; +import { ApiBackService } from 'src/app/services/api-back.service'; + +@Component({ + selector: 'app-update-del-restau', + templateUrl: './update-del-restau.component.html', + styleUrls: ['./update-del-restau.component.scss'] +}) +export class UpdateDelRestauComponent implements OnInit { + + restauList : Restaurant[]; + + constructor(private apiBackService : ApiBackService) { + this.restauList = []; + } + + ngOnInit(): void { + + } + + + saveRestauList(event : any){ + console.log(event); + this.restauList = event; + } + + deleteRestau(idRestau : number | undefined){ + this.apiBackService.deleteRestau(idRestau).subscribe( + resp =>{ + + + this.restauList = this.restauList.filter(restaus => restaus.id != idRestau) + + }); + } + +} \ No newline at end of file diff --git a/src/app/app.component.html b/src/app/app.component.html index cc2f543..ea9fe72 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,4 @@ - + diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1ad877a..11e5cba 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -20,6 +20,8 @@ import { IconComponent } from './filters/icon/icon.component'; import { TemplatePageComponent } from './components/template-page/template-page.component'; import { AdminPageComponent } from './pages/admin-page/admin-page.component'; import { AddRestauComponent } from './admin-component/add-restau/add-restau.component'; +import { UpdateDelRestauComponent } from './admin-component/update-del-restau/update-del-restau.component'; +import { HeaderLogoComponent } from './header/components/header-logo/header-logo.component'; @NgModule({ declarations: [ @@ -39,7 +41,9 @@ import { AddRestauComponent } from './admin-component/add-restau/add-restau.comp SigninComponent, TemplatePageComponent, AdminPageComponent, - AddRestauComponent + AddRestauComponent, + UpdateDelRestauComponent, + HeaderLogoComponent ], imports: [ BrowserModule, diff --git a/src/app/header/components/header-logo/header-logo.component.html b/src/app/header/components/header-logo/header-logo.component.html new file mode 100644 index 0000000..1e4cff4 --- /dev/null +++ b/src/app/header/components/header-logo/header-logo.component.html @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/src/app/header/components/header-logo/header-logo.component.scss b/src/app/header/components/header-logo/header-logo.component.scss new file mode 100644 index 0000000..1202554 --- /dev/null +++ b/src/app/header/components/header-logo/header-logo.component.scss @@ -0,0 +1,29 @@ +.container-fluid +{ + padding-top: 2%; + width : 100%; + margin: auto; + padding-bottom: 0,5%; + padding-left: 0; + padding-right: 0; + max-height: 20%; + +} + +.trait{ + + width: 100%; + height: 30px; + border-bottom: 2px solid #CE0000; + position: relative; + +} + +p{ + background-color: white; + position: absolute; + top: 15px; + left: 68px; + padding : 0 10px 0 10px; + color: grey; +} \ No newline at end of file diff --git a/src/app/header/components/header-logo/header-logo.component.spec.ts b/src/app/header/components/header-logo/header-logo.component.spec.ts new file mode 100644 index 0000000..1d6d25a --- /dev/null +++ b/src/app/header/components/header-logo/header-logo.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HeaderLogoComponent } from './header-logo.component'; + +describe('HeaderLogoComponent', () => { + let component: HeaderLogoComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ HeaderLogoComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(HeaderLogoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/header/components/header-logo/header-logo.component.ts b/src/app/header/components/header-logo/header-logo.component.ts new file mode 100644 index 0000000..efe742d --- /dev/null +++ b/src/app/header/components/header-logo/header-logo.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-header-logo', + templateUrl: './header-logo.component.html', + styleUrls: ['./header-logo.component.scss'] +}) +export class HeaderLogoComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/header/components/search-bar/search-bar.component.html b/src/app/header/components/search-bar/search-bar.component.html index 48cb329..d6b56ba 100644 --- a/src/app/header/components/search-bar/search-bar.component.html +++ b/src/app/header/components/search-bar/search-bar.component.html @@ -1,14 +1,5 @@ - +
+ + +
\ No newline at end of file diff --git a/src/app/header/components/search-bar/search-bar.component.scss b/src/app/header/components/search-bar/search-bar.component.scss index 673c03c..089d9a6 100644 --- a/src/app/header/components/search-bar/search-bar.component.scss +++ b/src/app/header/components/search-bar/search-bar.component.scss @@ -1,35 +1,3 @@ -.container-fluid -{ - padding-top: 2%; - width : 100%; - margin: auto; - padding-bottom: 0,5%; - padding-left: 0; - padding-right: 0; - max-height: 20%; - -} - -.trait{ - - width: 100%; - height: 30px; - border-bottom: 2px solid #CE0000; - position: relative; - -} - -p{ - background-color: white; - position: absolute; - top: 15px; - left: 68px; - padding : 0 10px 0 10px; - color: grey; -} - - - input[type="search"], textarea{ background-color: #edf5f1; } diff --git a/src/app/header/components/search-bar/search-bar.component.ts b/src/app/header/components/search-bar/search-bar.component.ts index 1a2c8d4..933beaf 100644 --- a/src/app/header/components/search-bar/search-bar.component.ts +++ b/src/app/header/components/search-bar/search-bar.component.ts @@ -1,5 +1,6 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Restaurant } from 'src/app/pages/models/restaurant'; import { RestoPageComponent } from 'src/app/pages/resto-page/resto-page.component'; import { ApiBackService } from 'src/app/services/api-back.service'; @@ -10,11 +11,13 @@ import { ApiBackService } from 'src/app/services/api-back.service'; }) export class SearchBarComponent implements OnInit { - searchText = new EventEmitter(); listRestau: any[]; restauByName: any[]; + @Output() resultSearch = new EventEmitter(); - constructor(private apiBackService: ApiBackService, private route: Router) { + constructor(private apiBackService: ApiBackService, + private route: Router, + private activatedRoute : ActivatedRoute) { this.listRestau = []; this.restauByName = []; @@ -33,11 +36,18 @@ export class SearchBarComponent implements OnInit { this.restauByName = this.restauByName.filter((restau: any) => restau.nom.toLowerCase().includes(search.toLowerCase())); - console.log(this.restauByName); + + // Composant search-bar utilisé dans la page admin + if(this.activatedRoute.snapshot.routeConfig?.path === "admin"){ + + this.resultSearch.emit(this.restauByName); + + }else{ // la search bar utilisée dans la nav-bar pour trouver un restau this.apiBackService.setListRestau(this.restauByName, "filtres"); - this.route.routeReuseStrategy.shouldReuseRoute= () => false; - this.route.onSameUrlNavigation = 'reload'; + //this.route.routeReuseStrategy.shouldReuseRoute= () => false; + // this.route.onSameUrlNavigation = 'reload'; this.route.navigate(['restaurants']); + } } } diff --git a/src/app/pages/admin-page/admin-page.component.html b/src/app/pages/admin-page/admin-page.component.html index 1e715de..184fccc 100644 --- a/src/app/pages/admin-page/admin-page.component.html +++ b/src/app/pages/admin-page/admin-page.component.html @@ -1 +1,9 @@ - \ No newline at end of file +
+
+ +
+ +
+
\ No newline at end of file diff --git a/src/app/pages/admin-page/admin-page.component.scss b/src/app/pages/admin-page/admin-page.component.scss index e69de29..8e1cebc 100644 --- a/src/app/pages/admin-page/admin-page.component.scss +++ b/src/app/pages/admin-page/admin-page.component.scss @@ -0,0 +1,3 @@ +.search-bar{ + width : 30%; +} \ No newline at end of file diff --git a/src/app/pages/models/restaurant.ts b/src/app/pages/models/restaurant.ts index 272f5e9..d8faa52 100644 --- a/src/app/pages/models/restaurant.ts +++ b/src/app/pages/models/restaurant.ts @@ -10,4 +10,5 @@ export interface Restaurant { aEmporter?: boolean; accesPMR?: boolean; surPlace?: boolean; + typerestaus ?: any[]; } diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts index 696cc0f..b5c5c96 100644 --- a/src/app/services/api-back.service.ts +++ b/src/app/services/api-back.service.ts @@ -64,4 +64,9 @@ export class ApiBackService { } + deleteRestau( idRestau : number | undefined) : Observable{ + + return this.httpClient.delete(`${environment.apiUrl}/delete-restaurant/${idRestau}`); + } + }