Added match counter
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good

This commit is contained in:
2025-08-18 23:28:15 +02:00
parent 71e5b5c912
commit 5a5c134002
22 changed files with 484 additions and 2070 deletions

View File

@@ -1,10 +1,5 @@
@if (tournament) {
<mat-card appearance="outlined">
<!--
<mat-card-header>
<h5>{{ tournament.name }}</h5>
</mat-card-header>
-->
<mat-card-content>
<mat-tab-group animationDuration="0ms" disableRipple="true">
@@ -108,56 +103,43 @@
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>play_arrow</mat-icon>
&nbsp;Actieve wedstrijden
&nbsp;
&nbsp;Actieve wedstrijden&nbsp;&nbsp;
@if (this.activeMatches().length > 0) {
<span class="badge text-bg-success">{{ this.activeMatches().length }}</span>
}
</ng-template>
@if (this.activeMatches().length > 0) {
<table class="table table-hover w-100 m-4">
<thead>
<tr>
<th colspan="3">Wedstrijd</th>
<th>Onderdeel/Ronde</th>
<th>Start</th>
<th>Baan</th>
<th></th>
</tr>
</thead>
<tbody>
@for (activeMatch of this.activeMatches(); track activeMatch.match.id) {
<tr>
<td class="align-middle">{{ activeMatch.match.team1 | teamText }}</td>
<td class="align-middle">-</td>
<td class="align-middle">{{ activeMatch.match.team2 | teamText }}</td>
<td class="align-middle">{{ activeMatch.group.name }} {{ activeMatch.round.name }}</td>
<td class="align-middle">{{ activeMatch.match.startTime | date: 'HH:mm' }}</td>
<td class="align-middle">{{ activeMatch.match.court }}</td>
<td nowrap class="align-middle">
<button class="align-baseline" mat-button (click)="editResult(activeMatch.match, activeMatch.group, activeMatch.round)">
<mat-icon>edit</mat-icon>
Uitslag invoeren
</button>
<button mat-icon-button [matMenuTriggerFor]="activeMatchMenu" [matMenuTriggerData]="{ match: activeMatch.match }" class="menu-button">
<mat-icon>more_vert</mat-icon>
</button>
</td>
</tr>
}
</tbody>
</table>
<mat-menu #activeMatchMenu="matMenu">
<ng-template matMenuContent let-match="match">
<button mat-button (click)="stopMatch(match)">
<mat-icon>stop</mat-icon>
Wedstrijd stoppen
</button>
</ng-template>
</mat-menu>
<h6 class="mt-3">Actieve wedstrijden</h6>
@for (activeMatch of this.activeMatches(); track activeMatch.match.id) {
<mat-expansion-panel>
<mat-expansion-panel-header>
<div class="col-md-2">Baan {{ activeMatch.match.court }}</div>
<div class="col-md-3">{{ activeMatch.match.team1 | teamText }}</div>
<div class="col-md-1">-</div>
<div class="col-md-3">{{ activeMatch.match.team2 | teamText }}</div>
<div class="col-md-3">{{ activeMatch.group.name }} {{ activeMatch.round.name }}</div>
</mat-expansion-panel-header>
<div class="row">
<div class="col-md-3">Teller: {{ activeMatch.match.counter | fullName }}</div>
<div class="col-md-5"></div>
<div class="col-md-2">Starttijd: {{ activeMatch.match.startTime | date: 'HH:mm' }}</div>
<div class="col-md-2">Duur: {{ getDuration(activeMatch.match.startTime) | date: 'mm:ss' }}</div>
</div>
<mat-action-row>
<button class="align-baseline" mat-button (click)="editResult(activeMatch.match, activeMatch.group, activeMatch.round)">
<mat-icon>edit</mat-icon>
Uitslag invoeren
</button>
<button mat-button (click)="stopMatch(activeMatch.match)">
<mat-icon>stop</mat-icon>
Wedstrijd stoppen
</button>
</mat-action-row>
</mat-expansion-panel>
<br>
}
} @else {
<h6 class="mt-3">Geen actieve wedstrijden</h6>
}
@@ -223,11 +205,11 @@
<mat-icon>play_arrow</mat-icon>
Ronde starten
</button>
<button mat-menu-item (click)="printMatchSheets(round)">
<mat-icon>print</mat-icon>
Wedstrijdbriefjes printen
</button>
}
<button mat-menu-item (click)="printMatchSheets(round)">
<mat-icon>print</mat-icon>
Wedstrijdbriefjes printen
</button>
<button mat-menu-item (click)="printRoundOverview(round)">
<mat-icon>print</mat-icon>
Rondeoverzicht printen
@@ -402,8 +384,7 @@
}
</mat-tab-group>
</mat-tab>
}
@if (tournament.status == 'ONGOING' || tournament.status == 'DRAWN') {
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>settings</mat-icon>

View File

@@ -24,3 +24,11 @@ td.w-sep {
td.w-fill {
width: 35%;
}
.w-90 {
width: 90% !important;
}
.material-tooltip {
white-space: pre-line;
}

View File

@@ -1,7 +1,7 @@
import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core';
import {
MatAccordion,
MatExpansionPanel,
MatExpansionPanel, MatExpansionPanelActionRow,
MatExpansionPanelHeader,
MatExpansionPanelTitle
} from "@angular/material/expansion";
@@ -25,13 +25,15 @@ import {MatDialog} from "@angular/material/dialog";
import {MatchResultPipe} from "../../pipes/match-result-pipe";
import {Event} from "../../model/event";
import {TournamentValidateComponent} from "../tournament-validate/tournament-validate.component";
import {Strength} from "../../model/player";
import {Player, Strength} from "../../model/player";
import {MatSlideToggleChange} from "@angular/material/slide-toggle";
import {MatSnackBar} from "@angular/material/snack-bar";
import {CourtSelectionComponent} from "../court-selection/court-selection.component";
import {Standings} from "../../model/standings";
import {HeaderService} from "../../service/header.service";
import {TournamentPlayersComponent} from "../tournament-players/tournament-players.component";
import {TournamentPlayer} from "../../model/tournamentPlayer";
import {MatTooltip} from "@angular/material/tooltip";
@Component({
selector: 'app-tournament-manage',
@@ -60,7 +62,8 @@ import {TournamentPlayersComponent} from "../tournament-players/tournament-playe
DecimalPipe,
TournamentValidateComponent,
MatMenuContent,
TournamentPlayersComponent
TournamentPlayersComponent,
MatExpansionPanelActionRow,
],
providers: [
FullNamePipe,
@@ -102,6 +105,16 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
this.headerService.clearTitle();
}
getDuration(startTime: string | Date): Date {
const start = new Date(startTime);
const now = new Date();
const diffInMs = now.getTime() - start.getTime();
// Convert milliseconds to a Date object starting from epoch
// This allows the date pipe to format it as mm:ss
return new Date(diffInMs);
}
onRoundTabChange(event: MatTabChangeEvent) {
const index = event.index;
this.router.navigate(
@@ -152,6 +165,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
this.tournament = data;
});
}
reopenGroup(group: Group) {
this.tournamentService.reopenGroup(this.tournament.id, group.id).subscribe(data => {
this.tournament = data;
@@ -183,20 +197,24 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
alert('Geen banen beschikbaar!');
} else if (this.matchContainsPlayersThatArePlaying(match)) {
alert('Deze wedstrijd bevat spelers die al aan het spelen zijn!');
} else if (this.matchContainsPlayersThatAreCounting(match)) {
alert('Deze wedstrijd bevat spelers die aan het tellen zijn!');
} else {
this.courtSelectionDialog.open(CourtSelectionComponent, {
data: {
match: match,
availableCourts: this.getAvailableCourts(),
totalCourts: this.tournament.courts
totalCourts: this.tournament.courts,
availableCounters: this.getAvailableCounters()
},
minWidth: '800px',
minHeight: '250px'
}).afterClosed().subscribe(result => {
if (result != undefined) {
this.tournamentService.startMatch(this.tournament.id, match.id, result).subscribe(data => {
console.log('Start match on court ' + result.court + ' with counter ' + result.counter.name);
this.tournamentService.startMatch(this.tournament.id, match.id, result.court, result.counter.playerId).subscribe(data => {
this.tournament = data;
})
});
}
});
}
@@ -219,6 +237,22 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
return playersThatArePlaying.length > 0;
}
matchContainsPlayersThatAreCounting(match: Match): boolean {
let currentCounters: number[] = [];
for (let activeMatch of this.activeMatches()) {
currentCounters.push(activeMatch.match.counter.id);
}
let matchPlayers: number[] = [];
matchPlayers.push(match.team1.player1.id);
if (match.team1.player2) matchPlayers.push(match.team1.player2.id);
matchPlayers.push(match.team2.player1.id);
if (match.team2.player2) matchPlayers.push(match.team2.player2.id);
let playersThatAreCounting = currentCounters.filter(Set.prototype.has, new Set(matchPlayers));
return playersThatAreCounting.length > 0;
}
getAvailableCourts(): number[] {
const maxCourts = this.tournament.courts;
const activeCourts = this.activeMatches().map(activeMatch => activeMatch.match.court);
@@ -229,6 +263,21 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
return courts.filter(court => activeCourts.indexOf(court) < 0);
}
getAvailableCounters(): TournamentPlayer[] {
const activePlayerIds = new Set(
this.activeMatches().flatMap(activeMatch => [
activeMatch.match.team1.player1.id,
activeMatch.match.team1.player2?.id,
activeMatch.match.team2.player1.id,
activeMatch.match.team2.player2?.id
].filter(id => id !== undefined))
);
return this.tournament.tournamentPlayers.filter(
player => !player.counting && !activePlayerIds.has(player.playerId)
);
}
stopMatch(match: Match) {
this.tournamentService.stopMatch(this.tournament.id, match.id).subscribe(data => {
this.tournament = data;
@@ -241,18 +290,6 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
})
}
playerPaid($event: MatSlideToggleChange, playerId: number) {
this.tournamentService.playerPaid(this.tournament.id, playerId, $event.checked).subscribe(() => {
this._snackBar.open('Opgeslagen.');
});
}
playerPresent($event: MatSlideToggleChange, playerId: number) {
this.tournamentService.playerPresent(this.tournament.id, playerId, $event.checked).subscribe(() => {
this._snackBar.open('Opgeslagen.');
});
}
getStrength(strength: string | undefined) {
if (strength == undefined) return "";
for (let [key, value] of Object.entries(Strength)) {