Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| efb129c323 | |||
| 828c2a03c1 | |||
| 8603222ab4 | |||
| 76e0e3db78 | |||
| 0ac61032bd | |||
| 890c3fcecc |
@@ -108,3 +108,18 @@
|
||||
### Bug Fixes
|
||||
|
||||
* jwt token issue ([147d7f0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/147d7f0d2ca7a77bb80eb4b73b8d60b00ad2f708))
|
||||
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.6.2...0.0.0) (2026-06-23)
|
||||
|
||||
### 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))
|
||||
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.6.4...0.0.0) (2026-06-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* show finished games on watch page instead of hanging spinner ([#16](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/16)) ([828c2a0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/828c2a03c18c74d191d7181cfa70c824c2beca67))
|
||||
|
||||
Generated
+24
-3
@@ -458,6 +458,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@angular/common/-/common-20.3.19.tgz",
|
||||
"integrity": "sha512-hcB1eUEN8LGcKGc4DlRJ+abS6AYfbEHDZKg8LnXNugkbwI6Ebyh2AUYTDhzZL2S4aH+C8biHKgSYHFCqieCRhA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
@@ -474,6 +475,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-20.3.19.tgz",
|
||||
"integrity": "sha512-ETkgDKm0l2PuaBubgPJe0ccy8kE75DFu6/zKcz7TUuk3KrKF2OZAopbbjftsUSZGeCNvCdqHzjmcL6hQ6oAOwA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
@@ -487,6 +489,7 @@
|
||||
"integrity": "sha512-ET/JjO8s62kAHfgIsGXlvW5VUwLqHm03q1y/2yD7aQW/WdDvssMsvZv7Knl440989vdOFemIGTMwVPakmWqRmA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/core": "7.28.3",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
||||
@@ -519,6 +522,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@angular/core/-/core-20.3.19.tgz",
|
||||
"integrity": "sha512-SYnwW+q51bQoPtGFoGovm1P5GK9fMEXsG0lGaEAUapjskblAYyX7hLlM/jgueSojv2SjhqNF8aXR+gjHLhZVNA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
@@ -562,6 +566,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.19.tgz",
|
||||
"integrity": "sha512-TRZfatH1B/kreDwFRwtpLEurJQ6044qh6DWpvxzTbugaG5otLQJKTk+1z81/KsJwQqc1+24v+yuywc1LM7aq7w==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
@@ -628,6 +633,7 @@
|
||||
"integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "^2.2.0",
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
@@ -1601,6 +1607,7 @@
|
||||
"integrity": "sha512-nqhDw2ZcAUrKNPwhjinJny903bRhI0rQhiDz1LksjeRxqa36i3l75+4iXbOy0rlDpLJGxqtgoPavQjmmyS5UJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@inquirer/checkbox": "^4.2.1",
|
||||
"@inquirer/confirm": "^5.1.14",
|
||||
@@ -3531,6 +3538,7 @@
|
||||
"integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~7.19.0"
|
||||
}
|
||||
@@ -3887,6 +3895,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.10.12",
|
||||
"caniuse-lite": "^1.0.30001782",
|
||||
@@ -4902,6 +4911,7 @@
|
||||
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"accepts": "^2.0.0",
|
||||
"body-parser": "^2.2.1",
|
||||
@@ -5343,6 +5353,7 @@
|
||||
"integrity": "sha512-am5zfg3yu6sqn5yjKBNqhnTX7Cv+m00ox+7jbaKkrLMRJ4rAdldd1xPd/JzbBWspqaQv6RSTrgFN95EsfhC+7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
@@ -5839,7 +5850,8 @@
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-5.9.0.tgz",
|
||||
"integrity": "sha512-OMUvF1iI6+gSRYOhMrH4QYothVLN9C3EJ6wm4g7zLJlnaTl8zbaPOr0bTw70l7QxkoM7sVFOWo83u9B2Fe2Zng==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/jose": {
|
||||
"version": "6.2.2",
|
||||
@@ -5941,6 +5953,7 @@
|
||||
"integrity": "sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@colors/colors": "1.5.0",
|
||||
"body-parser": "^1.19.0",
|
||||
@@ -6408,6 +6421,7 @@
|
||||
"integrity": "sha512-SL0JY3DaxylDuo/MecFeiC+7pedM0zia33zl0vcjgwcq1q1FWWF1To9EIauPbl8GbMCU0R2e0uJ8bZunhYKD2g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"cli-truncate": "^4.0.0",
|
||||
"colorette": "^2.0.20",
|
||||
@@ -7920,6 +7934,7 @@
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
|
||||
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
@@ -7955,6 +7970,7 @@
|
||||
"integrity": "sha512-9GUyuksjw70uNpb1MTYWsH9MQHOHY6kwfnkafC24+7aOMZn9+rVMBxRbLvw756mrBFbIsFg6Xw9IkR2Fnn3k+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"chokidar": "^4.0.0",
|
||||
"immutable": "^5.0.2",
|
||||
@@ -8574,7 +8590,8 @@
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
"license": "0BSD",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tuf-js": {
|
||||
"version": "4.1.0",
|
||||
@@ -8612,6 +8629,7 @@
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -8741,6 +8759,7 @@
|
||||
"integrity": "sha512-Bby3NOsna2jsjfLVOHKes8sGwgl4TT0E6vvpYgnAYDIF/tie7MRaFthmKuHx1NSXjiTueXH3do80FMQgvEktRg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.27.0",
|
||||
"fdir": "^6.5.0",
|
||||
@@ -9538,6 +9557,7 @@
|
||||
"integrity": "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
@@ -9556,7 +9576,8 @@
|
||||
"version": "0.15.1",
|
||||
"resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.1.tgz",
|
||||
"integrity": "sha512-XE96n56IQpJM7NAoXswY3XRLcWFW83xe0BiAOeMD7K5k5xecOeul3Qcpx6GqEeeHNkW5DWL5zOyTbEfB4eti8w==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,14 +55,47 @@ export class TournamentWatchComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
from(this.stream.fetchGame(this.serverUrl, this.tournamentId, this.gameId))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: game => {
|
||||
this.applySnapshot(game);
|
||||
this.connecting = false;
|
||||
if (!this.isFinished(game.status)) {
|
||||
this.subscribeToStream();
|
||||
}
|
||||
},
|
||||
error: err => {
|
||||
this.connecting = false;
|
||||
this.error = (err as Error).message ?? 'Failed to load game.';
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private applySnapshot(game: GameStateSnapshot): void {
|
||||
this.whiteName = game.white?.name ?? null;
|
||||
this.blackName = game.black?.name ?? null;
|
||||
this.snapshot = game;
|
||||
this.fen = game.fen;
|
||||
this.turn = game.turn;
|
||||
this.status = game.status;
|
||||
this.winner = game.winner;
|
||||
this.clock = game.clock ?? null;
|
||||
this.moves = game.moves ? game.moves.split(/\s+/).filter(Boolean) : [];
|
||||
}
|
||||
|
||||
private isFinished(status: GameStatus): boolean {
|
||||
return status !== 'pending' && status !== 'ongoing';
|
||||
}
|
||||
|
||||
private subscribeToStream(): void {
|
||||
this.stream.streamGame(this.serverUrl, this.tournamentId, this.gameId)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: ev => this.apply(ev),
|
||||
error: err => {
|
||||
this.connecting = false;
|
||||
this.error = (err as Error).message ?? 'Stream failed.';
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Tournament, TournamentList, RoundPairings } from '../models/tournament.models';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
export interface CreateTournamentForm {
|
||||
name: string;
|
||||
@@ -15,7 +14,7 @@ export interface CreateTournamentForm {
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class TournamentService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly base = `${(environment.tournamentServerUrl ?? '').replace(/\/+$/, '')}/api/tournament`;
|
||||
private readonly base = '/api/tournament';
|
||||
|
||||
list(): Observable<TournamentList> {
|
||||
return this.http.get<TournamentList>(this.base);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
MAJOR=0
|
||||
MINOR=6
|
||||
PATCH=2
|
||||
PATCH=5
|
||||
|
||||
Reference in New Issue
Block a user