diff --git a/src/app/components/player-link/player-link.component.html b/src/app/components/player-link/player-link.component.html new file mode 100644 index 0000000..c960a6f --- /dev/null +++ b/src/app/components/player-link/player-link.component.html @@ -0,0 +1,21 @@ +@if (this.message_parts[0]) { + {{ this.message_parts[0] }} +} @else { } +@if (this.player1_id) { + {{ this.player1_name }} +} +@if (this.message_parts[1]) { + {{ this.message_parts[1] }} +} +@if (this.player2_id) { + {{ this.player2_name }} +} +@if (this.message_parts[2]) { + {{ this.message_parts[2] }} +} +@if (this.player3_id) { + {{ this.player3_name }} +} +@if (this.message_parts[3]) { + {{ this.message_parts[3] }} +} diff --git a/src/app/components/player-link/player-link.component.scss b/src/app/components/player-link/player-link.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/player-link/player-link.component.ts b/src/app/components/player-link/player-link.component.ts new file mode 100644 index 0000000..3a89c49 --- /dev/null +++ b/src/app/components/player-link/player-link.component.ts @@ -0,0 +1,53 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {MatAnchor} from "@angular/material/button"; +import {RouterLink} from "@angular/router"; + +@Component({ + selector: 'player-link', + standalone: true, + imports: [ + MatAnchor, + RouterLink + ], + templateUrl: './player-link.component.html', + styleUrl: './player-link.component.scss' +}) +export class PlayerLinkComponent implements OnInit { + + player1_id: string; + player1_name: string; + player2_id: string; + player2_name: string; + player3_id: string; + player3_name: string; + + message_parts: string[]; + + + constructor() {} + + @Input() validationMessage: string; + + ngOnInit(): void { + this.parse(this.validationMessage); + } + + parse(message: string) { + this.message_parts = message.split(/\[.*?]/g); + const matches = message.match(/\[(\d+)\|.*?]/g); + if (matches) { + if (matches[0]) { + this.player1_id = matches[0].substring(1, matches[0].indexOf("|")); + this.player1_name = matches[0].substring(matches[0].indexOf("|") + 1, matches[0].indexOf("]")); + } + if (matches[1]) { + this.player2_id = matches[1].substring(1, matches[1].indexOf("|")); + this.player2_name = matches[1].substring(matches[1].indexOf("|") + 1, matches[1].indexOf("]")); + } + if (matches[2]) { + this.player3_id = matches[2].substring(1, matches[2].indexOf("|")); + this.player3_name = matches[2].substring(matches[2].indexOf("|") + 1, matches[2].indexOf("]")); + } + } + } +} diff --git a/src/app/components/tournament-manage/tournament-manage.component.html b/src/app/components/tournament-manage/tournament-manage.component.html index e751acb..c667214 100644 --- a/src/app/components/tournament-manage/tournament-manage.component.html +++ b/src/app/components/tournament-manage/tournament-manage.component.html @@ -46,11 +46,16 @@ + + +
Totaal: {{ getTournamentMatchCount(tournament)}} wedstrijden
+
+
@for (event of tournament.events; track event) { @if (event.groups.length > 0) { -
Indeling {{ TournamentEvent.getType(event.type) }}
+
Indeling {{ TournamentEvent.getType(event.type) }} ({{ getEventMatchCount(event)}} wedstrijden)
diff --git a/src/app/components/tournament-manage/tournament-manage.component.ts b/src/app/components/tournament-manage/tournament-manage.component.ts index e03e2be..a18a2b6 100644 --- a/src/app/components/tournament-manage/tournament-manage.component.ts +++ b/src/app/components/tournament-manage/tournament-manage.component.ts @@ -345,6 +345,24 @@ export class TournamentManageComponent implements OnInit { protected readonly TournamentEvent = Event; + getEventMatchCount(event: Event) { + let count = 0; + for (let group of event.groups) { + let numTeams = group.teams.length; + let rounds = Math.trunc(Math.log2(numTeams)); + let matchesPerRound = Math.trunc(numTeams / 2); + count += (rounds * matchesPerRound); + } + return count; + } + + getTournamentMatchCount(tournament: Tournament) { + let count = 0; + for (let event of tournament.events) { + count += this.getEventMatchCount(event); + } + return count; + } } class ActiveMatch { diff --git a/src/app/components/tournament-validate/tournament-validate.component.html b/src/app/components/tournament-validate/tournament-validate.component.html index af4f28c..717ff42 100644 --- a/src/app/components/tournament-validate/tournament-validate.component.html +++ b/src/app/components/tournament-validate/tournament-validate.component.html @@ -59,7 +59,12 @@
  • {{ getIconForSeverity(validation.severity) }} - {{ validation.message }} + +
diff --git a/src/app/components/tournament-validate/tournament-validate.component.ts b/src/app/components/tournament-validate/tournament-validate.component.ts index e290e96..00953b6 100644 --- a/src/app/components/tournament-validate/tournament-validate.component.ts +++ b/src/app/components/tournament-validate/tournament-validate.component.ts @@ -15,6 +15,8 @@ import {Player} from "../../model/player"; import {EventValidation, TournamentValidation, Validation} from "../../model/tournamentValidation"; import {MatIcon} from "@angular/material/icon"; import {FullNamePipe} from "../../pipes/fullname-pipe"; +import {PlayerService} from "../../service/player.service"; +import {PlayerLinkComponent} from "../player-link/player-link.component"; @Component({ selector: 'app-tournament-validate', @@ -31,7 +33,8 @@ import {FullNamePipe} from "../../pipes/fullname-pipe"; MatAccordion, AsyncPipe, MatIcon, - FullNamePipe + FullNamePipe, + PlayerLinkComponent ], templateUrl: './tournament-validate.component.html', styleUrl: './tournament-validate.component.scss' @@ -39,6 +42,7 @@ import {FullNamePipe} from "../../pipes/fullname-pipe"; export class TournamentValidateComponent implements OnInit { tournament: Tournament; tournamentValidation: TournamentValidation; + players: Player[]; protected readonly TournamentEvent = Event; protected readonly Player = Player; @@ -46,8 +50,9 @@ export class TournamentValidateComponent implements OnInit { constructor( private tournamentService: TournamentService, + private playerService: PlayerService, private route: ActivatedRoute, - private router: Router + private router: Router, ) {} ngOnInit() { @@ -58,6 +63,9 @@ export class TournamentValidateComponent implements OnInit { this.tournamentService.getValidation(Number(id)).subscribe(data => { this.tournamentValidation = data; }); + this.playerService.getAll().subscribe(data => { + this.players = data; + }); } getEventValidation(id: number): EventValidation | null {