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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user