Compare commits

..

10 Commits

29 changed files with 460 additions and 67 deletions

View File

@ -1,62 +1,71 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { LoginPage } from './login/login.page'; import { LoginPage } from './login/login.page';
const routes: Routes = [ const routes: Routes = [
{ {
path: 'login', path: 'login',
component: LoginPage component: LoginPage
}, },
{ {
path: 'tabs', path: 'tabs',
loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule) loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
}, },
{ {
path: 'tabsUser', path: 'tabsUser',
loadChildren: () => import('./tabs-user/tabs-user.module').then(m => m.TabsUserPageModule) loadChildren: () => import('./tabs-user/tabs-user.module').then(m => m.TabsUserPageModule)
}, },
{ {
path: 'view-evento', path: 'view-evento',
loadChildren: () => import('./view-evento/view-evento.module').then( m => m.ViewEventoPageModule) loadChildren: () => import('./view-evento/view-evento.module').then( m => m.ViewEventoPageModule)
}, },
{ {
path: 'galeriamodal', path: 'galeriamodal',
loadChildren: () => import('./galeriamodal/galeriamodal.module').then( m => m.GaleriamodalPageModule) loadChildren: () => import('./galeriamodal/galeriamodal.module').then( m => m.GaleriamodalPageModule)
}, },
{ {
path:'', path:'',
redirectTo: 'login', redirectTo: 'login',
pathMatch: 'full' pathMatch: 'full'
}, },
{ {
path: 'tabs-user', path: 'tabs-user',
loadChildren: () => import('./tabs-user/tabs-user.module').then( m => m.TabsUserPageModule) loadChildren: () => import('./tabs-user/tabs-user.module').then( m => m.TabsUserPageModule)
}, },
{ {
path: 'feed', path: 'feed',
loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule) loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule)
}, },
{ {
path: 'view-evento-cliente', path: 'view-evento-cliente',
loadChildren: () => import('./view-evento-cliente/view-evento-cliente.module').then( m => m.ViewEventoClientePageModule) loadChildren: () => import('./view-evento-cliente/view-evento-cliente.module').then( m => m.ViewEventoClientePageModule)
}, { },
{
path: 'view-discoteca-cliente', path: 'view-discoteca-cliente',
loadChildren: () => import('./view-discoteca-cliente/view-discoteca-cliente.module').then( m => m.ViewDiscotecaClientePageModule) loadChildren: () => import('./view-discoteca-cliente/view-discoteca-cliente.module').then( m => m.ViewDiscotecaClientePageModule)
}, },
{
path: 'reservamodal',
loadChildren: () => import('./reservamodal/reservamodal.module').then( m => m.ReservamodalPageModule)
},
{
path: 'perfil-usuario',
loadChildren: () => import('./perfil-usuario/perfil-usuario.module').then( m => m.PerfilUsuarioPageModule)
},
]; ];
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
], ],
exports: [RouterModule] exports: [RouterModule]
}) })
export class AppRoutingModule {} export class AppRoutingModule {}

View File

@ -6,6 +6,10 @@
<ion-content> <ion-content>
<ion-grid> <ion-grid>
<ion-row class="searchbar">
<ion-input class="text" id="filtro" aria-placeholder="evento o discoteca"></ion-input>
<ion-button (click)="filtrarEventos()"><ion-icon name="search-outline"></ion-icon></ion-button>
</ion-row>
<ion-row> <ion-row>
<ion-col size="12"> <ion-col size="12">
<div *ngIf="eventos.length>0" class="eventos"> <div *ngIf="eventos.length>0" class="eventos">

View File

@ -0,0 +1,3 @@
.searchbar{
float: right;
}

View File

