feat(tournaments): remove external server add/remove UI
Servers are now env-var configured; the Servers dialog, add form, remove buttons, and TournamentServerService are all deleted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -271,7 +271,7 @@
|
||||
@if (serversLoading) {
|
||||
<div class="dialog-loading"><span class="pulse"></span>Loading servers…</div>
|
||||
} @else if (servers.length === 0) {
|
||||
<p class="join-empty">No external servers registered yet.</p>
|
||||
<p class="join-empty">No external servers registered.</p>
|
||||
} @else {
|
||||
<div class="servers-list">
|
||||
@for (s of servers; track s.id) {
|
||||
@@ -280,49 +280,14 @@
|
||||
<span class="server-label">{{ s.label }}</span>
|
||||
<span class="server-url">{{ s.url }}</span>
|
||||
</div>
|
||||
<button type="button" class="server-remove-btn"
|
||||
[disabled]="removingServerId === s.id"
|
||||
(click)="removeServer(s.id)"
|
||||
title="Remove server">
|
||||
@if (removingServerId === s.id) { … } @else {
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/>
|
||||
<path d="M10 11v6"/><path d="M14 11v6"/>
|
||||
<path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/>
|
||||
</svg>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="server-add-form">
|
||||
<h4 class="server-add-heading">Add server</h4>
|
||||
<div class="dialog-field">
|
||||
<label class="dialog-label">Label</label>
|
||||
<input type="text" class="dialog-input" [(ngModel)]="newServerLabel"
|
||||
placeholder="e.g. Local Dev Server" />
|
||||
</div>
|
||||
<div class="dialog-field">
|
||||
<label class="dialog-label">URL</label>
|
||||
<input type="url" class="dialog-input" [(ngModel)]="newServerUrl"
|
||||
placeholder="http://host:8089" />
|
||||
</div>
|
||||
@if (addServerError) {
|
||||
<div class="dialog-error">{{ addServerError }}</div>
|
||||
}
|
||||
<div class="dialog-actions">
|
||||
<button type="button" class="btn-ghost" (click)="closeServersDialog()">Close</button>
|
||||
<button type="button" class="btn-primary"
|
||||
[disabled]="addingServer || !newServerLabel.trim() || !newServerUrl.trim()"
|
||||
(click)="addServer()">
|
||||
{{ addingServer ? 'Adding…' : 'Add' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<button type="button" class="btn-ghost" (click)="closeServersDialog()">Close</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -71,11 +71,6 @@ export class TournamentsComponent implements OnInit {
|
||||
showServersDialog = false;
|
||||
servers: ExternalTournamentServer[] = [];
|
||||
serversLoading = false;
|
||||
newServerLabel = '';
|
||||
newServerUrl = '';
|
||||
addingServer = false;
|
||||
addServerError: string | null = null;
|
||||
removingServerId: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.authService.currentUser$
|
||||
@@ -248,9 +243,6 @@ export class TournamentsComponent implements OnInit {
|
||||
}
|
||||
|
||||
openServersDialog(): void {
|
||||
this.newServerLabel = '';
|
||||
this.newServerUrl = '';
|
||||
this.addServerError = null;
|
||||
this.showServersDialog = true;
|
||||
this.serversLoading = true;
|
||||
this.tournamentServerService.list()
|
||||
@@ -265,40 +257,6 @@ export class TournamentsComponent implements OnInit {
|
||||
this.showServersDialog = false;
|
||||
}
|
||||
|
||||
addServer(): void {
|
||||
const label = this.newServerLabel.trim();
|
||||
const url = this.newServerUrl.trim();
|
||||
if (!label || !url || this.addingServer) return;
|
||||
this.addingServer = true;
|
||||
this.addServerError = null;
|
||||
this.tournamentServerService.register(label, url).subscribe({
|
||||
next: server => {
|
||||
this.addingServer = false;
|
||||
this.servers = [...this.servers, server];
|
||||
this.newServerLabel = '';
|
||||
this.newServerUrl = '';
|
||||
this.loadTournaments();
|
||||
},
|
||||
error: err => {
|
||||
this.addingServer = false;
|
||||
this.addServerError = err.error?.error ?? 'Failed to add server.';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
removeServer(id: string): void {
|
||||
if (this.removingServerId) return;
|
||||
this.removingServerId = id;
|
||||
this.tournamentServerService.remove(id).subscribe({
|
||||
next: () => {
|
||||
this.removingServerId = null;
|
||||
this.servers = this.servers.filter(s => s.id !== id);
|
||||
this.loadTournaments();
|
||||
},
|
||||
error: () => { this.removingServerId = null; }
|
||||
});
|
||||
}
|
||||
|
||||
private loadTournaments(): void {
|
||||
this.tournamentService.list()
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
|
||||
@@ -20,12 +20,4 @@ export class TournamentServerService {
|
||||
list(): Observable<ExternalTournamentServerList> {
|
||||
return this.http.get<ExternalTournamentServerList>(this.base);
|
||||
}
|
||||
|
||||
register(label: string, url: string): Observable<ExternalTournamentServer> {
|
||||
return this.http.post<ExternalTournamentServer>(this.base, { label, url });
|
||||
}
|
||||
|
||||
remove(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`${this.base}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user