upsi dupsi, da sind noch die componenten 🤡
This commit is contained in:
5
src/app/model/theater-seat-state.model.ts
Normal file
5
src/app/model/theater-seat-state.model.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum TheaterSeatState {
|
||||
AVAILABLE,
|
||||
RESERVED,
|
||||
BOOKED,
|
||||
}
|
||||
1
src/app/seat-row/seat-row.component.css
Normal file
1
src/app/seat-row/seat-row.component.css
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
src/app/seat-row/seat-row.component.html
Normal file
3
src/app/seat-row/seat-row.component.html
Normal file
@@ -0,0 +1,3 @@
|
||||
@for (entry of rowSeatList(); track $index) {
|
||||
<app-seat class="my-1" [seatState]="entry.state" [seatCategory]="entry.seat.row.category"></app-seat>
|
||||
}
|
||||
14
src/app/seat-row/seat-row.component.ts
Normal file
14
src/app/seat-row/seat-row.component.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Component, input} from '@angular/core';
|
||||
import {Sitzplatz} from '@infinimotion/model-frontend';
|
||||
import {TheaterSeatState} from '../model/theater-seat-state.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-seat-row',
|
||||
standalone: false,
|
||||
templateUrl: './seat-row.component.html',
|
||||
styleUrl: './seat-row.component.css'
|
||||
})
|
||||
export class SeatRowComponent {
|
||||
rowSeatList = input.required<{ seat: Sitzplatz, state: TheaterSeatState }[]>();
|
||||
|
||||
}
|
||||
0
src/app/seat/seat.component.css
Normal file
0
src/app/seat/seat.component.css
Normal file
15
src/app/seat/seat.component.html
Normal file
15
src/app/seat/seat.component.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<button class="mx-1 hover:opacity-50">
|
||||
<mat-icon style="font-size: 30px; width: 30px; height: 30px">
|
||||
@if(seatCategory().id ==1){
|
||||
event_seat
|
||||
}
|
||||
@if(seatCategory().id == 2){
|
||||
weekend
|
||||
}
|
||||
@if(seatCategory().id == 3){
|
||||
chair
|
||||
}
|
||||
|
||||
</mat-icon>
|
||||
</button>
|
||||
|
||||
14
src/app/seat/seat.component.ts
Normal file
14
src/app/seat/seat.component.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Component, input} from '@angular/core';
|
||||
import {TheaterSeatState} from '../model/theater-seat-state.model';
|
||||
import {Sitzkategorie} from '@infinimotion/model-frontend';
|
||||
|
||||
@Component({
|
||||
selector: 'app-seat',
|
||||
standalone: false,
|
||||
templateUrl: './seat.component.html',
|
||||
styleUrl: './seat.component.css'
|
||||
})
|
||||
export class SeatComponent {
|
||||
seatState = input.required<TheaterSeatState>();
|
||||
seatCategory = input.required<Sitzkategorie>();
|
||||
}
|
||||
0
src/app/theater-layout/theater-layout.component.css
Normal file
0
src/app/theater-layout/theater-layout.component.css
Normal file
3
src/app/theater-layout/theater-layout.component.html
Normal file
3
src/app/theater-layout/theater-layout.component.html
Normal file
@@ -0,0 +1,3 @@
|
||||
@for (row of seatsPerRow(); track $index) {
|
||||
<app-seat-row class="flex justify-center" [rowSeatList]="row"></app-seat-row>
|
||||
}
|
||||
13
src/app/theater-layout/theater-layout.component.ts
Normal file
13
src/app/theater-layout/theater-layout.component.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {Component, input} from '@angular/core';
|
||||
import {Sitzplatz} from '@infinimotion/model-frontend';
|
||||
import {TheaterSeatState} from '../model/theater-seat-state.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-theater-layout',
|
||||
standalone: false,
|
||||
templateUrl: './theater-layout.component.html',
|
||||
styleUrl: './theater-layout.component.css'
|
||||
})
|
||||
export class TheaterLayoutComponent {
|
||||
seatsPerRow = input.required<{ seat: Sitzplatz, state: TheaterSeatState }[][]>();
|
||||
}
|
||||
9
src/app/theater-overlay/theater-overlay.component.html
Normal file
9
src/app/theater-overlay/theater-overlay.component.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="m-auto w-200 h-10 bg-gray-300 mb-20" style="clip-path: polygon(0% 0%,100% 0%,90% 100%,10% 100%);">
|
||||
<p class="flex justify-center text-2xl fond-bold p-1">
|
||||
Leinwand
|
||||
</p>
|
||||
</div>
|
||||
<div class="">
|
||||
<app-theater-layout [seatsPerRow]="seatsPerRow"></app-theater-layout>
|
||||
</div>
|
||||
|
||||
60
src/app/theater-overlay/theater-overlay.component.ts
Normal file
60
src/app/theater-overlay/theater-overlay.component.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import {Component, inject, input, OnInit} from '@angular/core';
|
||||
import {HttpService} from '../http.service';
|
||||
import {LoadingService} from '../loading.service';
|
||||
import {catchError, of, tap} from 'rxjs';
|
||||
import {Sitzplatz} from '@infinimotion/model-frontend';
|
||||
import {TheaterSeatState} from '../model/theater-seat-state.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-theater-overlay',
|
||||
standalone: false,
|
||||
templateUrl: './theater-overlay.component.html',
|
||||
styleUrl: './theater-overlay.component.css'
|
||||
})
|
||||
export class TheaterOverlayComponent implements OnInit {
|
||||
private http = inject(HttpService);
|
||||
private loading = inject(LoadingService)
|
||||
show = input.required<number>();
|
||||
|
||||
seatsPerRow: { seat: Sitzplatz, state: TheaterSeatState }[][] = []
|
||||
|
||||
ngOnInit() {
|
||||
this.loadShowSeats();
|
||||
}
|
||||
|
||||
loadShowSeats() {
|
||||
this.loading.show();
|
||||
this.http.getSeatsByShowId(2).pipe(
|
||||
tap((data) => {
|
||||
let rows = this.converter(data)
|
||||
this.loading.hide();
|
||||
this.seatsPerRow = rows
|
||||
console.log(rows)
|
||||
}),
|
||||
catchError(err => {
|
||||
this.loading.showError(err);
|
||||
console.error('Fehler beim Laden der Vorstellung', err);
|
||||
return of([]);
|
||||
})
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
converter(resp: { seats: Sitzplatz[], reserved: Sitzplatz[], booked: Sitzplatz[] }): {
|
||||
seat: Sitzplatz,
|
||||
state: TheaterSeatState
|
||||
}[][] {
|
||||
let rows: { seat: Sitzplatz, state: TheaterSeatState }[][] = [];
|
||||
resp.seats.forEach(seat => {
|
||||
if (!rows[seat.row.position]) {
|
||||
rows[seat.row.position] = [];
|
||||
}
|
||||
let state = resp.booked.find(other => other.id == seat.id) ? TheaterSeatState.BOOKED : resp.booked.find(other => other.id == seat.id) ? TheaterSeatState.RESERVED : TheaterSeatState.AVAILABLE;
|
||||
rows[seat.row.position].push({seat: seat, state: state});
|
||||
});
|
||||
rows = rows.filter(row => row.length > 0).sort((a, b) => a[0].seat.row.position - b[0].seat.row.position);
|
||||
rows.forEach(row => row.sort((a, b) => a.seat.position - b.seat.position));
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user