diff --git a/frontend/.dockerignore b/frontend/.dockerignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/frontend/.dockerignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index b7a38d3..62f93b6 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -2,13 +2,15 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import {PublicComponent} from "./components/public/public.component";
import {PrivateComponent} from "./components/private/private.component";
-import {AuthGuard} from "./guards/auth.guard";
-//import { AuthGuard } from '@auth0/auth0-angular';
+//import {AuthGuard} from "./guards/auth.guard";
+import { AuthGuard } from '@auth0/auth0-angular';
+import {AgregarResComponent} from "./components/agregar-res/agregar-res.component";
const routes: Routes = [
{ path: 'public', component:PublicComponent},
{ path: 'private', component:PrivateComponent, canActivate: [AuthGuard]},
+ {path: 'agregar.res', component:AgregarResComponent, canActivate:[AuthGuard]},
{path: '**', pathMatch: 'full', redirectTo: 'public'}
];
diff --git a/frontend/src/app/app.component.html b/frontend/src/app/app.component.html
index 5f1cebb..18618ef 100644
--- a/frontend/src/app/app.component.html
+++ b/frontend/src/app/app.component.html
@@ -9,6 +9,9 @@
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts
index 48a962b..ea391c9 100644
--- a/frontend/src/app/app.component.ts
+++ b/frontend/src/app/app.component.ts
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import {AuthService} from "@auth0/auth0-angular";
+
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index 4e595cd..0af38e9 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -1,18 +1,20 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
-
+import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
-
-import { AuthModule } from '@auth0/auth0-angular';
+import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
+import { AuthModule, AuthHttpInterceptor } from '@auth0/auth0-angular';
import { PublicComponent } from './components/public/public.component';
import { PrivateComponent } from './components/private/private.component';
+import { AgregarResComponent } from './components/agregar-res/agregar-res.component';
@NgModule({
declarations: [
AppComponent,
PublicComponent,
- PrivateComponent
+ PrivateComponent,
+ AgregarResComponent
],
imports: [
BrowserModule,
@@ -21,10 +23,33 @@ import { PrivateComponent } from './components/private/private.component';
domain: 'dev-ygnrzo5i.us.auth0.com',
clientId: '2MCYrmwNWAkeJyYYYRCS1gscDbiwAIfq',
cacheLocation: 'localstorage',
- useRefreshTokens:true
+ useRefreshTokens:true,
+ audience: 'https://api.unified.restaurant',
+ scope: 'read:current_user',
+ httpInterceptor:{
+ allowedList: [
+ {
+ // Match any request that starts 'https://dev-6scsp8es.us.auth0.com/api/v2/' (note the asterisk)
+ uri: 'https://api.unified.restaurant/api/v1/*',
+ tokenOptions: {
+ // The attached token should target this audience
+ audience: 'https://api.unified.restaurant',
+
+ // The attached token should have these scopes
+ scope: 'read:current_user'
+ }
+ }
+ ]
+ }
}),
+
+
+ HttpClientModule,
+ FormsModule
+ ],
+ providers: [
+ { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true }
],
- providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
diff --git a/frontend/src/app/components/agregar-res/agregar-res.component.html b/frontend/src/app/components/agregar-res/agregar-res.component.html
new file mode 100644
index 0000000..ee4c720
--- /dev/null
+++ b/frontend/src/app/components/agregar-res/agregar-res.component.html
@@ -0,0 +1,33 @@
+
+
+
+ | id | nombre | creacion | modificacion |
+
+
+
+
+ | {{r.id}} |
+ {{r.nombre}} |
+ {{r['created_at']}} |
+ {{r['updated_at']}} |
+
+
+
+
+
+
+
+
+ nombre:
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/app/components/agregar-res/agregar-res.component.scss b/frontend/src/app/components/agregar-res/agregar-res.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/components/agregar-res/agregar-res.component.ts b/frontend/src/app/components/agregar-res/agregar-res.component.ts
new file mode 100644
index 0000000..1dc1a6f
--- /dev/null
+++ b/frontend/src/app/components/agregar-res/agregar-res.component.ts
@@ -0,0 +1,47 @@
+import { Component, OnInit } from '@angular/core';
+import {RestaurantesService} from "../../restaurantes.service";
+
+@Component({
+ selector: 'app-agregar-res',
+ templateUrl: './agregar-res.component.html',
+ styleUrls: ['./agregar-res.component.scss']
+})
+export class AgregarResComponent implements OnInit {
+
+ restaurante: any;
+
+ agre={
+ nombre:null
+
+ }
+
+ constructor(private restaurantServ : RestaurantesService) { }
+
+ ngOnInit(): void {
+ this.recuperartodos();
+
+ }
+ recuperartodos(){
+ this.restaurantServ.mostrarTodosRes().subscribe(result => this.restaurante = result);
+ }
+ agregarRes(){
+ this.restaurantServ.agregar(this.agre).subscribe(this.recuperartodos)
+ }
+ eliminarRes(id:any){
+ console.log(id);
+ this.restaurantServ.eliminar(id).subscribe()
+
+ }
+ modificarRes(id:any){
+ console.log(id,this.agre)
+
+ this.restaurantServ.modificar(id,this.agre).subscribe();
+ }
+
+
+
+ hayregistro(){
+ return true;
+ }
+
+}
diff --git a/frontend/src/app/components/private/private.component.html b/frontend/src/app/components/private/private.component.html
index c0b80bb..a7b776c 100644
--- a/frontend/src/app/components/private/private.component.html
+++ b/frontend/src/app/components/private/private.component.html
@@ -1,5 +1,5 @@
-
+
- {{user | json}}
+ {{dato | json}}
diff --git a/frontend/src/app/components/private/private.component.ts b/frontend/src/app/components/private/private.component.ts
index 553fa8e..e6c07e7 100644
--- a/frontend/src/app/components/private/private.component.ts
+++ b/frontend/src/app/components/private/private.component.ts
@@ -1,16 +1,31 @@
import { Component, OnInit } from '@angular/core';
import {AuthService} from "@auth0/auth0-angular";
+import { concatMap, tap, pluck } from 'rxjs/operators';
+import { HttpClient } from '@angular/common/http';
+
@Component({
selector: 'app-private',
templateUrl: './private.component.html',
styleUrls: ['./private.component.scss']
})
export class PrivateComponent implements OnInit {
+ dato = {};
- constructor(public auth: AuthService) { }
+ constructor(public auth: AuthService, private http: HttpClient) { }
ngOnInit(): void {
+
+ this.auth.user$
+ .pipe(
+ tap((user)=>console.log(user)),
+ concatMap((user)=>
+ this.http.get(`https://api.unified.restaurant/api/v1/users/${user?.sub}`)
+ ),
+ tap((userdato) =>(this.dato = userdato))
+ ).subscribe();
+ console.log();
+
}
}
diff --git a/frontend/src/app/restaurantes.service.spec.ts b/frontend/src/app/restaurantes.service.spec.ts
new file mode 100644
index 0000000..b5c5d98
--- /dev/null
+++ b/frontend/src/app/restaurantes.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { RestaurantesService } from './restaurantes.service';
+
+describe('RestaurantesService', () => {
+ let service: RestaurantesService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(RestaurantesService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/restaurantes.service.ts b/frontend/src/app/restaurantes.service.ts
new file mode 100644
index 0000000..ee5276e
--- /dev/null
+++ b/frontend/src/app/restaurantes.service.ts
@@ -0,0 +1,35 @@
+import { Injectable } from '@angular/core';
+
+import {HttpClient, HttpHeaders} from "@angular/common/http";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RestaurantesService {
+
+ url='https://api.unified.restaurant/api/v1';
+
+ constructor(private http: HttpClient) { }
+
+ mostrarTodosRes(){
+ return this.http.get(`${this.url}/restaurantes`);
+ }
+
+ agregar(AgreRestaurant:any){
+ const headers: HttpHeaders = new HttpHeaders({
+ 'Content-Type': 'application/json'
+ });
+ return this.http.post(`${this.url}/restaurantes`, JSON.stringify(AgreRestaurant),{ headers: headers });
+ }
+ eliminar(codigo:any){
+ return this.http.delete(`${this.url}/restaurantes/${codigo}`);
+ }
+ modificar(codigo:any,ModificarRes:any){
+ const headers: HttpHeaders = new HttpHeaders({
+ 'Content-Type': 'application/json'
+ });
+ return this.http.put(`${this.url}/restaurantes/${codigo}`, JSON.stringify(ModificarRes),{ headers: headers });
+ }
+
+
+}