Commit 27ea8d02 by Luciano Barletta

added a purchase component and the search works better

1 parent 2f489806
...@@ -3,11 +3,13 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -3,11 +3,13 @@ import { Routes, RouterModule } from '@angular/router';
import { InformacionComponent } from './informacion/informacion.component'; import { InformacionComponent } from './informacion/informacion.component';
import { MainComponent } from './main/main.component'; import { MainComponent } from './main/main.component';
import { BusquedaComponent } from './busqueda/busqueda.component'; import { BusquedaComponent } from './busqueda/busqueda.component';
import { CompraComponent } from './compra/compra.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component : MainComponent }, { path: '', component : MainComponent },
{ path: 'informacion/:id', component: InformacionComponent }, { path: 'informacion/:id', component: InformacionComponent },
{ path: 'busqueda/:search', component: BusquedaComponent } { path: 'busqueda/:search', component: BusquedaComponent },
{ path: 'comprar/:id', component: CompraComponent }
]; ];
/* { path: '**', component: PageNotFoundComponent } */ /* { path: '**', component: PageNotFoundComponent } */
......
...@@ -10,6 +10,7 @@ import { InformacionComponent } from './informacion/informacion.component'; ...@@ -10,6 +10,7 @@ import { InformacionComponent } from './informacion/informacion.component';
import { ImagesService } from './services/images.service'; import { ImagesService } from './services/images.service';
import { BusquedaComponent } from './busqueda/busqueda.component'; import { BusquedaComponent } from './busqueda/busqueda.component';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { CompraComponent } from './compra/compra.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -18,7 +19,8 @@ import { FormsModule } from '@angular/forms'; ...@@ -18,7 +19,8 @@ import { FormsModule } from '@angular/forms';
MainComponent, MainComponent,
NavBarComponent, NavBarComponent,
InformacionComponent, InformacionComponent,
BusquedaComponent BusquedaComponent,
CompraComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
......
Está por comprar la funcion de id {{ eventid }}
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CompraComponent } from './compra.component';
describe('CompraComponent', () => {
let component: CompraComponent;
let fixture: ComponentFixture<CompraComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CompraComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CompraComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-compra',
templateUrl: './compra.component.html',
styleUrls: ['./compra.component.css']
})
export class CompraComponent implements OnInit {
public eventid
constructor(
private route: ActivatedRoute,
private router: Router,
) { }
ngOnInit(): void {
this.route.paramMap.subscribe(
(params) => {
this.eventid = params.get('id');
}
);
}
}
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
/* Style the tab content */ /* Style the tab content */
.tabcontent { .tabcontent {
display: none;
margin: none; margin: none;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<img class="EspectaculoImagen" src="assets/images/{{ imagename }}"> <img class="EspectaculoImagen" src="assets/images/{{ imagename }}">
<div class="tab"> <div class="tab">
<svg width="70" height="75"> <svg width="70" height="75">
<a href="#" onclick="openCity(event, 'Funciones')"> <a (click)="showInfo('Funciones')">
<polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" /> <polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" />
<image xlink:href="assets/images/Funciones.png" <image xlink:href="assets/images/Funciones.png"
x="5" y="5" height="40px" width="40px"></image> x="5" y="5" height="40px" width="40px"></image>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</svg> </svg>
<svg width="70" height="75"> <svg width="70" height="75">
<a href="#" onclick="openCity(event, 'Entradas')"> <a (click)="showInfo('Entradas')">
<polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" /> <polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" />
<image xlink:href="assets/images/Entrada.png" <image xlink:href="assets/images/Entrada.png"
x="5" y="5" height="40px" width="40px"></image> x="5" y="5" height="40px" width="40px"></image>
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
</svg> </svg>
<svg width="70" height="75"> <svg width="70" height="75">
<a href="#" onclick="openCity(event, 'Teatro')"> <a (click)="showInfo('Teatro')">
<polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" /> <polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" />
<image xlink:href="assets/images/Teatro.png" <image xlink:href="assets/images/Teatro.png"
x="5" y="5" height="40px" width="40px"></image> x="5" y="5" height="40px" width="40px"></image>
</a> </a>
</svg> </svg>
<svg width="70" height="75"> <svg width="70" height="75">
<a href="#" onclick="openCity(event, 'Duracion')"> <a (click)="showInfo('Tiempo')">
<polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" /> <polygon points="0,0 0,75 25,50 50,75 50,0" class="Boton" />
<image xlink:href="assets/images/Tiempo.png" <image xlink:href="assets/images/Tiempo.png"
x="5" y="5" height="40px" width="40px"></image> x="5" y="5" height="40px" width="40px"></image>
...@@ -34,18 +34,18 @@ ...@@ -34,18 +34,18 @@
</svg> </svg>
</div> </div>
<div id="Funciones" class="tabcontent"> <div *ngIf="funciones" id="Funciones" class="tabcontent">
<h3>Funciones</h3> <h3>Funciones</h3>
</div> </div>
<div id="Entradas" class="tabcontent"> <div *ngIf="entradas" class="tabcontent">
<h3>Entradas</h3> <h3>Entradas</h3>
</div> </div>
<div id="Teatro" class="tabcontent"> <div *ngIf="teatro" class="tabcontent">
<h3>Teatro</h3> <h3>Teatro</h3>
</div> </div>
<div id="Duracion" class="tabcontent"> <div *ngIf="tiempo" class="tabcontent">
<h3>Duracion</h3> <h3>Duracion</h3>
</div> </div>
...@@ -65,6 +65,8 @@ ...@@ -65,6 +65,8 @@
ut aliquip ex ea commodo consequat.</p> ut aliquip ex ea commodo consequat.</p>
<h3>Calificacion: &#9733; &#9733; &#9733; &#9733; &#9734;</h3> <h3>Calificacion: &#9733; &#9733; &#9733; &#9733; &#9734;</h3>
<input class="EspectaculoBoton" type="button" value="Quiero Mi Entrada!"> <button routerLink="/comprar/{{ imageid }}" class="EspectaculoBoton" type="button">
Quiero mi entrada!
</button>
</div> </div>
</div> </div>
...@@ -16,6 +16,12 @@ export class InformacionComponent implements OnInit { ...@@ -16,6 +16,12 @@ export class InformacionComponent implements OnInit {
}; };
public imagename; public imagename;
public imageid;
public funciones : boolean = false;
public entradas : boolean = false;
public tiempo : boolean = false;
public teatro : boolean = false;
constructor( constructor(
private route : ActivatedRoute, private route : ActivatedRoute,
...@@ -24,8 +30,30 @@ export class InformacionComponent implements OnInit { ...@@ -24,8 +30,30 @@ export class InformacionComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.route.paramMap.subscribe( this.route.paramMap.subscribe(
(params) => this.imagename = this.id2name[params.get('id')] (params) => {
this.imageid = params.get('id');
this.imagename = this.id2name[this.imageid]
}
); );
} }
showInfo(show : string) {
console.log(show);
this.funciones = this.teatro = this.tiempo = this.entradas = false;
switch (show) {
case "Funciones":
this.funciones = true;
break;
case "Entradas":
this.entradas = true;
break;
case "Tiempo":
this.tiempo = true;
break;
case "Teatro":
this.teatro = true;
break;
}
}
} }
...@@ -26,26 +26,26 @@ ...@@ -26,26 +26,26 @@
justify-content: space-between; justify-content: space-between;
} }
.NavInput { .NavInput, .NavSuggestion {
outline: none; outline: none;
margin-right: 10%;
height: 40%;
width: 90%;
float: right;
padding: 6px; padding: 6px;
border: none;
font-size: 17px; font-size: 17px;
border-radius: 10px; border-radius: 10px;
}
.NavInput {
border: none;
float: right;
margin-right: 10%;
width: 100%;
height: 40%;
} }
.NavSuggestion { .NavSuggestion {
width: 27%;
background-color: white; background-color: white;
border: solid 1px grey; border: solid 1px grey;
position: absolute; position: absolute;
width: 30%; top: 50px;
left: 70%; z-index: 1;
padding: 3px;
top: 0;
transform: translate(-50%,220%);
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<img class="NavLogo" src="assets/images/LogoProv2.png" style="height: auto; width: 250px;"> <img class="NavLogo" src="assets/images/LogoProv2.png" style="height: auto; width: 250px;">
</a> </a>
<div class="NavSearchContainer"> <div class="NavSearchContainer">
<input [(ngModel)]="search" (keyup)="showinput()" (keydown)="hideinput()" class="NavInput" type="text" placeholder="Search.."> <input [(ngModel)]="search" (keyup)="showinput()" class="NavInput" type="text" placeholder="Search..">
<a routerLink="/busqueda/{{ search }}"> <a routerLink="/busqueda/{{ search }}">
<i class="fas fa-search fa-2x" style="color:white;"></i> <i class="fas fa-search fa-2x" style="color:white;"></i>
</a> </a>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Observable, interval } from 'rxjs'; import { Observable, interval } from 'rxjs';
import { switchMap, take } from 'rxjs/operators'; import { switchMap, take, switchMapTo } from 'rxjs/operators';
import { filter } from 'rxjs/operators';
import { Router, ActivatedRoute, NavigationStart, Navigation } from '@angular/router';
@Component({ @Component({
selector: 'nav-bar', selector: 'nav-bar',
...@@ -12,16 +14,33 @@ export class NavBarComponent implements OnInit { ...@@ -12,16 +14,33 @@ export class NavBarComponent implements OnInit {
search : string = ''; search : string = '';
suggestion : boolean = false; suggestion : boolean = false;
constructor() { } private clearSearch$;
constructor(
private route: ActivatedRoute,
private router: Router,
) { }
ngOnInit(): void { ngOnInit(): void {
/* On route change, clear search bar */
this.clearSearch$ = this.router.events.pipe(
filter(event => event instanceof NavigationStart)
)
.subscribe( (event : NavigationStart) => {
this.search = '';
this.suggestion = false;
} );
} }
showinput() { showinput() {
interval(1000).pipe( take(1) ) /** this needs to be done with switchmap **/
.subscribe( if (this.search == "") {
() => this.suggestion = true this.hideinput()
); }
else {
this.suggestion = true;
}
} }
hideinput() { hideinput() {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!