FrontEndDev #4

Merged
onsaliyo merged 17 commits from FrontEndDev into master 2021-05-14 15:45:24 +02:00
10 changed files with 118 additions and 11 deletions
Showing only changes of commit 139e3fcb8b - Show all commits

View File

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

View File

View File

@ -0,0 +1,24 @@
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

@ -0,0 +1,14 @@
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

@ -79,9 +79,6 @@ export class PerfilDiscotecaPage implements OnInit {
this.eventos = this.tab1Service.eventos;
}
getDescripcion(): void{
this.descripcion = this.tab1Service.getDescripcion();
}
cargarImagen(){
this.fotoSrc = this.someURL;
@ -192,6 +189,7 @@ export class PerfilDiscotecaPage implements OnInit {
editarEvento(evento: Eventoi){
this.tab1Service.eventoIndex = this.eventos.indexOf(evento);
this.tab1Service.editarEvento = true;
this.tab1Service.initEventoForms();
this.router.navigate(['/tabs/tab1/prompt-evento']);
}

View File

@ -39,7 +39,13 @@ export class ApiService {
}
getEventos(discotecaID: number): Observable<Eventoi[]>{
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

@ -0,0 +1,16 @@
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

@ -0,0 +1,22 @@
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

@ -5,6 +5,7 @@ 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({
@ -14,7 +15,7 @@ export class LoginService {
user: User;
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service) {
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
this.user = {
id: 0,
discotecaID: 0,
@ -33,9 +34,10 @@ export class LoginService {
this.apiService.validateUser(userlogin)
.subscribe(user => {
this.user = user[0];
console.log(this.user);
console.log(this.user.discotecaID);
if (this.user.userType==0)
this.tab1service.getDiscoteca(this.user.discotecaID);
else if (this.user.userType==1)
this.feedService.initFeed();
})

View File

@ -3,7 +3,7 @@ import { stringify } from 'querystring';
import { Tab1Page } from './tab1.page'
import { Discoteca } from '../discoteca'
import { Observable, of } from 'rxjs';
import { FormControl, FormGroup } from '@angular/forms';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NumericValueAccessor } from '@ionic/angular';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { ApiService } from '../services/api.service';
@ -65,7 +65,7 @@ export class Tab1Service implements OnInit{
initEventos(): void{
this.eventos = [];
this.apiService.getEventos(this.discoteca.getId())
this.apiService.getEventosDiscoteca(this.discoteca.getId())
.subscribe(eventos => {
this.eventos = eventos;
this.router.navigate(['/tabs/tab1/perfil-discoteca']);
@ -76,6 +76,25 @@ export class Tab1Service implements OnInit{
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){
@ -91,6 +110,7 @@ getDiscoteca(discotecaId: number){
this.initValues();
})
}
}
postEvento(evento: Eventoi){
@ -105,4 +125,6 @@ getDiscoteca(discotecaId: number){
}
}