Compare commits

...

6 Commits

Author SHA1 Message Date
87d9291bfb Use substitutions for disable button test
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good
2025-11-06 23:19:00 +01:00
c646ae15ee Optionally disable starting a match and show reason
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good
2025-11-06 23:00:00 +01:00
Michel ten Voorde
8128ba4744 Cleanup
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good
2025-11-06 16:42:48 +01:00
Michel ten Voorde
19e4372006 Show substitutions in standings 2025-11-06 16:42:22 +01:00
Michel ten Voorde
7fd84005f9 Show 100 players by default 2025-11-06 16:41:03 +01:00
Michel ten Voorde
a56317fecd Update counter 2025-11-06 16:40:20 +01:00
13 changed files with 269 additions and 63 deletions

View File

@@ -0,0 +1,22 @@
<mat-dialog-content>
<h3>Kies een teller:</h3>
<div class="col-md-6">
<mat-form-field appearance="fill">
<mat-label>Teller</mat-label>
<mat-select [(ngModel)]="counter">
<mat-option>Geen</mat-option>
@for (player of data.availableCounters; track player.playerId) {
<mat-option [value]="player">
{{ player.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
</div>
</mat-dialog-content>
<mat-dialog-actions>
@if (counter) {
<button mat-button [mat-dialog-close]="{counter: counter}">Opslaan</button>
}
<button mat-button (click)="onAnnulerenClick()">Annuleren</button>
</mat-dialog-actions>

View File

@@ -0,0 +1,4 @@
button:disabled {
cursor: not-allowed;
pointer-events: all !important;
}

View File

@@ -0,0 +1,49 @@
import {Component, inject, Inject} from '@angular/core';
import {
MAT_DIALOG_DATA,
MatDialogActions,
MatDialogClose,
MatDialogContent,
MatDialogRef
} from "@angular/material/dialog";
import {Match} from "../../model/match";
import {MatButton} from "@angular/material/button";
import {TournamentPlayer} from "../../model/tournamentPlayer";
import {MatFormField, MatLabel} from "@angular/material/form-field";
import {MatOption, MatSelect} from "@angular/material/select";
import {FormsModule} from "@angular/forms";
@Component({
selector: 'app-counter-selection',
imports: [
MatDialogContent,
MatButton,
MatDialogClose,
MatDialogActions,
MatFormField,
MatLabel,
MatOption,
MatSelect,
FormsModule,
],
templateUrl: './counter-selection.component.html',
standalone: true,
styleUrl: './counter-selection.component.scss'
})
export class CounterSelectionComponent {
counter: TournamentPlayer;
readonly dialogRef = inject(MatDialogRef<CounterSelectionComponent>);
constructor(@Inject(MAT_DIALOG_DATA) public data: {
match: Match,
availableCounters: TournamentPlayer[]
}) {}
onAnnulerenClick() {
this.dialogRef.close();
}
}

View File

@@ -12,15 +12,24 @@ import {MatTooltip} from '@angular/material/tooltip';
styleUrls: ['./player-display.component.scss'],
template: `
@let substitute = getSubstituteForEvent(player, event);
<span [class.has-substitute]="substitute"
[matTooltip]="substitute ? 'Valt in voor ' + (player | fullName) : ''"
matTooltipPosition="below">{{ substitute || (player | fullName) }}</span>
@if (exlicitSubstitute) {
@if (substitute) {
{{ substitute }} (valt in voor {{ player | fullName }})
} @else {
{{ player | fullName }}
}
} @else {
<span [class.has-substitute]="substitute"
[matTooltip]="substitute ? 'Valt in voor ' + (player | fullName) : ''"
matTooltipPosition="below">{{ substitute || (player | fullName) }}</span>
}
`
})
export class PlayerDisplayComponent {
@Input({ required: true }) player!: Player;
@Input({ required: true }) event!: Event;
@Input({ required: true }) tournament!: Tournament;
@Input({ required: false }) exlicitSubstitute: boolean = false;
getSubstituteForEvent(player: Player, event: Event): string | undefined {
const tournamentPlayer = this.tournament.tournamentPlayers.find(

View File

@@ -39,7 +39,8 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 20, 50]"
<mat-paginator [pageSizeOptions]="[10, 25, 100]"
[pageSize]="100"
showFirstLastButtons
aria-label="Select page of periodic elements">
</mat-paginator>

View File

@@ -5,3 +5,7 @@ a {
td, th {
background-color: transparent !important;
}
.mat-mdc-row:hover {
background-color: rgba(0, 0, 0, 0.075);
}

View File

@@ -108,7 +108,8 @@
[team]="entry.team"
[event]="this.event"
[tournament]="this.tournament"
[inline]="true">
[inline]="true"
[explicitSubstitute]="true">
</app-team-display>
</td>
<td class="align-middle">{{ entry.played }}</td>

View File

@@ -12,7 +12,8 @@ import {Team} from "../../model/team";
<app-player-display
[player]="team.player1"
[event]="event"
[tournament]="tournament">
[tournament]="tournament"
[exlicitSubstitute]="explicitSubstitute">
</app-player-display>
@if (event.doublesEvent && team.player2) {
@@ -34,4 +35,5 @@ export class TeamDisplayComponent {
@Input({ required: true }) event!: Event;
@Input({ required: true }) tournament!: Tournament;
@Input({ required: false }) inline: boolean = true;
@Input({ required: false }) explicitSubstitute: boolean = false;
}

View File

@@ -158,9 +158,13 @@
</div>
<mat-action-row>
<button class="align-baseline" mat-button (click)="editResult(activeMatch.match, activeMatch.event, activeMatch.group, activeMatch.round)">
<mat-icon>edit</mat-icon>
<mat-icon>leaderboard</mat-icon>
Uitslag invoeren
</button>
<button mat-button (click)="changeCounter(activeMatch.match)">
<mat-icon>person</mat-icon>
Teller wijzigen
</button>
<button mat-button (click)="stopMatch(activeMatch.match)">
<mat-icon>stop</mat-icon>
Wedstrijd stoppen
@@ -297,7 +301,6 @@
}
</tbody>
</table>
<!-- }-->
} @else if (round.status == 'IN_PROGRESS') {
<table class="table table-hover m-4 wide w-95">
<tbody>
@@ -320,18 +323,31 @@
</td>
<td class="align-middle w-fill">
@if (match.status == 'NOT_STARTED') {
<button mat-button (click)="startMatch(match)">
<mat-icon>play_arrow</mat-icon>
Wedstrijd starten
</button>
@if (match.canStart) {
<button mat-button (click)="startMatch(match)">
<mat-icon>play_arrow</mat-icon>
Wedstrijd starten
</button>
} @else {
<span [matTooltip]="match.cantStartReason" style="cursor: not-allowed;">
<button mat-button disabled>
<mat-icon>play_arrow</mat-icon>
Wedstrijd starten
</button>
</span>
}
} @else if (match.status == 'IN_PROGRESS') {
<button mat-button (click)="editResult(match, event, group, round)">
<mat-icon>edit</mat-icon>
Uitslag invoeren
<mat-icon>leaderboard</mat-icon>
Uitslag
</button>
<button mat-button (click)="changeCounter(match)">
<mat-icon>person</mat-icon>
Teller
</button>
<button mat-button (click)="stopMatch(match)">
<mat-icon>stop</mat-icon>
Wedstrijd stoppen
Stoppen
</button>
} @else if (match.status == 'FINISHED') {
<div class="row result align-items-center">
@@ -347,7 +363,7 @@
</button>
<mat-menu #finishedMatchMenu="matMenu">
<button mat-menu-item (click)="editResult(match, event, group, round)">
<mat-icon>edit</mat-icon>
<mat-icon>leaderboard</mat-icon>
Uitslag bewerken
</button>
</mat-menu>
@@ -429,7 +445,14 @@
@for (entry of getStandingsForRound(round, group).entries; track entry.position) {
<tr>
<td class="align-middle">{{ entry.position }}</td>
<td class="align-middle">{{ entry.team | teamText }}</td>
<td class="align-middle">
<app-team-display
[team]="entry.team"
[event]="event"
[tournament]="this.tournament"
[inline]="true">
</app-team-display>
</td>
<td class="align-middle">{{ entry.played }}</td>
<td class="align-middle">
@if (entry.played > 0 ) {

View File

@@ -33,8 +33,10 @@ 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";
import {TeamDisplayComponent} from "../team-display/team-display.component";
import {CounterSelectionComponent} from "../counter-selection/counter-selection.component";
import {Observable, Subscription, tap} from "rxjs";
import {MatTooltip} from '@angular/material/tooltip';
@Component({
selector: 'app-tournament-manage',
@@ -65,6 +67,7 @@ import {TeamDisplayComponent} from "../team-display/team-display.component";
TournamentPlayersComponent,
MatExpansionPanelActionRow,
TeamDisplayComponent,
MatTooltip,
],
providers: [
FullNamePipe,
@@ -97,10 +100,10 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
this.activeRoundTab = params['tab'];
}
})
this.tournamentService.getById(Number(id)).subscribe(data => {
this.tournament = data;
this.headerService.setTitle(this.tournament.name);
});
this.loadTournament(
this.tournamentService.getById(Number(id)),
(tournament) => this.headerService.setTitle(tournament.name)
);
}
ngOnDestroy() {
@@ -151,45 +154,31 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
}
startRound(round: Round) {
this.tournamentService.startRound(this.tournament.id, round.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.startRound(this.tournament.id, round.id));
}
finishRound(round: Round) {
this.tournamentService.finishRound(this.tournament.id, round.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.finishRound(this.tournament.id, round.id));
}
finishGroup(group: Group) {
this.tournamentService.finishGroup(this.tournament.id, group.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.finishGroup(this.tournament.id, group.id));
}
reopenGroup(group: Group) {
this.tournamentService.reopenGroup(this.tournament.id, group.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.reopenGroup(this.tournament.id, group.id));
}
divideTournament() {
this.tournamentService.divide(this.tournament.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.divide(this.tournament.id));
}
clearDivision() {
this.tournamentService.clearDivision(this.tournament.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.clearDivision(this.tournament.id));
}
drawTournament() {
this.tournamentService.draw(this.tournament.id).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.draw(this.tournament.id));
}
startMatch(match: Match) {
@@ -213,9 +202,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
minHeight: '250px'
}).afterClosed().subscribe(result => {
if (result != undefined) {
this.tournamentService.startMatch(this.tournament.id, match.id, result.court, result.counter.playerId).subscribe(data => {
this.tournament = data;
});
this.loadTournament(this.tournamentService.startMatch(this.tournament.id, match.id, result.court, result.counter.playerId));
}
});
}
@@ -223,26 +210,48 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
matchContainsPlayersThatArePlaying(match: Match): boolean {
let matchPlayers: number[] = [];
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
let matchPlayersThatArePlaying = this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
return matchPlayersThatArePlaying.length > 0;
}
matchPlayersThatArePlaying(match: Match): number[] {
let matchPlayers: number[] = [];
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
return this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
}
matchContainsPlayersThatAreCounting(match: Match): boolean {
let matchPlayers: number[] = [];
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
let matchPlayersThatAreCounting = this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
return matchPlayersThatAreCounting.length > 0;
}
matchPlayersThatAreCounting(match: Match): number[] {
let matchPlayers: number[] = [];
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
return this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
}
getTournamentPlayerFromPlayer(player: Player): TournamentPlayer {
for (let tournamentPlayer of this.tournament.tournamentPlayers) {
if (tournamentPlayer.playerId == player.id) {
@@ -302,15 +311,11 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
}
stopMatch(match: Match) {
this.tournamentService.stopMatch(this.tournament.id, match.id).subscribe(data => {
this.tournament = data;
})
this.loadTournament(this.tournamentService.stopMatch(this.tournament.id, match.id));
}
newRound(group: Group) {
this.tournamentService.newRound(this.tournament.id, group.id).subscribe(data => {
this.tournament = data;
})
this.loadTournament(this.tournamentService.newRound(this.tournament.id, group.id));
}
getStrength(strength: string | undefined) {
@@ -367,6 +372,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
matchResultDialog = inject(MatDialog);
courtSelectionDialog = inject(MatDialog);
counterSelectionDialog = inject(MatDialog);
editResult(match: Match, event: Event, group: Group, round: Round) {
this.matchResultDialog.open(MatchResultComponent, {
@@ -374,9 +380,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
minWidth: '800px'
}).afterClosed().subscribe(result => {
if (result != undefined) {
this.tournamentService.saveResult(this.tournament.id, result.matchId, result).subscribe(data => {
this.tournament = data;
})
this.loadTournament(this.tournamentService.saveResult(this.tournament.id, result.matchId, result));
}
});
}
@@ -427,6 +431,84 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
return count;
}
changeCounter(match: Match) {
this.counterSelectionDialog.open(CounterSelectionComponent, {
data: {
match: match,
availableCounters: this.getAvailableCounters(match)
},
minWidth: '800px',
minHeight: '250px'
}).afterClosed().subscribe(result => {
if (result != undefined) {
this.loadTournament(this.tournamentService.updateCounter(this.tournament.id, match.id, result.counter.playerId));
}
});
}
private loadTournament(
observable: Observable<Tournament>,
afterLoad?: (tournament: Tournament) => void
): Subscription {
return observable.subscribe(data => {
this.tournament = data;
this.updateMatchAvailability();
afterLoad?.(data); // Optional chaining
});
}
private updateMatchAvailability() {
for (const event of this.tournament.events) {
for (const group of event.groups) {
for (const round of group.rounds) {
for (const match of round.matches) {
let canStart = true;
let matchPlayersThatArePlaying = this.matchPlayersThatArePlaying(match);
let matchPlayersThatAreCounting = this.matchPlayersThatAreCounting(match);
let cantStartReason = "";
if (matchPlayersThatArePlaying.length > 0) {
canStart = false;
cantStartReason = this.joinWithEn(matchPlayersThatArePlaying.map(m => this.getTournamentPlayerFromId(m).name));
if (matchPlayersThatArePlaying.length == 1) {
cantStartReason += " is al aan het spelen";
} else {
cantStartReason += " zijn al aan het spelen";
}
}
if (matchPlayersThatAreCounting.length > 0) {
canStart = false;
if (cantStartReason.length > 0) {
cantStartReason += " en ";
}
cantStartReason += this.joinWithEn(matchPlayersThatAreCounting.map(m => this.getTournamentPlayerFromId(m).name));
if (matchPlayersThatAreCounting.length == 1) {
cantStartReason += " is aan het tellen";
} else {
cantStartReason += " zijn aan het tellen";
}
}
match.canStart = canStart;
match.cantStartReason = cantStartReason;
}
}
}
}
}
joinWithEn(items: string[], separator = ", "): string {
const len = items.length;
if (len === 0) return "";
if (len === 1) return items[0];
if (len === 2) return items.join(" en ");
return items.slice(0, -1).join(separator) + `${separator}and ${items[len - 1]}`;
}
}
class ActiveMatch {

View File

@@ -13,4 +13,6 @@ export class Match {
games: Game[];
court: number;
counter: Player;
canStart?: boolean;
cantStartReason?: string;
}

View File

@@ -97,6 +97,10 @@ export class TournamentService {
return this.http.post<Tournament>(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitutions`, substitutions)
}
public updateCounter(tournamentId: number, matchId: number, counter: number): Observable<Tournament> {
return this.http.patch<Tournament>(`${this.tournamentsUrl}/${tournamentId}/matches/${matchId}/update?counter=${counter}`, null);
}
public addTestData(): Observable<void> {
return this.http.get<void>(`${environment.backendUrl}/testdata`);
}

View File

@@ -7,3 +7,6 @@ body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
z-index: 2000 !important;
}
*/
.mat-tooltip {
white-space: pre-line !important;
}