@ -5,6 +5,7 @@ import { DiscotecaI } from '../interfaces/discoteca-i';
import { ApiService } from '../services/api.service'; import { ApiService } from '../services/api.service';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
import { Tab1Service } from '../tab1/tab1.service'; import { Tab1Service } from '../tab1/tab1.service';
import { EventListenerFocusTrapInertStrategy } from '@angular/cdk/a11y';
@Component({ @Component({
selector: 'app-feed', selector: 'app-feed',
@ -16,9 +17,12 @@ export class FeedPage implements OnInit {
eventos: Eventoi[]; eventos: Eventoi[];
discotecas: DiscotecaI[]; discotecas: DiscotecaI[];
idsDiscoteca: number[]; idsDiscoteca: number[];
mostrarTodos: boolean;
constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router, private apiService: ApiService ) { } constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router, private apiService: ApiService ) { }
ngOnInit() { ngOnInit() {
this.mostrarTodos = true;
this.eventos = this.feedService.eventos; this.eventos = this.feedService.eventos;
this.idsDiscoteca = []; this.idsDiscoteca = [];
this.discotecas=[]; this.discotecas=[];
@ -54,6 +58,31 @@ export class FeedPage implements OnInit {
) )
} }
filtrarEventos(){
var filtro = (<HTMLInputElement>document.getElementById("filtro")).value;
let eventoSinFiltrar = this.feedService.eventos;
this.eventos = [];
eventoSinFiltrar.forEach(evento => {
if (this.cumpleFiltro(evento, filtro)){
this.eventos.push(evento);
}
})
}
cumpleFiltro(evento: Eventoi, filtro: string){
if(evento.nombre.toLowerCase().includes(filtro.toLowerCase())){
return true;
}
if (this.discotecas[this.idsDiscoteca.indexOf(evento.discotecaID)]
.nombre.toLowerCase().includes(filtro.toLowerCase())){
return true;
}
else return false;
}
} }

View File

@ -0,0 +1,5 @@
export interface Codigo {
UserID: number,
codigo: string,
numReservas: number
}

View File

@ -0,0 +1,8 @@
export interface Reservai {
UserID: number,
EventoID: number,
codigoDescuento: string,
codigoUnico: string,
codigoUnicoID: number,
descuentoPorciento: number
}

View File

@ -1,5 +1,5 @@
export interface User { export interface User {
id: number; userID: number;
discotecaID: number; discotecaID: number;
userType: number; userType: number;
username: string; username: string;

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PerfilUsuarioPage } from './perfil-usuario.page';
const routes: Routes = [
{
path: '',
component: PerfilUsuarioPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PerfilUsuarioPageRoutingModule {}

View File

@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { PerfilUsuarioPageRoutingModule } from './perfil-usuario-routing.module';
import { PerfilUsuarioPage } from './perfil-usuario.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
PerfilUsuarioPageRoutingModule
],
declarations: [PerfilUsuarioPage]
})
export class PerfilUsuarioPageModule {}

View File

