Enhance SwarmUI integration by adding swarm connection status to the API and updating client-side components to reflect this status. Improved localization strings for various SwarmUI states and refactored ApplicantsDialog and PersonCard components to utilize the new connection information, ensuring a more responsive user experience.
ci / server (push) Failing after 4m56s
ci / client (push) Failing after 15s

This commit is contained in:
Leonid Pershin
2026-08-20 04:21:35 +03:00
parent 36b46774a7
commit 5991dcd5c4
13 changed files with 246 additions and 33 deletions
+8 -3
View File
@@ -37,6 +37,7 @@ builder.Services.AddSingleton<GameSocketHandler>();
builder.Services.AddSingleton<GameLoopService>();
builder.Services.AddHostedService(sp => sp.GetRequiredService<GameLoopService>());
builder.Services.AddSwarmUi(builder.Configuration);
builder.Services.AddSingleton<SwarmUiHealthService>();
builder.Services.AddSingleton(sp => SwarmUiSettings.Load(sp.GetRequiredService<IHostEnvironment>(), sp.GetRequiredService<ILoggerFactory>().CreateLogger("SwarmUiSettings")));
builder.Services.AddSingleton<PortraitService>();
@@ -60,16 +61,19 @@ app.MapSchoolEndpoints();
app.MapTimetableEndpoints();
app.MapModEndpoints();
app.MapGet("/api/status", (GameLoopService loop, ClientRegistry clients, IOptions<SwarmUiOptions> swarm) =>
app.MapGet("/api/status", async (GameLoopService loop, ClientRegistry clients, IOptions<SwarmUiOptions> swarm, SwarmUiHealthService swarmHealth, CancellationToken cancellationToken) =>
{
var state = loop.SchoolsState;
var configured = !string.IsNullOrWhiteSpace(swarm.Value.BaseUrl);
var connected = configured ? await swarmHealth.GetConnectedAsync(cancellationToken) : null;
return new GameStatusResponse(
loop.CurrentTick,
loop.Options.TickRate,
state.Schools.Count,
state.MaxSchools,
clients.Count,
!string.IsNullOrWhiteSpace(swarm.Value.BaseUrl));
configured,
connected);
})
.WithName("GetGameStatus");
@@ -119,7 +123,8 @@ internal sealed record GameStatusResponse(
int Schools,
int MaxSchools,
int Connections,
bool SwarmUiConfigured);
bool SwarmUiConfigured,
bool? SwarmUiConnected);
/// <summary>Exposed so <c>WebApplicationFactory</c>-style tests can reference the entry point.</summary>
public partial class Program;