From b9d95793dc3371f388314d309aee9d456d204121 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Sun, 21 Feb 2021 12:21:18 +0100 Subject: [PATCH 1/9] =?UTF-8?q?a=C3=B1adida=20interfaz=20discoteca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/discoteca-i.ts | 2 ++ src/app/discoteca.ts | 2 +- src/app/perfil-discoteca/perfil-discoteca.page.ts | 5 +++++ src/app/tab1/tab1.service.ts | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/app/discoteca-i.ts diff --git a/src/app/discoteca-i.ts b/src/app/discoteca-i.ts new file mode 100644 index 0000000..522adda --- /dev/null +++ b/src/app/discoteca-i.ts @@ -0,0 +1,2 @@ +export interface DiscotecaI { +} diff --git a/src/app/discoteca.ts b/src/app/discoteca.ts index 4ba5387..8114e04 100644 --- a/src/app/discoteca.ts +++ b/src/app/discoteca.ts @@ -43,7 +43,7 @@ export class Discoteca { this.descripcion = desc; } - get Descripcion(): string{ + getDescripcion(): string{ return this.descripcion; } } diff --git a/src/app/perfil-discoteca/perfil-discoteca.page.ts b/src/app/perfil-discoteca/perfil-discoteca.page.ts index deeaeb9..f87e339 100644 --- a/src/app/perfil-discoteca/perfil-discoteca.page.ts +++ b/src/app/perfil-discoteca/perfil-discoteca.page.ts @@ -20,6 +20,7 @@ export class PerfilDiscotecaPage implements OnInit { nombre: string; telefono: number; localizacion: string; + descripcion: string; fotoSrc: string; fotoLoaded: string; someURL: string; @@ -73,6 +74,10 @@ export class PerfilDiscotecaPage implements OnInit { this.eventos = this.tab1Service.getEventos(); } + getDescripcion(): void{ + this.descripcion = this.tab1Service.getDescripcion(); + } + cargarImagen(){ this.fotoSrc = this.someURL; } diff --git a/src/app/tab1/tab1.service.ts b/src/app/tab1/tab1.service.ts index c07d3c7..8bb4d48 100644 --- a/src/app/tab1/tab1.service.ts +++ b/src/app/tab1/tab1.service.ts @@ -56,6 +56,11 @@ export class Tab1Service implements OnInit{ return this.eventos; } + getDescripcion(): string{ + this.initValues(); + return this.discoteca.getDescripcion(); + } + initEventos(): void{ this.eventos = []; } From 659783d23fc6f5ea29e8f7527cca595f3ca913e4 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Mon, 22 Feb 2021 20:09:15 +0100 Subject: [PATCH 2/9] metodos e interfaces de login actualizados --- src/app/api.service.ts | 18 ++++++------------ src/app/login.service.ts | 22 +++++++++------------- src/app/user-login.ts | 4 ++++ 3 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 src/app/user-login.ts diff --git a/src/app/api.service.ts b/src/app/api.service.ts index 32381eb..b513eb1 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -4,30 +4,24 @@ import { Observable, throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; import { User } from './user'; import { Discoteca } from './discoteca'; +import { UserLogin } from './user-login'; @Injectable({ providedIn: 'root' }) export class ApiService { + url = ''; + constructor(private http: HttpClient) { } - validateUser(loginUser: string, loginPassword: string): boolean{ - return (loginUser==''); + validateUser(user: UserLogin): Observable{ + + return this.http.post(this.url, user); } - getUser (loginUser: string): void{ - } - - postNewUser(user: User): void{ - - } - - postNewDiscoteca(discoteca: Discoteca): void{ - - } } diff --git a/src/app/login.service.ts b/src/app/login.service.ts index 2e1fcfe..f0fde60 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -1,30 +1,26 @@ import { Injectable } from '@angular/core'; import { ApiService } from './api.service'; import { User } from './user'; +import { UserLogin } from './user-login' @Injectable({ providedIn: 'root' }) export class LoginService { - private userId: number; - private sessionType: number; - private loginUser: string; - private loginPassword: string; + user: User; constructor(private apiService: ApiService) { } - validateUser(loginUser: string, loginPassword: string): boolean{ - return (loginUser==''); + validateUser(login: string, password: string): void{ + let user : UserLogin = { + loginUser: login, + loginPassword: password, + } + this.apiService.validateUser(user) + .subscribe((data: User) => this.user = {...data}); } - getUser (loginUser: string): void{ - - } - - postNewUser(user: User): void{ - - } } diff --git a/src/app/user-login.ts b/src/app/user-login.ts new file mode 100644 index 0000000..f0cc9b0 --- /dev/null +++ b/src/app/user-login.ts @@ -0,0 +1,4 @@ +export interface UserLogin { + loginUser: string; + loginPassword: string; +} From f1bf8ff75ebde1ecd9fbdea042034fdc270d5c89 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Mon, 8 Mar 2021 13:33:27 +0100 Subject: [PATCH 3/9] =?UTF-8?q?Montada=20comunicaci=C3=B3n=20con=20API,=20?= =?UTF-8?q?pero=20devuelve=20un=20objeto=20undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api.service.ts | 10 ++++++---- src/app/app-routing.module.ts | 2 +- src/app/login.service.ts | 28 +++++++++++++++++++++------- src/app/login/login.page.html | 7 +++++++ src/app/login/login.page.scss | 3 +++ src/app/login/login.page.ts | 18 +++++++++++++++--- src/app/user.ts | 6 +++--- 7 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/app/api.service.ts b/src/app/api.service.ts index b513eb1..b9bd55d 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -1,17 +1,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { Observable, throwError } from 'rxjs'; -import { catchError, retry } from 'rxjs/operators'; +import { Observable, throwError, BehaviorSubject } from 'rxjs'; +import { catchError, retry, map, tap } from 'rxjs/operators'; import { User } from './user'; import { Discoteca } from './discoteca'; import { UserLogin } from './user-login'; + @Injectable({ providedIn: 'root' }) export class ApiService { - url = ''; + constructor(private http: HttpClient) { @@ -20,8 +21,9 @@ export class ApiService { validateUser(user: UserLogin): Observable{ - return this.http.post(this.url, user); + return this.http.post("http://localhost:3307/api/consultas/users", user); } + } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7675048..c4f4dc7 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -23,7 +23,7 @@ const routes: Routes = [ }, { path:'', - redirectTo: 'tabs', + redirectTo: 'login', pathMatch: 'full' }, diff --git a/src/app/login.service.ts b/src/app/login.service.ts index f0fde60..beaf043 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -1,7 +1,9 @@ import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; import { ApiService } from './api.service'; import { User } from './user'; -import { UserLogin } from './user-login' +import { UserLogin } from './user-login'; + @Injectable({ providedIn: 'root' @@ -10,17 +12,29 @@ export class LoginService { user: User; - constructor(private apiService: ApiService) { - + constructor(private apiService: ApiService, private router: Router) { + this.user = { + id: 0, + userType: 0, + username: '', + password: '' + }; } - validateUser(login: string, password: string): void{ - let user : UserLogin = { + validateUser(login: string, password: string): User { + + let userlogin: UserLogin = { loginUser: login, loginPassword: password, } - this.apiService.validateUser(user) - .subscribe((data: User) => this.user = {...data}); + + this.apiService.validateUser(userlogin) + .subscribe(user => this.user = user) + + return this.user; + } + + } diff --git a/src/app/login/login.page.html b/src/app/login/login.page.html index 1a77f8b..cacbd4a 100644 --- a/src/app/login/login.page.html +++ b/src/app/login/login.page.html @@ -5,7 +5,14 @@ + Usuario: + ContraseƱa: Login +
+
+ {{user.username}} +
+
diff --git a/src/app/login/login.page.scss b/src/app/login/login.page.scss index e69de29..1bdc99e 100644 --- a/src/app/login/login.page.scss +++ b/src/app/login/login.page.scss @@ -0,0 +1,3 @@ +input{ + color: black; +} \ No newline at end of file diff --git a/src/app/login/login.page.ts b/src/app/login/login.page.ts index 75a025e..f8de934 100644 --- a/src/app/login/login.page.ts +++ b/src/app/login/login.page.ts @@ -1,5 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; +import { LoginService } from '../login.service'; +import { User } from '../user'; @Component({ selector: 'app-login', @@ -8,13 +10,23 @@ import { Router } from '@angular/router'; }) export class LoginPage implements OnInit { - constructor(private router: Router) { } + username: string; + password: string; + user: User; + + constructor(private router: Router, private loginService: LoginService) { } ngOnInit() { + this.user = this.loginService.user; } - login(){ - this.router.navigate(['/tabs']); + async login() { + + this.username = (document.getElementById("username")).value; + this.password = (document.getElementById("password")).value; + this.user = await this.loginService.validateUser(this.username, this.password); + console.log(this.user.username); + } } diff --git a/src/app/user.ts b/src/app/user.ts index 72434d2..5f9dd3f 100644 --- a/src/app/user.ts +++ b/src/app/user.ts @@ -1,6 +1,6 @@ export interface User { - userId: number; + id: number; userType: number; - loginUser: string; - loginPassword: string; + username: string; + password: string; } From 36426bc6434fc3fb7f8d66812cc7e5008d365f2e Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Tue, 16 Mar 2021 10:23:46 +0100 Subject: [PATCH 4/9] =?UTF-8?q?Comunicaci=C3=B3n=20con=20backend.=20Permit?= =?UTF-8?q?e=20cargar=20un=20usuario=20de=20la=20BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api.service.ts | 4 +++- src/app/login.service.ts | 11 ++++++----- src/app/login/login.page.ts | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/api.service.ts b/src/app/api.service.ts index b9bd55d..b3c7cf4 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -21,9 +21,11 @@ export class ApiService { validateUser(user: UserLogin): Observable{ - return this.http.post("http://localhost:3307/api/consultas/users", user); + return this.http.post("http://localhost:3307/api/consultas/users", user) + } + } diff --git a/src/app/login.service.ts b/src/app/login.service.ts index beaf043..1b7225a 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; +import { VirtualTimeScheduler } from 'rxjs'; import { ApiService } from './api.service'; import { User } from './user'; import { UserLogin } from './user-login'; @@ -21,7 +22,7 @@ export class LoginService { }; } - validateUser(login: string, password: string): User { + validateUser(login: string, password: string): void{ let userlogin: UserLogin = { loginUser: login, @@ -29,12 +30,12 @@ export class LoginService { } this.apiService.validateUser(userlogin) - .subscribe(user => this.user = user) - - return this.user; + .subscribe(user => { + this.user = user; + console.log(this.user); + }) } - } diff --git a/src/app/login/login.page.ts b/src/app/login/login.page.ts index f8de934..3016ca9 100644 --- a/src/app/login/login.page.ts +++ b/src/app/login/login.page.ts @@ -20,12 +20,12 @@ export class LoginPage implements OnInit { this.user = this.loginService.user; } - async login() { + login() { this.username = (document.getElementById("username")).value; this.password = (document.getElementById("password")).value; - this.user = await this.loginService.validateUser(this.username, this.password); - console.log(this.user.username); + this.loginService.validateUser(this.username, this.password) + } From de5a925e388187346bb4dbe7947e9cb83a4567dc Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Wed, 17 Mar 2021 21:19:42 +0100 Subject: [PATCH 5/9] Redefinida interfaz user --- src/app/login.service.ts | 2 +- src/app/user.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/login.service.ts b/src/app/login.service.ts index 1b7225a..6e8f283 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -16,9 +16,9 @@ export class LoginService { constructor(private apiService: ApiService, private router: Router) { this.user = { id: 0, + discotecaId: 0, userType: 0, username: '', - password: '' }; } diff --git a/src/app/user.ts b/src/app/user.ts index 5f9dd3f..78fb1f5 100644 --- a/src/app/user.ts +++ b/src/app/user.ts @@ -1,6 +1,6 @@ export interface User { id: number; + discotecaId: number; userType: number; username: string; - password: string; } From 660f19932cc92e53d0fcec5e633935710b93ab02 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Thu, 18 Mar 2021 18:04:58 +0100 Subject: [PATCH 6/9] Si el usuario es tipo 0 (gestor de discoteca) muestra la discoteca asociada al gestor en la BD --- src/app/api.service.ts | 11 +++++++++-- src/app/discoteca-i.ts | 4 ++++ src/app/login.service.ts | 10 +++++++--- src/app/tab1/tab1.service.ts | 24 ++++++++++++++++++++---- src/app/user.ts | 2 +- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/app/api.service.ts b/src/app/api.service.ts index b3c7cf4..58e806e 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -5,6 +5,7 @@ import { catchError, retry, map, tap } from 'rxjs/operators'; import { User } from './user'; import { Discoteca } from './discoteca'; import { UserLogin } from './user-login'; +import { DiscotecaI } from './discoteca-i'; @Injectable({ @@ -12,7 +13,7 @@ import { UserLogin } from './user-login'; }) export class ApiService { - + baseUrl = "http://localhost:3307/api/consultas"; constructor(private http: HttpClient) { @@ -21,10 +22,16 @@ export class ApiService { validateUser(user: UserLogin): Observable{ - return this.http.post("http://localhost:3307/api/consultas/users", user) + return this.http.post(this.baseUrl+"/users", user) } + getUserDiscoteca(discotecaId: number): Observable{ + + return this.http.post(this.baseUrl+"/discoteca", { "id": discotecaId}); + + } + diff --git a/src/app/discoteca-i.ts b/src/app/discoteca-i.ts index 522adda..a3274f1 100644 --- a/src/app/discoteca-i.ts +++ b/src/app/discoteca-i.ts @@ -1,2 +1,6 @@ export interface DiscotecaI { + discotecaId: number, + nombre: string, + telefono: number, + localizacion: string } diff --git a/src/app/login.service.ts b/src/app/login.service.ts index 6e8f283..8652c71 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { VirtualTimeScheduler } from 'rxjs'; import { ApiService } from './api.service'; +import { Tab1Service } from './tab1/tab1.service'; import { User } from './user'; import { UserLogin } from './user-login'; @@ -13,10 +14,10 @@ export class LoginService { user: User; - constructor(private apiService: ApiService, private router: Router) { + constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service) { this.user = { id: 0, - discotecaId: 0, + discotecaID: 0, userType: 0, username: '', }; @@ -31,8 +32,11 @@ export class LoginService { this.apiService.validateUser(userlogin) .subscribe(user => { - this.user = user; + this.user = user[0]; console.log(this.user); + console.log(this.user.discotecaID); + this.tab1service.getDiscoteca(this.user.discotecaID); + }) } diff --git a/src/app/tab1/tab1.service.ts b/src/app/tab1/tab1.service.ts index 8bb4d48..1b98cd3 100644 --- a/src/app/tab1/tab1.service.ts +++ b/src/app/tab1/tab1.service.ts @@ -5,6 +5,9 @@ import { Discoteca } from '../discoteca' import { Evento } from '../evento'; import { FormControl, FormGroup } from '@angular/forms'; import { NumericValueAccessor } from '@ionic/angular'; +import { DiscotecaI } from '../discoteca-i'; +import { ApiService } from '../api.service'; +import { Router } from '@angular/router'; @Injectable({ @@ -13,13 +16,14 @@ import { NumericValueAccessor } from '@ionic/angular'; export class Tab1Service implements OnInit{ discoteca: Discoteca; + discotecaI: DiscotecaI; galeria: string[]; eventos: Evento[]; eventoForms: FormGroup[]; eventoIndex: number; editarEvento: boolean; - constructor() { + constructor(private apiService: ApiService, private router: Router) { } @@ -29,9 +33,9 @@ export class Tab1Service implements OnInit{ initValues(): void{ this.discoteca = new Discoteca(); - this.discoteca.setNombre('Barraca'); - this.discoteca.setTelefono(666666666); - this.discoteca.setLocalizacion('Calle del Barquillo'); + this.discoteca.setNombre(this.discotecaI.nombre); + this.discoteca.setTelefono(this.discotecaI.telefono); + this.discoteca.setLocalizacion(this.discotecaI.localizacion); this.galeria = []; this.initEventos(); this.editarEvento = false; @@ -73,4 +77,16 @@ export class Tab1Service implements OnInit{ return this.eventos[eventoIndex]; } + getDiscoteca(discotecaId: number){ + if (discotecaId != 0){ + this.apiService.getUserDiscoteca(discotecaId) + .subscribe(discoteca => { + this.discotecaI = discoteca[0]; + console.log(this.discotecaI); + this.initValues(); + this.router.navigate(['/tabs/tab1/perfil-discoteca']); + }) + } + } + } diff --git a/src/app/user.ts b/src/app/user.ts index 78fb1f5..f40b02f 100644 --- a/src/app/user.ts +++ b/src/app/user.ts @@ -1,6 +1,6 @@ export interface User { id: number; - discotecaId: number; + discotecaID: number; userType: number; username: string; } From f6756c25a89ee08ab54ea6b49295ac3c3eb61b95 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Thu, 18 Mar 2021 18:56:19 +0100 Subject: [PATCH 7/9] =?UTF-8?q?reorganizaci=C3=B3n=20con=20carpetas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/{ => interfaces}/discoteca-i.ts | 0 src/app/interfaces/eventoi.ts | 2 ++ src/app/{ => interfaces}/user-login.ts | 0 src/app/{ => interfaces}/user.ts | 0 src/app/login/login.page.ts | 4 ++-- src/app/{ => services}/api.service.spec.ts | 0 src/app/{ => services}/api.service.ts | 8 ++++---- src/app/{ => services}/login.service.spec.ts | 0 src/app/{ => services}/login.service.ts | 6 +++--- src/app/tab1/tab1.service.ts | 4 ++-- 10 files changed, 13 insertions(+), 11 deletions(-) rename src/app/{ => interfaces}/discoteca-i.ts (100%) create mode 100644 src/app/interfaces/eventoi.ts rename src/app/{ => interfaces}/user-login.ts (100%) rename src/app/{ => interfaces}/user.ts (100%) rename src/app/{ => services}/api.service.spec.ts (100%) rename src/app/{ => services}/api.service.ts (77%) rename src/app/{ => services}/login.service.spec.ts (100%) rename src/app/{ => services}/login.service.ts (85%) diff --git a/src/app/discoteca-i.ts b/src/app/interfaces/discoteca-i.ts similarity index 100% rename from src/app/discoteca-i.ts rename to src/app/interfaces/discoteca-i.ts diff --git a/src/app/interfaces/eventoi.ts b/src/app/interfaces/eventoi.ts new file mode 100644 index 0000000..961d4e7 --- /dev/null +++ b/src/app/interfaces/eventoi.ts @@ -0,0 +1,2 @@ +export interface Eventoi { +} diff --git a/src/app/user-login.ts b/src/app/interfaces/user-login.ts similarity index 100% rename from src/app/user-login.ts rename to src/app/interfaces/user-login.ts diff --git a/src/app/user.ts b/src/app/interfaces/user.ts similarity index 100% rename from src/app/user.ts rename to src/app/interfaces/user.ts diff --git a/src/app/login/login.page.ts b/src/app/login/login.page.ts index 3016ca9..c33e6a8 100644 --- a/src/app/login/login.page.ts +++ b/src/app/login/login.page.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { LoginService } from '../login.service'; -import { User } from '../user'; +import { LoginService } from '../services/login.service'; +import { User } from '../interfaces/user'; @Component({ selector: 'app-login', diff --git a/src/app/api.service.spec.ts b/src/app/services/api.service.spec.ts similarity index 100% rename from src/app/api.service.spec.ts rename to src/app/services/api.service.spec.ts diff --git a/src/app/api.service.ts b/src/app/services/api.service.ts similarity index 77% rename from src/app/api.service.ts rename to src/app/services/api.service.ts index 58e806e..cf30afc 100644 --- a/src/app/api.service.ts +++ b/src/app/services/api.service.ts @@ -2,10 +2,10 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, throwError, BehaviorSubject } from 'rxjs'; import { catchError, retry, map, tap } from 'rxjs/operators'; -import { User } from './user'; -import { Discoteca } from './discoteca'; -import { UserLogin } from './user-login'; -import { DiscotecaI } from './discoteca-i'; +import { User } from '../interfaces/user'; +import { Discoteca } from '../discoteca'; +import { UserLogin } from '../interfaces/user-login'; +import { DiscotecaI } from '../interfaces/discoteca-i'; @Injectable({ diff --git a/src/app/login.service.spec.ts b/src/app/services/login.service.spec.ts similarity index 100% rename from src/app/login.service.spec.ts rename to src/app/services/login.service.spec.ts diff --git a/src/app/login.service.ts b/src/app/services/login.service.ts similarity index 85% rename from src/app/login.service.ts rename to src/app/services/login.service.ts index 8652c71..977a8b3 100644 --- a/src/app/login.service.ts +++ b/src/app/services/login.service.ts @@ -2,9 +2,9 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { VirtualTimeScheduler } from 'rxjs'; import { ApiService } from './api.service'; -import { Tab1Service } from './tab1/tab1.service'; -import { User } from './user'; -import { UserLogin } from './user-login'; +import { Tab1Service } from '../tab1/tab1.service'; +import { User } from '../interfaces/user'; +import { UserLogin } from '../interfaces/user-login'; @Injectable({ diff --git a/src/app/tab1/tab1.service.ts b/src/app/tab1/tab1.service.ts index 1b98cd3..7df4ad2 100644 --- a/src/app/tab1/tab1.service.ts +++ b/src/app/tab1/tab1.service.ts @@ -5,8 +5,8 @@ import { Discoteca } from '../discoteca' import { Evento } from '../evento'; import { FormControl, FormGroup } from '@angular/forms'; import { NumericValueAccessor } from '@ionic/angular'; -import { DiscotecaI } from '../discoteca-i'; -import { ApiService } from '../api.service'; +import { DiscotecaI } from '../interfaces/discoteca-i'; +import { ApiService } from '../services/api.service'; import { Router } from '@angular/router'; From 4b2d8cf7b692b7406bdbc8e40f8c316d2b3ecd3d Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Sat, 20 Mar 2021 13:21:50 +0100 Subject: [PATCH 8/9] Se suben eventos a la BD, asociados a la discoteca del usuario --- src/app/discoteca.ts | 7 +++ src/app/evento.ts | 10 ++-- src/app/interfaces/discoteca-i.ts | 2 +- src/app/interfaces/eventoi.ts | 12 ++++ src/app/prompt-evento/prompt-evento.page.html | 13 ++++- src/app/prompt-evento/prompt-evento.page.ts | 56 ++++++++++++++----- src/app/services/api.service.ts | 7 +++ src/app/tab1/tab1.service.ts | 14 +++++ 8 files changed, 102 insertions(+), 19 deletions(-) diff --git a/src/app/discoteca.ts b/src/app/discoteca.ts index 8114e04..8438b79 100644 --- a/src/app/discoteca.ts +++ b/src/app/discoteca.ts @@ -10,6 +10,13 @@ export class Discoteca { private eventos: Evento[]; private descripcion: string; + setId(id: number): void{ + this.id = id; + } + + getId(): number{ + return this.id; + } setNombre(nombre: string): void{ this.nombre = nombre; diff --git a/src/app/evento.ts b/src/app/evento.ts index 0471ab1..4ce12b3 100644 --- a/src/app/evento.ts +++ b/src/app/evento.ts @@ -1,10 +1,12 @@ +import { Time } from "@angular/common"; + export class Evento { private id: number; nombre: string; localizacion: string; fecha: Date; dia: string; - hora: string; + hora: Time; descripcion: string; precio1: number; precio2: number; @@ -49,11 +51,11 @@ export class Evento { return this.dia; } - setHora(fecha: Date): void{ - this.hora = fecha.getHours()+":"+fecha.getMinutes(); + setHora(time: Time): void{ + this.hora = time; } - getHora(): string{ + getHora(): Time{ return this.hora; } diff --git a/src/app/interfaces/discoteca-i.ts b/src/app/interfaces/discoteca-i.ts index a3274f1..c5e5c93 100644 --- a/src/app/interfaces/discoteca-i.ts +++ b/src/app/interfaces/discoteca-i.ts @@ -1,5 +1,5 @@ export interface DiscotecaI { - discotecaId: number, + discotecaID: number, nombre: string, telefono: number, localizacion: string diff --git a/src/app/interfaces/eventoi.ts b/src/app/interfaces/eventoi.ts index 961d4e7..8926fb3 100644 --- a/src/app/interfaces/eventoi.ts +++ b/src/app/interfaces/eventoi.ts @@ -1,2 +1,14 @@ +import { Time } from "@angular/common"; + export interface Eventoi { + + discotecaID: number, + nombre: string, + localizacion: string, + fecha: Date, + hora: Time, + descripcion: string, + precio1: number, + precio2: number, + } diff --git a/src/app/prompt-evento/prompt-evento.page.html b/src/app/prompt-evento/prompt-evento.page.html index 94845bd..8e2cd63 100644 --- a/src/app/prompt-evento/prompt-evento.page.html +++ b/src/app/prompt-evento/prompt-evento.page.html @@ -21,7 +21,7 @@ @@ -29,6 +29,17 @@ + + + + Tu evento necesita una hora + + +