diff --git a/src/app/feed/feed.component.html b/src/app/feed/feed.component.html
new file mode 100644
index 0000000..229abb4
--- /dev/null
+++ b/src/app/feed/feed.component.html
@@ -0,0 +1,3 @@
+
+ feed works!
+
diff --git a/src/app/feed/feed.component.scss b/src/app/feed/feed.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/feed/feed.component.spec.ts b/src/app/feed/feed.component.spec.ts
new file mode 100644
index 0000000..009b6e6
--- /dev/null
+++ b/src/app/feed/feed.component.spec.ts
@@ -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;
+
+ 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();
+ });
+});
diff --git a/src/app/feed/feed.component.ts b/src/app/feed/feed.component.ts
new file mode 100644
index 0000000..da2fc7a
--- /dev/null
+++ b/src/app/feed/feed.component.ts
@@ -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() {}
+
+}
diff --git a/src/app/perfil-discoteca/perfil-discoteca.page.ts b/src/app/perfil-discoteca/perfil-discoteca.page.ts
index fd858bb..6ab4d9e 100644
--- a/src/app/perfil-discoteca/perfil-discoteca.page.ts
+++ b/src/app/perfil-discoteca/perfil-discoteca.page.ts
@@ -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']);
}
diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts
index b922549..8d2d383 100644
--- a/src/app/services/api.service.ts
+++ b/src/app/services/api.service.ts
@@ -39,7 +39,13 @@ export class ApiService {
}
- getEventos(discotecaID: number): Observable{
+ getEventos(): Observable{
+
+ return this.http.get(this.baseUrl+"/evento");
+ }
+
+ getEventosDiscoteca(discotecaID: number): Observable{
+
return this.http.post(this.baseUrl+"/eventosDiscoteca", {"id": discotecaID});
diff --git a/src/app/services/feed.service.spec.ts b/src/app/services/feed.service.spec.ts
new file mode 100644
index 0000000..656b960
--- /dev/null
+++ b/src/app/services/feed.service.spec.ts
@@ -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();
+ });
+});
diff --git a/src/app/services/feed.service.ts b/src/app/services/feed.service.ts
new file mode 100644
index 0000000..980b787
--- /dev/null
+++ b/src/app/services/feed.service.ts
@@ -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;
+
+ })
+ }
+}
diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts
index 977a8b3..ad5d36e 100644
--- a/src/app/services/login.service.ts
+++ b/src/app/services/login.service.ts
@@ -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,
@@ -32,10 +33,11 @@ export class LoginService {
this.apiService.validateUser(userlogin)
.subscribe(user => {
- this.user = user[0];
- console.log(this.user);
- console.log(this.user.discotecaID);
- this.tab1service.getDiscoteca(this.user.discotecaID);
+ this.user = user[0];
+ if (this.user.userType==0)
+ this.tab1service.getDiscoteca(this.user.discotecaID);
+ else if (this.user.userType==1)
+ this.feedService.initFeed();
})
diff --git a/src/app/tab1/tab1.service.ts b/src/app/tab1/tab1.service.ts
index 5b65175..f7de7bd 100644
--- a/src/app/tab1/tab1.service.ts
+++ b/src/app/tab1/tab1.service.ts
@@ -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){
}
+
+
}