Compare commits

..

No commits in common. "139e3fcb8b5731dfd5c58603810542e17ccfd2fd" and "3e7968ab7fe8703dcb40522d6475b11c1d85b12a" have entirely different histories.

32 changed files with 685 additions and 1051 deletions

1116
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,16 +23,16 @@
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@capacitor/core": "2.4.3",
"@ionic-native/core": "^5.31.1",
"@ionic-native/splash-screen": "^5.31.1",
"@ionic-native/status-bar": "^5.31.1",
"@ionic/angular": "^5.5.4",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",
"rxjs": "~6.5.5",
"tslib": "^2.1.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1000.8",
"@angular-devkit/build-angular": "~0.1000.0",
"@angular/cli": "10.0.8",
"@angular/compiler": "~10.0.0",
"@angular/compiler-cli": "~10.0.0",
@ -41,15 +41,15 @@
"@ionic/angular-toolkit": "^2.3.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.20.4",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"cordova-android": "^9.0.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
@ -60,7 +60,7 @@
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "^3.9.9"
"typescript": "~3.9.5"
},
"description": "An Ionic project",
"cordova": {

33
src/app/api.service.ts Normal file
View File

@ -0,0 +1,33 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators';
import { User } from './user';
import { Discoteca } from './discoteca';
@Injectable({
providedIn: 'root'
})
export class ApiService {
constructor(private http: HttpClient) {
}
validateUser(loginUser: string, loginPassword: string): boolean{
return (loginUser=='');
}
getUser (loginUser: string): void{
}
postNewUser(user: User): void{
}
postNewDiscoteca(discoteca: Discoteca): void{
}
}

View File

@ -23,7 +23,7 @@ const routes: Routes = [
},
{
path:'',
redirectTo: 'login',
redirectTo: 'tabs',
pathMatch: 'full'
},

View File

@ -1,5 +1,5 @@
import {Eventoi} from './interfaces/eventoi';
import {Evento} from './evento';
export class Discoteca {
@ -7,16 +7,9 @@ export class Discoteca {
private nombre: string;
private telefono: number;
private localizacion: string;
private eventos: Eventoi[];
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;
@ -42,7 +35,7 @@ export class Discoteca {
return this.localizacion
}
getEventos(): Eventoi[]{
getEventos(): Evento[]{
return this.eventos;
}

7
src/app/evento.spec.ts Normal file
View File

@ -0,0 +1,7 @@
import { Evento } from './evento';
describe('Evento', () => {
it('should create an instance', () => {
expect(new Evento()).toBeTruthy();
});
});

75
src/app/evento.ts Normal file
View File

@ -0,0 +1,75 @@
export class Evento {
private id: number;
nombre: string;
localizacion: string;
fecha: Date;
dia: string;
hora: string;
descripcion: string;
precio1: number;
precio2: number;
setNombre(nombre: string): void{
this.nombre = nombre;
}
getNombre(): string{
return this.nombre;
}
setLocalizacion(localizacion: string): void{
this.localizacion = localizacion;
}
getLocalizacion(): string{
return this.localizacion
}
setFecha(fecha: Date): void{
this.fecha = fecha;
}
getFecha(): Date{
return this.fecha;
}
setDesc(desc: string): void{
this.descripcion = desc;
}
getDesc(): string{
return this.descripcion;
}
setDia(fecha: Date): void{
this.dia = fecha.getDate()+"/"+fecha.getMonth();
}
getDia(): string{
return this.dia;
}
setHora(fecha: Date): void{
this.hora = fecha.getHours()+":"+fecha.getMinutes();
}
getHora(): string{
return this.hora;
}
setPrecio1(precio: number): void{
this.precio1 = precio;
}
getPrecio1(): number{
return this.precio1;
}
setPrecio2(precio: number): void{
this.precio2 = precio;
}
getPrecio2(): number{
return this.precio2;
}
}

View File

@ -1,3 +0,0 @@
<p>
feed works!
</p>

View File

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

View File

@ -1,14 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-feed',
templateUrl: './feed.component.html',
styleUrls: ['./feed.component.scss'],
})
export class FeedComponent implements OnInit {
constructor() { }
ngOnInit() {}
}

View File

@ -1,6 +0,0 @@
export interface DiscotecaI {
discotecaID: number,
nombre: string,
telefono: number,
localizacion: string
}

View File

@ -1,14 +0,0 @@
import { Time } from "@angular/common";
export interface Eventoi {
id: number,
discotecaID: number,
nombre: string,
localizacion: string,
fecha: Date,
hora: Time,
descripcion: string,
precio1: number,
precio2: number,
}

View File

@ -1,4 +0,0 @@
export interface UserLogin {
loginUser: string;
loginPassword: string;
}

View File

@ -1,6 +0,0 @@
export interface User {
id: number;
discotecaID: number;
userType: number;
username: string;
}

30
src/app/login.service.ts Normal file
View File

@ -0,0 +1,30 @@
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { User } from './user';
@Injectable({
providedIn: 'root'
})
export class LoginService {
private userId: number;
private sessionType: number;
private loginUser: string;
private loginPassword: string;
constructor(private apiService: ApiService) {
}
validateUser(loginUser: string, loginPassword: string): boolean{
return (loginUser=='');
}
getUser (loginUser: string): void{
}
postNewUser(user: User): void{
}
}

View File

@ -5,14 +5,7 @@
</ion-header>
<ion-content>
<span>Usuario: </span><input type="text" id="username">
<span>Contraseña: </span><input type="text" id="password">
<ion-button (click)="login()">
Login
</ion-button>
<div>
<div *ngIf="user">
{{user.username}}
</div>
</div>
</ion-content>

View File

@ -1,3 +0,0 @@
input{
color: black;
}

View File

@ -1,7 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../services/login.service';
import { User } from '../interfaces/user';
@Component({
selector: 'app-login',
@ -10,23 +8,13 @@ import { User } from '../interfaces/user';
})
export class LoginPage implements OnInit {
username: string;
password: string;
user: User;
constructor(private router: Router, private loginService: LoginService) { }
constructor(private router: Router) { }
ngOnInit() {
this.user = this.loginService.user;
}
login() {
this.username = (<HTMLInputElement>document.getElementById("username")).value;
this.password = (<HTMLInputElement>document.getElementById("password")).value;
this.loginService.validateUser(this.username, this.password)
login(){
this.router.navigate(['/tabs']);
}
}

View File

@ -3,7 +3,7 @@ import { Tab1Service } from '../tab1/tab1.service';
import { IonSlides, ModalController} from '@ionic/angular';
import { AlertController } from '@ionic/angular';
import { ViewChild } from '@angular/core';
import { Eventoi } from '../interfaces/eventoi';
import { Evento } from '../evento';
import { Router } from '@angular/router';
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
import { GaleriamodalPage } from '../galeriamodal/galeriamodal.page';
@ -28,7 +28,7 @@ export class PerfilDiscotecaPage implements OnInit {
editEnabled: string;
galeriaFotos: string[];
currentIndex: number;
eventos: Eventoi[];
eventos: Evento[];
alertCtrl: AlertController;
sliderOpts = {
slidesPerView: 1.5,
@ -70,16 +70,14 @@ export class PerfilDiscotecaPage implements OnInit {
this.localizacion = this.tab1Service.getLocalizacion();
}
getEventos(): void{
this.eventos = this.tab1Service.getEventos();
}
getDescripcion(): void{
this.descripcion = this.tab1Service.getDescripcion();
}
getEventos(): void{
this.eventos = this.tab1Service.eventos;
}
cargarImagen(){
this.fotoSrc = this.someURL;
}
@ -181,15 +179,14 @@ export class PerfilDiscotecaPage implements OnInit {
this.router.navigate(['/tabs/tab1/prompt-evento']);
}
mostrarEvento(evento: Eventoi){
mostrarEvento(evento: Evento){
this.tab1Service.eventoIndex = this.eventos.indexOf(evento);
this.router.navigate(['/tabs/tab1/view-evento']);
}
editarEvento(evento: Eventoi){
editarEvento(evento: Evento){
this.tab1Service.eventoIndex = this.eventos.indexOf(evento);
this.tab1Service.editarEvento = true;
this.tab1Service.initEventoForms();
this.router.navigate(['/tabs/tab1/prompt-evento']);
}

View File

@ -21,7 +21,7 @@
<ion-item>
<label>
Fecha:
<ion-datetime displayFormat="YYYY/DD/MM"placeholder="Elegir Fecha" formControlName="fecha"></ion-datetime>
<ion-datetime displayFormat="DD/MM, HH:mm"placeholder="Elegir Fecha" formControlName="fecha"></ion-datetime>
</label>
<span
*ngIf="fecha?.errors?.required && submitted">
@ -29,17 +29,6 @@
</span>
</ion-item>
<ion-item>
<label>
Hora
<ion-datetime displayFormat="HH:MM"placeholder="Elegir Hora" formControlName="hora"></ion-datetime>
</label>
<span
*ngIf="hora.errors.required && submitted">
Tu evento necesita una hora
</span>
</ion-item>
<ion-item>
<label>

View File

@ -1,10 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Tab1Service } from '../tab1/tab1.service';
import { Evento } from '../evento';
import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi';
import { DatePipe } from '@angular/common'
import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.module';
@Component({
selector: 'app-prompt-evento',
@ -12,18 +10,18 @@ import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.
styleUrls: ['./prompt-evento.page.scss'],
})
export class PromptEventoPage implements OnInit{
submitted = false;
editarEvento = false;
eventoForm = new FormGroup({
nombre: new FormControl(null, Validators.required),
fecha: new FormControl(null, Validators.required),
hora: new FormControl(null, Validators.required),
precio1: new FormControl(null, Validators.required),
precio2: new FormControl(null, Validators.required),
descripcion: new FormControl(null, Validators.required),
nombre: new FormControl('', Validators.required),
fecha: new FormControl('', Validators.required),
precio1: new FormControl('', Validators.required),
precio2: new FormControl('', Validators.required),
descripcion: new FormControl('', Validators.required),
});
eventos: Eventoi[];
eventos: Evento[];
constructor(private tab1Service: Tab1Service, private router: Router) {
@ -37,50 +35,30 @@ export class PromptEventoPage implements OnInit{
onSubmit(){
this.submitted = true;
if (this.eventoForm.valid){
let evento: Eventoi = {
id: null,
discotecaID: this.tab1Service.discotecaI.discotecaID,
nombre: '',
localizacion: this.tab1Service.discotecaI.localizacion,
fecha: null,
hora: null,
descripcion: '',
precio1: null,
precio2: null
};
let evento = new Evento();
this.asignarEvento(evento);
this.router.navigate(['/tabs']);
}
}
asignarEvento(evento: Eventoi){
evento.nombre = this.eventoForm.get('nombre').value;
evento.descripcion = this.eventoForm.get('descripcion').value;
var fecha = this.eventoForm.get('fecha').value;
fecha = fecha.split("T")[0];
evento.fecha = fecha;
let hora = this.eventoForm.get('hora').value;
hora = hora.split("T")[1];
hora = hora.split(":")[0]+(":")+hora.split(":")[1];
evento.hora = hora;
evento.precio1 = this.eventoForm.get('precio1').value;
evento.precio2 = this.eventoForm.get('precio2').value;
asignarEvento(evento: Evento){
evento.setNombre(this.eventoForm.get('nombre').value);
evento.setDesc(this.eventoForm.get('descripcion').value);
evento.setFecha(this.eventoForm.get('fecha').value);
evento.setPrecio1(this.eventoForm.get('precio1').value);
evento.setPrecio2(this.eventoForm.get('precio2').value);
//evento.setDia(evento.getFecha()); el datetime de Ion devuelve un String, no se puede
//evento.setHora(evento.getFecha()); transformar en dia y hora
if (!this.tab1Service.eventos){
this.tab1Service.initEventos();}
if(!this.tab1Service.eventoForms){
this.tab1Service.initEventoForms();}
if(this.tab1Service.editarEvento==true){
this.tab1Service.updateEvento(evento);
//this.tab1Service.eventos[this.tab1Service.eventoIndex] = evento;
//this.tab1Service.eventoForms[this.tab1Service.eventoIndex] = this.eventoForm;
this.tab1Service.eventos[this.tab1Service.eventoIndex] = evento;
this.tab1Service.eventoForms[this.tab1Service.eventoIndex] = this.eventoForm;
}
else{
this.tab1Service.postEvento(evento);
//this.tab1Service.eventos.push(evento);
//this.tab1Service.eventoForms.push(this.eventoForm);
}
this.tab1Service.eventos.push(evento);
this.tab1Service.eventoForms.push(this.eventoForm);}
}

View File

@ -1,57 +0,0 @@
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 '../interfaces/user';
import { Discoteca } from '../discoteca';
import { UserLogin } from '../interfaces/user-login';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi';
@Injectable({
providedIn: 'root'
})
export class ApiService {
baseUrl = "http://localhost:3307/api/consultas";
constructor(private http: HttpClient) {
}
validateUser(user: UserLogin): Observable<User>{
return this.http.post<User>(this.baseUrl+"/users", user)
}
getUserDiscoteca(discotecaId: number): Observable<DiscotecaI>{
return this.http.post<DiscotecaI>(this.baseUrl+"/discoteca", { "id": discotecaId});
}
postEvento(eventoInterface: Eventoi): Observable<Eventoi>{
return this.http.post<Eventoi>(this.baseUrl+"/evento", eventoInterface);
}
getEventos(): Observable<Eventoi[]>{
return this.http.get<Eventoi[]>(this.baseUrl+"/evento");
}
getEventosDiscoteca(discotecaID: number): Observable<Eventoi[]>{
return this.http.post<Eventoi[]>(this.baseUrl+"/eventosDiscoteca", {"id": discotecaID});
}
}

View File

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

View File

@ -1,22 +0,0 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi';
import { ApiService } from './api.service';
@Injectable({
providedIn: 'root'
})
export class FeedService {
eventos: Eventoi[];
constructor(private apiService: ApiService, private router: Router) { }
initFeed(): void{
this.apiService.getEventos()
.subscribe(eventos => {
this.eventos = eventos;
})
}
}

View File

@ -1,47 +0,0 @@
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 '../interfaces/user';
import { UserLogin } from '../interfaces/user-login';
import { FeedService } from './feed.service';
@Injectable({
providedIn: 'root'
})
export class LoginService {
user: User;
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
this.user = {
id: 0,
discotecaID: 0,
userType: 0,
username: '',
};
}
validateUser(login: string, password: string): void{
let userlogin: UserLogin = {
loginUser: login,
loginPassword: password,
}
this.apiService.validateUser(userlogin)
.subscribe(user => {
this.user = user[0];
if (this.user.userType==0)
this.tab1service.getDiscoteca(this.user.discotecaID);
else if (this.user.userType==1)
this.feedService.initFeed();
})
}
}

View File

@ -6,6 +6,7 @@ import { PerfilDiscotecaPage } from '../perfil-discoteca/perfil-discoteca.page'
import { IonSlides} from '@ionic/angular';
import { AlertController } from '@ionic/angular';
import { ViewChild } from '@angular/core';
import { Evento } from '../evento';
import { Router } from '@angular/router';
import { from } from 'rxjs';

View File

@ -2,13 +2,9 @@ import { Injectable, OnInit } from '@angular/core';
import { stringify } from 'querystring';
import { Tab1Page } from './tab1.page'
import { Discoteca } from '../discoteca'
import { Observable, of } from 'rxjs';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Evento } from '../evento';
import { FormControl, FormGroup } from '@angular/forms';
import { NumericValueAccessor } from '@ionic/angular';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { ApiService } from '../services/api.service';
import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi';
@Injectable({
@ -17,114 +13,64 @@ import { Eventoi } from '../interfaces/eventoi';
export class Tab1Service implements OnInit{
discoteca: Discoteca;
discotecaI: DiscotecaI;
galeria: string[];
eventos: Eventoi[];
eventos: Evento[];
eventoForms: FormGroup[];
eventoIndex: number;
editarEvento: boolean;
constructor(private apiService: ApiService, private router: Router) {
constructor() {
}
ngOnInit(){
this.initValues();
}
initValues(): void{
this.discoteca = new Discoteca();
this.discoteca.setId(this.discotecaI.discotecaID);
this.discoteca.setNombre(this.discotecaI.nombre);
this.discoteca.setTelefono(this.discotecaI.telefono);
this.discoteca.setLocalizacion(this.discotecaI.localizacion);
this.initEventos();
this.discoteca.setNombre('Barraca');
this.discoteca.setTelefono(666666666);
this.discoteca.setLocalizacion('Calle del Barquillo');
this.discoteca.setDescripcion('Barraca es una discoteca inaugurada en 1965 que tuvo su gran auge en los años 80, cuando se consolidó como la discoteca de mayor importancia de la movida valenciana, durante la conocida Ruta Destroy.');
this.galeria = [];
this.initEventos();
this.editarEvento = false;
}
getNombre(): string{
this.initValues();
return this.discoteca.getNombre();
}
getTelefono(): number{
this.initValues();
return this.discoteca.getTelefono();
}
getLocalizacion(): string{
this.initValues();
return this.discoteca.getLocalizacion();
}
getEventos(): Eventoi[]{
return this.eventos;
}
getDescripcion(): string{
return this.discoteca.getDescripcion();
}
getEventos(): Evento[]{
return this.eventos;
}
initEventos(): void{
this.eventos = [];
this.apiService.getEventosDiscoteca(this.discoteca.getId())
.subscribe(eventos => {
this.eventos = eventos;
this.router.navigate(['/tabs/tab1/perfil-discoteca']);
})
}
initEventoForms(): void{
this.eventoForms = [];
if (this.eventos){
this.eventos.forEach(evento => {
let thisForm = new FormGroup({
nombre: new FormControl(null, Validators.required),
fecha: new FormControl(null, Validators.required),
hora: new FormControl(null, Validators.required),
precio1: new FormControl(null, Validators.required),
precio2: new FormControl(null, Validators.required),
descripcion: new FormControl(null, Validators.required),
});
thisForm.controls['nombre'].setValue(evento.nombre);
thisForm.controls['fecha'].setValue(evento.fecha);
thisForm.controls['hora'].setValue(evento.hora);
thisForm.controls['precio1'].setValue(evento.precio1);
thisForm.controls['precio2'].setValue(evento.precio2);
thisForm.controls['descripcion'].setValue(evento.descripcion);
this.eventoForms.push(thisForm);
})
}
}
getEventobyIndex(eventoIndex: number){
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();
})
}
}
postEvento(evento: Eventoi){
this.apiService.postEvento(evento)
.subscribe(evento => {
this.initEventos();
})
}
updateEvento(evento: Eventoi){
}
}

6
src/app/user.ts Normal file
View File

@ -0,0 +1,6 @@
export interface User {
userId: number;
userType: number;
loginUser: string;
loginPassword: string;
}

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Eventoi } from '../interfaces/eventoi';
import { Evento } from '../evento';
import { Tab1Service } from '../tab1/tab1.service';
@Component({
@ -9,7 +9,7 @@ import { Tab1Service } from '../tab1/tab1.service';
})
export class ViewEventoPage implements OnInit {
evento: Eventoi;
evento: Evento;
constructor(private tab1Service: Tab1Service) { }