Compare commits

..

No commits in common. "f6756c25a89ee08ab54ea6b49295ac3c3eb61b95" and "de5a925e388187346bb4dbe7947e9cb83a4567dc" have entirely different histories.

12 changed files with 45 additions and 78 deletions

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

@ -0,0 +1,31 @@
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';
@Injectable({
providedIn: 'root'
})
export class ApiService {
constructor(private http: HttpClient) {
}
validateUser(user: UserLogin): Observable<User>{
return this.http.post<User>("http://localhost:3307/api/consultas/users", user)
}
}

2
src/app/discoteca-i.ts Normal file
View File

@ -0,0 +1,2 @@
export interface DiscotecaI {
}

View File

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

View File

@ -1,2 +0,0 @@
export interface Eventoi {
}

View File

@ -2,9 +2,8 @@ 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 { User } from './user';
import { UserLogin } from './user-login';
@Injectable({
@ -14,10 +13,10 @@ export class LoginService {
user: User;
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service) {
constructor(private apiService: ApiService, private router: Router) {
this.user = {
id: 0,
discotecaID: 0,
discotecaId: 0,
userType: 0,
username: '',
};
@ -32,11 +31,8 @@ export class LoginService {
this.apiService.validateUser(userlogin)
.subscribe(user => {
this.user = user[0];
this.user = user;
console.log(this.user);
console.log(this.user.discotecaID);
this.tab1service.getDiscoteca(this.user.discotecaID);
})
}

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../services/login.service';
import { User } from '../interfaces/user';
import { LoginService } from '../login.service';
import { User } from '../user';
@Component({
selector: 'app-login',

View File

@ -1,38 +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';
@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});
}
}

View File

@ -5,9 +5,6 @@ import { Discoteca } from '../discoteca'
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';
@Injectable({
@ -16,14 +13,13 @@ import { Router } from '@angular/router';
export class Tab1Service implements OnInit{
discoteca: Discoteca;
discotecaI: DiscotecaI;
galeria: string[];
eventos: Evento[];
eventoForms: FormGroup[];
eventoIndex: number;
editarEvento: boolean;
constructor(private apiService: ApiService, private router: Router) {
constructor() {
}
@ -33,9 +29,9 @@ export class Tab1Service implements OnInit{
initValues(): void{
this.discoteca = new Discoteca();
this.discoteca.setNombre(this.discotecaI.nombre);
this.discoteca.setTelefono(this.discotecaI.telefono);
this.discoteca.setLocalizacion(this.discotecaI.localizacion);
this.discoteca.setNombre('Barraca');
this.discoteca.setTelefono(666666666);
this.discoteca.setLocalizacion('Calle del Barquillo');
this.galeria = [];
this.initEventos();
this.editarEvento = false;
@ -77,16 +73,4 @@ 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']);
})
}
}
}

View File

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