@ -0,0 +1,14 @@
<ion-header>
<ion-toolbar>
<ion-title>Mi perfil</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div *ngIf="codigos?.length>0">
<div *ngFor="let codigo of codigos">
Tu código: {{codigo.codigo}}
</div>
</div>
</ion-content>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { PerfilUsuarioPage } from './perfil-usuario.page';
describe('PerfilUsuarioPage', () => {
let component: PerfilUsuarioPage;
let fixture: ComponentFixture<PerfilUsuarioPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PerfilUsuarioPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(PerfilUsuarioPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { Codigo } from '../interfaces/codigo';
import { ApiService } from '../services/api.service';
import { LoginService } from '../services/login.service';
@Component({
selector: 'app-perfil-usuario',
templateUrl: './perfil-usuario.page.html',
styleUrls: ['./perfil-usuario.page.scss'],
})
export class PerfilUsuarioPage implements OnInit {
codigos: Codigo[];
constructor(private apiService: ApiService, private loginService: LoginService) { }
ngOnInit() {
this.apiService.getCodigosUsuario(this.loginService.user)
.subscribe(codigos => {
this.codigos = codigos;
console.log(this.codigos);
})
}
}

View File

@ -3,8 +3,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Tab1Service } from '../tab1/tab1.service'; import { Tab1Service } from '../tab1/tab1.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { DatePipe } from '@angular/common'
import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.module';
@Component({ @Component({
selector: 'app-prompt-evento', selector: 'app-prompt-evento',
@ -12,6 +11,8 @@ import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.
styleUrls: ['./prompt-evento.page.scss'], styleUrls: ['./prompt-evento.page.scss'],
}) })
export class PromptEventoPage implements OnInit{ export class PromptEventoPage implements OnInit{
evento: Eventoi;
submitted = false; submitted = false;
editarEvento = false; editarEvento = false;
eventoForm = new FormGroup({ eventoForm = new FormGroup({
@ -37,9 +38,14 @@ export class PromptEventoPage implements OnInit{
onSubmit(){ onSubmit(){
this.submitted = true; this.submitted = true;
if (this.eventoForm.valid){ if (this.eventoForm.valid){
this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex]); if (this.tab1Service.editarEvento == true){
this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex])}
else{
this.asignarEvento(this.initEventoVacio());
};
} }
} }
asignarEvento(evento: Eventoi){ asignarEvento(evento: Eventoi){
evento.nombre = this.eventoForm.get('nombre').value; evento.nombre = this.eventoForm.get('nombre').value;
evento.descripcion = this.eventoForm.get('descripcion').value; evento.descripcion = this.eventoForm.get('descripcion').value;
@ -50,7 +56,6 @@ export class PromptEventoPage implements OnInit{
if (!this.tab1Service.editarEvento){ if (!this.tab1Service.editarEvento){
hora = hora.split("T")[1];} hora = hora.split("T")[1];}
hora = hora.split(":")[0]+(":")+hora.split(":")[1]; hora = hora.split(":")[0]+(":")+hora.split(":")[1];
console.log(hora);
evento.hora = hora; evento.hora = hora;
evento.precio1 = this.eventoForm.get('precio1').value; evento.precio1 = this.eventoForm.get('precio1').value;
evento.precio2 = this.eventoForm.get('precio2').value; evento.precio2 = this.eventoForm.get('precio2').value;
@ -85,5 +90,19 @@ export class PromptEventoPage implements OnInit{
return this.eventoForm.get('descripcion'); return this.eventoForm.get('descripcion');
} }
initEventoVacio(): Eventoi{
let evento = {
id: 0,
discotecaID: this.tab1Service.discotecaI.discotecaID,
nombre: this.tab1Service.discotecaI.localizacion,
localizacion: '',
fecha: null,
hora: null,
precio1: 0,
precio2: 0,
descripcion: ''
}
return evento;
}
} }

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ReservamodalPage } from './reservamodal.page';
const routes: Routes = [
{
path: '',
component: ReservamodalPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ReservamodalPageRoutingModule {}

View File

@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { ReservamodalPageRoutingModule } from './reservamodal-routing.module';
import { ReservamodalPage } from './reservamodal.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ReservamodalPageRoutingModule
],
declarations: [ReservamodalPage]
})
export class ReservamodalPageModule {}

View File

@ -0,0 +1,12 @@
<ion-header>
<ion-toolbar>
<ion-title>reservamodal</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
¡Reserva realizada!
Tu código de reserva:
{{codigoReserva}}
Descuento del {{descuento}} %
</ion-content>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ReservamodalPage } from './reservamodal.page';
describe('ReservamodalPage', () => {
let component: ReservamodalPage;
let fixture: ComponentFixture<ReservamodalPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReservamodalPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ReservamodalPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,23 @@
import { Component, OnInit } from '@angular/core';
import { NavParams } from '@ionic/angular';
@Component({
selector: 'app-reservamodal',
templateUrl: './reservamodal.page.html',
styleUrls: ['./reservamodal.page.scss'],
})
export class ReservamodalPage implements OnInit {
codigoReserva: string;
descuento: number;
constructor(private navParams: NavParams) { }
ngOnInit() {
this.codigoReserva = this.navParams.get('codigo');
this.descuento = this.navParams.get('descuento');
if(!this.descuento){
this.descuento = 0;
}
}
}

View File

@ -3,10 +3,12 @@ import { HttpClient } from '@angular/common/http';
import { Observable, throwError, BehaviorSubject } from 'rxjs'; import { Observable, throwError, BehaviorSubject } from 'rxjs';
import { catchError, retry, map, tap } from 'rxjs/operators'; import { catchError, retry, map, tap } from 'rxjs/operators';
import { User } from '../interfaces/user'; import { User } from '../interfaces/user';
import { Codigo } from '../interfaces/codigo'
import { Discoteca } from '../discoteca'; import { Discoteca } from '../discoteca';
import { UserLogin } from '../interfaces/user-login'; import { UserLogin } from '../interfaces/user-login';
import { DiscotecaI } from '../interfaces/discoteca-i'; import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { Reservai } from '../interfaces/reservai';
@Injectable({ @Injectable({
@ -51,6 +53,14 @@ export class ApiService {
} }
creaReserva(reserva: Reservai): Observable<Reservai>{
return this.http.post<Reservai>(this.baseUrl+"/reserva", reserva);
}
getCodigosUsuario(user: User){
return this.http.post<Codigo[]>(this.baseUrl+"/codigosUsuario", user);
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { CodigoreservaService } from './codigoreserva.service';
describe('CodigoreservaService', () => {
let service: CodigoreservaService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CodigoreservaService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CodigoreservaService {
codigo: string;
length: number;
constructor() {
}
generarAleatorio(){
this.length = 7;
var result = [];
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < this.length; i++ ) {
result.push(characters.charAt(Math.floor(Math.random() *
charactersLength)));
}
return result.join("");
}
}

View File

@ -17,7 +17,7 @@ export class LoginService {
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) { constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
this.user = { this.user = {
id: 0, userID: 0,
discotecaID: 0, discotecaID: 0,
userType: 0, userType: 0,
username: '', username: '',

View File

@ -1,11 +1,12 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { PerfilUsuarioPage } from '../perfil-usuario/perfil-usuario.page';
import { Tab3Page } from './tab3.page'; import { Tab3Page } from './tab3.page';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
component: Tab3Page, component: PerfilUsuarioPage,
} }
]; ];

View File

@ -8,7 +8,7 @@
<ion-tab-button tab="tab3"> <ion-tab-button tab="tab3">
<ion-icon name="accessibility-outline"></ion-icon> <ion-icon name="accessibility-outline"></ion-icon>
<ion-label>Me</ion-label> <ion-label>Mi Perfil</ion-label>
</ion-tab-button> </ion-tab-button>

View File

@ -16,6 +16,7 @@ export class ViewDiscotecaClientePage implements OnInit {
constructor(private feedService: FeedService) { } constructor(private feedService: FeedService) { }
ngOnInit() { ngOnInit() {
this.eventos = [];
this.discoteca = this.feedService.discotecaEvento; this.discoteca = this.feedService.discotecaEvento;
this.feedService.eventos.forEach(evento => { this.feedService.eventos.forEach(evento => {
if (this.discoteca.discotecaID == evento.discotecaID){ if (this.discoteca.discotecaID == evento.discotecaID){

View File

@ -26,6 +26,14 @@
<a [routerLink]="['/tabsUser/tab2/view-discoteca-cliente']">{{discoteca?.nombre}}</a> <a [routerLink]="['/tabsUser/tab2/view-discoteca-cliente']">{{discoteca?.nombre}}</a>
</div> </div>
</ion-row> </ion-row>
<ion-row>
<ion-button (click)="openReserva()">
Reserva
</ion-button>
</ion-row>
<ion-row>
<span>Código de descuento: </span><input type="text" id="codigoDescuento">
</ion-row>
</div> </div>
</ion-grid> </ion-grid>
</ion-content> </ion-content>

View File

@ -1,7 +1,14 @@
import { stringify } from '@angular/compiler/src/util';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { DiscotecaI } from '../interfaces/discoteca-i'; import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { Reservai } from '../interfaces/reservai';
import { ReservamodalPage } from '../reservamodal/reservamodal.page';
import { ApiService } from '../services/api.service';
import { CodigoreservaService } from '../services/codigoreserva.service';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
import { LoginService } from '../services/login.service';
@Component({ @Component({
selector: 'app-view-evento-cliente', selector: 'app-view-evento-cliente',
@ -12,11 +19,61 @@ export class ViewEventoClientePage implements OnInit {
evento: Eventoi; evento: Eventoi;
discoteca: DiscotecaI; discoteca: DiscotecaI;
constructor(private feedService: FeedService) { } reserva: Reservai;
codigoReserva: string;
reservaRealizada: boolean;
constructor(private feedService: FeedService, private modalController: ModalController,
private codigoReservaService: CodigoreservaService, private loginService: LoginService, private apiService: ApiService) { }
ngOnInit() { ngOnInit() {
this.reservaRealizada = false;
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex); this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
this.discoteca = this.feedService.discotecaEvento; this.discoteca = this.feedService.discotecaEvento;
} }
generarCodigo(){
return stringify(this.codigoReservaService.generarAleatorio());
}
initReserva(){
this.reserva = {
UserID: this.loginService.user.userID,
EventoID: this.evento.id,
codigoDescuento: null,
codigoUnico: '',
codigoUnicoID: null,
descuentoPorciento: null
}
}
openReserva(){
this.initReserva();
this.reserva.codigoDescuento = (<HTMLInputElement>document.getElementById("codigoDescuento")).value;
this.reserva.codigoUnico = this.generarCodigo();
this.creaReserva(this.reserva);
}
creaReserva(reserva){
this.apiService.creaReserva(reserva)
.subscribe(
data => {
console.log(data);
this.reserva = data;
this.reservaRealizada = true;
this.modalController.create({
component: ReservamodalPage,
componentProps : {
codigo: this.reserva.codigoUnico,
descuento: this.reserva.descuentoPorciento
}
}).then(modal => modal.present());
},
error => {
console.log(error);
}
)
}
} }