diff --git a/src/app/admin-component/add-restau/add-restau.component.html b/src/app/admin-component/add-restau/add-restau.component.html
new file mode 100644
index 0000000..1c4213c
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.html
@@ -0,0 +1,195 @@
+
\ No newline at end of file
diff --git a/src/app/admin-component/add-restau/add-restau.component.scss b/src/app/admin-component/add-restau/add-restau.component.scss
new file mode 100644
index 0000000..8778894
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.scss
@@ -0,0 +1,36 @@
+.login-form {
+ height: 100vh;
+ padding-top: 40px;
+ background-color: #f5f5f5;
+}
+
+.form-signup {
+ width: 100%;
+ max-width: 350px;
+ padding: 15px;
+ margin: auto;
+}
+
+.form-signup .checkbox {
+ font-weight: 400;
+}
+
+.form-signup .form-floating:focus-within {
+ z-index: 2;
+}
+
+.form-signup input[type="email"] {
+ margin-bottom: -1px;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
+.form-signup input[type="password"] {
+ margin-bottom: 10px;
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
+}
+
+.text-left{
+ text-align: left;
+}
\ No newline at end of file
diff --git a/src/app/admin-component/add-restau/add-restau.component.spec.ts b/src/app/admin-component/add-restau/add-restau.component.spec.ts
new file mode 100644
index 0000000..f2d6986
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AddRestauComponent } from './add-restau.component';
+
+describe('AddRestauComponent', () => {
+ let component: AddRestauComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ AddRestauComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AddRestauComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/admin-component/add-restau/add-restau.component.ts b/src/app/admin-component/add-restau/add-restau.component.ts
new file mode 100644
index 0000000..bf2df6a
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.ts
@@ -0,0 +1,81 @@
+
+import { Component, OnInit } from '@angular/core';
+import { FormControl, FormGroup, Validators } from '@angular/forms';
+import { Router } from '@angular/router';
+import { Restaurant } from 'src/app/pages/models/restaurant';
+import { ApiBackService } from 'src/app/services/api-back.service';
+
+@Component({
+ selector: 'app-add-restau',
+ templateUrl: './add-restau.component.html',
+ styleUrls: ['./add-restau.component.scss']
+})
+export class AddRestauComponent implements OnInit {
+
+
+ public signupForm: FormGroup;
+ public errorMessage ?: string;
+
+ constructor( private router: Router, private apiBackService : ApiBackService) {
+ this.signupForm = new FormGroup({});
+ }
+
+ ngOnInit(): void {
+ this.signupForm = new FormGroup({
+ nomFc : new FormControl('', [Validators.required]),
+ prixFc : new FormControl(''),
+ longitudeFc : new FormControl('', [Validators.required,]), // chercher une meilleure regex
+ latitudeFc : new FormControl('', [Validators.required]),
+ adresseFc : new FormControl('', [Validators.required]),
+ telephoneFc : new FormControl(''),
+ 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('')
+ })
+ }
+
+ public onSubmit(): void {
+ console.log("value : ", this.signupForm.value);
+ console.log("form : ", this.signupForm);
+ const nomFc = this.signupForm.value['nomFc'];
+ const prixFc = this.signupForm.value['prixFc'];
+ const longitudeFc = this.signupForm.value['longitudeFc'];
+ const latitudeFc = this.signupForm.value['latitudeFc'];
+ const adresseFc = this.signupForm.value['adresseFc'];
+ const telephoneFc = this.signupForm.value['telephoneFc'];
+ const websiteFc = this.signupForm.value['websiteFc'];
+ const surPlaceFc = this.signupForm.value['surPlaceFc'];
+ const aEmporterFc = this.signupForm.value['aEmporterFc'];
+ const accesPMRFc = this.signupForm.value['accesPMRFc'];
+
+ const restaurant: Restaurant = {
+ latitude: latitudeFc,
+ longitude: longitudeFc,
+ nom : nomFc,
+ prix: prixFc,
+ adresse : adresseFc,
+ telephone : telephoneFc,
+ website : websiteFc,
+ surPlace : surPlaceFc,
+ aEmporter : aEmporterFc,
+ accesPMR : accesPMRFc
+ }
+ if( restaurant.latitude !== '' &&
+ restaurant.longitude !== '' &&
+ restaurant.nom !== '' &&
+ restaurant.adresse !== '' ) {
+ this.apiBackService.addRestaurant(restaurant).subscribe(
+ resp=>
+
+ this.router.navigate(['restaurants'])
+ );
+ }else{
+
+ this.errorMessage = "Renseigner les champs obligatoires **";
+ }
+
+ }
+
+}
+
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 97ed3a3..d6925dd 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -7,6 +7,7 @@ import { RestoPageComponent } from './pages/resto-page/resto-page.component';
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
import { FiltersPageComponent } from './pages/filters-page/filters-page.component';
import { SigninComponent } from './pages/signin/signin.component';
+import { AdminPageComponent } from './pages/admin-page/admin-page.component';
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
@@ -18,6 +19,7 @@ const routes: Routes = [
{path: 'restaurants',component: RestoPageComponent},
{path: 'page-not-found',component: PageNotFoundComponent},
{path: 'signin', component: SigninComponent},
+ {path: 'admin', component: AdminPageComponent},
{path: '**', redirectTo: 'page-not-found' }
];
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index d7a4ae2..1ad877a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
-import { FormsModule } from '@angular/forms';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NavBarComponent } from './header/components/nav-bar/nav-bar.component';
@@ -18,6 +18,8 @@ import { FiltersPageComponent } from './pages/filters-page/filters-page.componen
import { AvisBarComponent } from './filters/avis-bar/avis-bar.component';
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';
@NgModule({
declarations: [
@@ -35,13 +37,16 @@ import { TemplatePageComponent } from './components/template-page/template-page.
AvisBarComponent,
IconComponent,
SigninComponent,
- TemplatePageComponent
+ TemplatePageComponent,
+ AdminPageComponent,
+ AddRestauComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
+ ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/app/card-resto/card-resto.component.html b/src/app/card-resto/card-resto.component.html
index c92f701..2baae9e 100644
--- a/src/app/card-resto/card-resto.component.html
+++ b/src/app/card-resto/card-resto.component.html
@@ -39,14 +39,20 @@
{{distance}}m
+
+
+ {{ priceRef[restaurant.prix] }}
+
-
- 5-10€
-
+
+
@@ -60,30 +66,54 @@
-
-
Sur place :
-
-
A emporter :
-
-
+
+
+
+
+ Sur place :
+ Infos non disponible.
+
+
+
+
+ A emporter :
+ Infos non disponible.
+
+
Accès PMR :
-
+
+
+
+ Infos non disponible.
+
+
+
+
+
diff --git a/src/app/card-resto/card-resto.component.ts b/src/app/card-resto/card-resto.component.ts
index eb43bee..5e11ace 100644
--- a/src/app/card-resto/card-resto.component.ts
+++ b/src/app/card-resto/card-resto.component.ts
@@ -13,15 +13,15 @@ export class CardRestoComponent implements OnInit {
@Input() likeResto: any;
@Output() clickLike = new EventEmitter();
isLiked : boolean = false;
+ priceRef = ["Info indisponible","1-10€ ","11-20€","21-30€","31-40€"];
constructor(private apiBackService : ApiBackService) {
this.distance = 0 ;
+
}
ngOnInit(): void {
- console.log(this.restaurant);
-
this.distance = Math.round(
this.apiBackService.setDistance(
48.86201110271593 , //latitude Simplon
@@ -29,10 +29,7 @@ export class CardRestoComponent implements OnInit {
this.restaurant.latitude,
this.restaurant.longitude)
);
-
- console.log(this.distance);
-
-
+
}
onClickLike() {
console.log('click');
diff --git a/src/app/pages/admin-page/admin-page.component.html b/src/app/pages/admin-page/admin-page.component.html
new file mode 100644
index 0000000..1e715de
--- /dev/null
+++ b/src/app/pages/admin-page/admin-page.component.html
@@ -0,0 +1 @@
+
\ 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
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/pages/admin-page/admin-page.component.spec.ts b/src/app/pages/admin-page/admin-page.component.spec.ts
new file mode 100644
index 0000000..9e9cb02
--- /dev/null
+++ b/src/app/pages/admin-page/admin-page.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AdminPageComponent } from './admin-page.component';
+
+describe('AdminPageComponent', () => {
+ let component: AdminPageComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ AdminPageComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AdminPageComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/pages/admin-page/admin-page.component.ts b/src/app/pages/admin-page/admin-page.component.ts
new file mode 100644
index 0000000..e431721
--- /dev/null
+++ b/src/app/pages/admin-page/admin-page.component.ts
@@ -0,0 +1,23 @@
+import { Component, OnInit } from '@angular/core';
+import { FormControl, FormGroup, Validators } from '@angular/forms';
+import { Router } from '@angular/router';
+import { ApiBackService } from 'src/app/services/api-back.service';
+import { Restaurant } from '../models/restaurant';
+
+@Component({
+ selector: 'app-admin-page',
+ templateUrl: './admin-page.component.html',
+ styleUrls: ['./admin-page.component.scss']
+})
+export class AdminPageComponent implements OnInit {
+
+
+ constructor( ) {
+
+ }
+
+ ngOnInit(): void {
+ }
+
+
+}
diff --git a/src/app/pages/models/restaurant.ts b/src/app/pages/models/restaurant.ts
new file mode 100644
index 0000000..272f5e9
--- /dev/null
+++ b/src/app/pages/models/restaurant.ts
@@ -0,0 +1,13 @@
+export interface Restaurant {
+ id?:number;
+ nom: string;
+ adresse: string;
+ prix?: number;
+ latitude: string;
+ longitude: string;
+ telephone ?: string;
+ website ?: string;
+ aEmporter?: boolean;
+ accesPMR?: boolean;
+ surPlace?: boolean;
+}
diff --git a/src/app/pages/resto-page/resto-page.component.ts b/src/app/pages/resto-page/resto-page.component.ts
index 62ec299..4b1aee8 100644
--- a/src/app/pages/resto-page/resto-page.component.ts
+++ b/src/app/pages/resto-page/resto-page.component.ts
@@ -31,6 +31,9 @@ export class RestoPageComponent implements OnInit {
})
}
+ console.log(this.apiBackService);
+
+
diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts
index a6ad8f2..696cc0f 100644
--- a/src/app/services/api-back.service.ts
+++ b/src/app/services/api-back.service.ts
@@ -2,6 +2,7 @@ import { Injectable, Input } from '@angular/core';
import { Observable, of, Subject } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
+import { Restaurant } from '../pages/models/restaurant';
@Injectable({
providedIn: 'root'
@@ -57,7 +58,10 @@ export class ApiBackService {
deg2rad(deg : number) {
return deg * (Math.PI/180)
}
- }
-
-
+
+ addRestaurant( newRestau : Restaurant) : Observable{
+ return this.httpClient.post(`${environment.apiUrl}/add-restaurant`, newRestau);
+
+ }
+}