12 Commits

20 changed files with 956 additions and 560 deletions

1157
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,23 +13,26 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^11.2.1",
"@angular/cdk": "^11.2.1",
"@angular/common": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/material": "^11.2.1",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@capacitor/core": "2.4.3",
"@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",
"@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",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"tslib": "^2.1.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.0",
"@angular-devkit/build-angular": "^0.1000.8",
"@angular/cli": "10.0.8",
"@angular/compiler": "~10.0.0",
"@angular/compiler-cli": "~10.0.0",
@@ -38,15 +41,15 @@
"@ionic/angular-toolkit": "^2.3.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"@types/node": "^12.20.4",
"codelyzer": "^6.0.0",
"cordova-android": "^9.0.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
@@ -57,7 +60,7 @@
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.9.5"
"typescript": "^3.9.9"
},
"description": "An Ionic project",
"cordova": {

View File

@@ -11,12 +11,17 @@ import { AppComponent } from './app.component';
import { PerfilDiscotecaPage } from './perfil-discoteca/perfil-discoteca.page';
import { PromptEventoPage} from './prompt-evento/prompt-evento.page'
import { GaleriamodalPageModule } from './galeriamodal/galeriamodal.module';
import { MatMenuModule } from '@angular/material/menu';
import { MatCardModule } from '@angular/material/card';
import { LoginPage } from './login/login.page';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatIconModule } from '@angular/material/icon';
@NgModule({
declarations: [AppComponent, PerfilDiscotecaPage, PromptEventoPage, LoginPage],
entryComponents: [],
imports: [BrowserModule, HttpClientModule, IonicModule.forRoot(), AppRoutingModule, ReactiveFormsModule, GaleriamodalPageModule],
imports: [BrowserModule, HttpClientModule, IonicModule.forRoot(), AppRoutingModule, ReactiveFormsModule, GaleriamodalPageModule, MatMenuModule, BrowserAnimationsModule, MatIconModule, MatCardModule],
providers: [
StatusBar,
SplashScreen,

View File

@@ -1,5 +1,5 @@
import {Evento} from './evento';
import {Eventoi} from './interfaces/eventoi';
export class Discoteca {
@@ -7,7 +7,7 @@ export class Discoteca {
private nombre: string;
private telefono: number;
private localizacion: string;
private eventos: Evento[];
private eventos: Eventoi[];
private descripcion: string;
setId(id: number): void{
@@ -42,7 +42,7 @@ export class Discoteca {
return this.localizacion
}
getEventos(): Evento[]{
getEventos(): Eventoi[]{
return this.eventos;
}

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

@@ -8,38 +8,52 @@
<ion-content [fullscreen]="true">
<div class='fotoPerfil'>
<div class='main'>
<ion-grid>
<ion-row>
<ion-col>
<div class='fotoPerfil'>
<ion-img class="fotoPerfil" width="100%" height="100%" [src]='fotoSrc' alt='barraquinha'></ion-img>
<div class="textoPie">{{nombre}}</div>
</div>
</ion-row>
<div class="addFoto">
<ion-button [disabled]='editDisabled'>
<ion-icon name="image" slot="icon-only"></ion-icon>
<input type="file" (change)="loadImageFromDevice($event);cargarImagen()" id="file-input-perfil" accept="image/png, image/jpeg">
</ion-button>
</div>
<ion-row>
<div class="menuBotones">
<div>
<ion-button (click)="enableEdit()" label="editar" [disabled]='editEnabled'>
<ion-icon name="create"></ion-icon>
</ion-button>
<div id="botonesHidden1" class="botonesHidden">
<ion-button (click)="saveEdit()" label="guardar" [disabled]='editDisabled'>
<ion-icon name="save"></ion-icon>
</ion-button>
<ion-button (click)="cancelEdit()" [disabled]='editDisabled'>
<button mat-icon-button [matMenuTriggerFor]="menu">
<ion-icon name="settings" class="settingsIcon"></ion-icon>
</button>
<mat-menu #menu="matMenu" xPositon="after" yPosition="above">
<button mat-menu-item>
<ion-icon name="image" slot="icon-only"></ion-icon>
<input type="file" (change)="loadImageFromDevice($event);cargarImagen()" id="file-input-perfil" accept="image/png, image/jpeg">
</button>
<button mat-menu-item (click)="enableEdit()" label="editar" [disabled]='editEnabled'>
<ion-icon name="create"></ion-icon>
</button>
<button mat-menu-item (click)="addEvento()">
<ion-icon name="add-circle-outline">
</ion-icon>
Añadir evento
</button>
</mat-menu>
</div>
</ion-row>
<ion-row>
<div id="botonesHidden1" class="botonesHidden">
<button (click)="saveEdit()" label="guardar" [disabled]='editDisabled' id="saveButton">
<ion-icon name="save"></ion-icon>
</button>
<button (click)="cancelEdit()" [disabled]='editDisabled' id="cancelButton">
Cancelar
</ion-button></div>
</div>
</ion-col>
</button>
</div>
</ion-row>
@@ -52,10 +66,24 @@
<div [contentEditable]='editEnabled'>{{localizacion}}</div>
</div>
</ion-col>
<ion-col>
<div>
<mat-card>
<mat-card-header>
Descripción
</mat-card-header>
<mat-card-content>
{{descripcion}}
</mat-card-content>
</mat-card>
</div>
</ion-col>
</ion-row>
<ion-row>
<div class="galeria">
Galería de Fotos
<input type="file" (change)="loadImageFromDevice($event)" id="file-input-galeria" accept="image/png, image/jpeg">
<ion-slides (ionDrag)="onSlideChanged()" [options]="sliderOpts">
<ion-slide *ngFor="let foto of galeriaFotos">
@@ -69,19 +97,10 @@
</ion-slide>
</ion-slides>
</div>
</ion-col>
</ion-row>
<ion-row>
<ion-button (click)="addEvento()">
<ion-icon name="add-circle-outline">
</ion-icon>
Añadir evento
</ion-button>
</ion-row>
<ion-row>
<ion-col size="12">
<div *ngIf="eventos.length>0" class="eventos">
<ion-list>
<ion-item *ngFor="let evento of eventos" button (click)="mostrarEvento(evento)">
@@ -101,14 +120,13 @@
</ion-item>
</ion-list>
</div>
</ion-col>
</ion-row>
<ion-row>
</ion-row>
</ion-grid>
</div>
</ion-content>

View File

@@ -6,16 +6,20 @@
}
*{
padding: 5px;
padding: 10px;
display: block;
}
.main{
max-width: 800px;
max-height: auto;
margin: auto;
text-align: justify;
}
.fotoPerfil{
text-align: end;
max-width: 800px;
max-height: auto;
margin: auto;
}
.textoPie{
@@ -35,6 +39,8 @@
float: left;
position: relative;
margin: auto;
text-align: right;
padding-right: 50px;
}
@@ -43,15 +49,14 @@
}
.galeria{
display: block;
max-width: 300px;
max-height: auto;
text-align: center;
padding: 30px;
margin: auto;
}
.botonesHidden{
display: none;
padding: none;
}
.botonesVisible{
@@ -59,14 +64,21 @@
}
.eventos{
display:block;
text-align: justify;
}
.evento{
max-width:fit-content;
}
.evento:hover{
background-color: rgb(97, 97, 97);
}
.eventoHeader{
font-weight: bold;
float: left;
}
.eventoDesc{
@@ -76,3 +88,26 @@
ion-slides {
height: 200px;
}
mat-card-header{
text-align: right;
font-weight: bold;
}
button{
background-color: transparent;
}
.settingsIcon{
font-size: large;
background-color: white;
}
.menuBotones{
position: relative;
float: left;
bottom: 60px;
left: 20px;
}

View File

@@ -33,7 +33,6 @@ export class PerfilDiscotecaPage implements OnInit {
sliderOpts = {
slidesPerView: 1.5,
centeredSlides: true,
spaceBetween: 20,
};
constructor(private tab1Service: Tab1Service, private router: Router, private modalController: ModalController) {
@@ -49,6 +48,7 @@ export class PerfilDiscotecaPage implements OnInit {
this.getTelefono();
this.getLocalizacion();
this.getEventos();
this.getDescripcion();
this.editDisabled="true";
this.editEnabled="false";
this.fotoSrc = '../assets/img/barraca.jpg';
@@ -79,6 +79,7 @@ export class PerfilDiscotecaPage implements OnInit {
this.eventos = this.tab1Service.eventos;
}
cargarImagen(){
this.fotoSrc = this.someURL;
}
@@ -123,10 +124,14 @@ export class PerfilDiscotecaPage implements OnInit {
let cajaDatos = document.getElementById("cajaDatos");
cajaDatos.style.background="white";
cajaDatos.style.color="black";
cajaDatos.contentEditable = "true";
let botones = document.getElementById("botonesHidden1");
botones.style.display = "block";
botones = document.getElementById("botonesHidden2");
botones.style.display = "block";
let saveButton = document.getElementById("saveButton") as HTMLButtonElement;
saveButton.disabled=false;
let cancelButton = document.getElementById("cancelButton") as HTMLButtonElement;
cancelButton.disabled=false;
@@ -138,6 +143,7 @@ export class PerfilDiscotecaPage implements OnInit {
let cajaDatos = document.getElementById("cajaDatos");
cajaDatos.style.background="inherit";
cajaDatos.style.color="inherit";
cajaDatos.contentEditable="false";
let botones = document.getElementById("botonesHidden1");
botones.style.display = "none";
botones = document.getElementById("botonesHidden2");
@@ -183,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

@@ -13,7 +13,7 @@
<input type="text" id="nombre" formControlName = "nombre">
</label>
<span
*ngIf="nombre.errors.required && (nombre.touched||submitted)">
*ngIf="nombre?.errors?.required && (nombre.touched||submitted)">
Tu evento necesita un nombre
</span>
</ion-item>
@@ -24,7 +24,7 @@
<ion-datetime displayFormat="YYYY/DD/MM"placeholder="Elegir Fecha" formControlName="fecha"></ion-datetime>
</label>
<span
*ngIf="fecha.errors.required && submitted">
*ngIf="fecha?.errors?.required && submitted">
Tu evento necesita una fecha
</span>
</ion-item>
@@ -47,7 +47,7 @@
<input type="number" formControlName = "precio1"><label>, </label><input type="number" formControlName = "precio2">
</label>
<span
*ngIf="precio1.errors.required && (precio1.touched||submitted)">
*ngIf="precio1?.errors?.required && (precio1.touched||submitted)">
Tu evento necesita un precio (puede ser 0)
</span>
</ion-item>
@@ -58,7 +58,7 @@
<textarea formControlName = "descripcion" rows="10"></textarea>
</label>
<span
*ngIf="descripcion.errors.required && (descripcion.touched||submitted)">
*ngIf="descripcion?.errors?.required && (descripcion.touched||submitted)">
¡Dale una descripción a tu evento!
</span>
</ion-item>

View File

@@ -13,6 +13,7 @@ import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.
})
export class PromptEventoPage implements OnInit{
submitted = false;
editarEvento = false;
eventoForm = new FormGroup({
nombre: new FormControl(null, Validators.required),
fecha: new FormControl(null, Validators.required),

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);
this.tab1service.getDiscoteca(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

@@ -6,7 +6,6 @@ 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

@@ -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){
}
}

View File

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