Compare commits

...

2 Commits

Author SHA1 Message Date
TeamCity 8603222ab4 ci: bump version to v0.6.4 2026-06-28 17:49:20 +00:00
lq64 76e0e3db78 fix: show actual bot names on watch page instead of Black/White fallbacks (#15)
The gameState stream event does not carry player names, so snapshot.white/black
were always undefined and the UI fell back to the literal strings "Black" and
"White". Fix by fetching the full game object (GET /api/tournament/{id}/game/{gameId})
on page load, which includes BotRef with real names, and storing them in
dedicated whiteName/blackName fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #15
2026-06-28 19:43:26 +02:00
5 changed files with 35 additions and 7 deletions
+5
View File
@@ -113,3 +113,8 @@
### Bug Fixes
* route tournament calls through backend gateway ([890c3fc](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/890c3fcecccec89e643180725e2a601f84fa5d99))
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.6.3...0.0.0) (2026-06-28)
### Bug Fixes
* show actual bot names on watch page instead of Black/White fallbacks ([#15](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/15)) ([76e0e3d](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/76e0e3db7869609e400593ca8f08ea8f72e72f68))
@@ -2,10 +2,10 @@
<header class="watch-head">
<a class="back-link" routerLink="/tournaments">← Tournaments</a>
<div class="watch-title">
@if (snapshot?.white && snapshot?.black) {
<span class="player">{{ snapshot!.white!.name }}</span>
@if (whiteName && blackName) {
<span class="player">{{ whiteName }}</span>
<span class="vs">vs</span>
<span class="player">{{ snapshot!.black!.name }}</span>
<span class="player">{{ blackName }}</span>
@if (snapshot?.round) {
<span class="round-tag">Round {{ snapshot!.round }}</span>
}
@@ -24,12 +24,12 @@
<div class="watch-layout">
<div class="board-wrap">
<div class="clock clock-top" [class.active]="status === 'ongoing' && turn === 'black'">
<span class="clock-label">{{ snapshot?.black?.name ?? 'Black' }}</span>
<span class="clock-label">{{ blackName ?? 'Black' }}</span>
<span class="clock-time">{{ formatTime(clock?.blackTime) }}</span>
</div>
<app-chess-board [fen]="fen"></app-chess-board>
<div class="clock clock-bot" [class.active]="status === 'ongoing' && turn === 'white'">
<span class="clock-label">{{ snapshot?.white?.name ?? 'White' }}</span>
<span class="clock-label">{{ whiteName ?? 'White' }}</span>
<span class="clock-time">{{ formatTime(clock?.whiteTime) }}</span>
</div>
</div>
@@ -1,6 +1,7 @@
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { from } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ChessBoardComponent } from '../../components/chess-board/chess-board.component';
import { TournamentStreamService } from '../../services/tournament-stream.service';
@@ -25,6 +26,9 @@ export class TournamentWatchComponent implements OnInit {
gameId = '';
serverUrl = '';
whiteName: string | null = null;
blackName: string | null = null;
fen = INITIAL_FEN;
turn: 'white' | 'black' = 'white';
status: GameStatus = 'pending';
@@ -51,6 +55,15 @@ export class TournamentWatchComponent implements OnInit {
return;
}
from(this.stream.fetchGame(this.serverUrl, this.tournamentId, this.gameId))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: game => {
this.whiteName = game.white?.name ?? null;
this.blackName = game.black?.name ?? null;
},
});
this.stream.streamGame(this.serverUrl, this.tournamentId, this.gameId)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
+11 -1
View File
@@ -1,6 +1,6 @@
import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { GameStreamEvent, TournamentStreamEvent } from '../models/tournament.models';
import { GameStateSnapshot, GameStreamEvent, TournamentStreamEvent } from '../models/tournament.models';
import { TournamentAuthService } from './tournament-auth.service';
@Injectable({ providedIn: 'root' })
@@ -21,6 +21,16 @@ export class TournamentStreamService {
);
}
async fetchGame(serverUrl: string, tournamentId: string, gameId: string): Promise<GameStateSnapshot> {
const base = serverUrl.replace(/\/+$/, '');
const token = await this.auth.getToken(serverUrl);
const res = await fetch(`${base}/api/tournament/${tournamentId}/game/${gameId}`, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) throw new Error(`Game fetch failed: ${res.status}`);
return res.json() as Promise<GameStateSnapshot>;
}
private fullUrl(base: string, path: string): string {
if (!base) return path;
return `${base.replace(/\/+$/, '')}${path}`;
+1 -1
View File
@@ -1,3 +1,3 @@
MAJOR=0
MINOR=6
PATCH=3
PATCH=4