Implement SignalR integration and refactor WeatherPage
Added SignalR for real-time progress updates during weather data fetch. Refactored WeatherPage to use a new reusable WeatherGrid component and SignalRHelper. Improved loading UI with a radial progress indicator.
This commit is contained in:
@@ -15,9 +15,10 @@ builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.AllowAnyOrigin()
|
||||
policy.WithOrigins("http://localhost:5173")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,6 +42,14 @@ var summaries = new[]
|
||||
|
||||
app.MapGet("/weatherforecast", async () =>
|
||||
{
|
||||
var hub = app.Services.GetRequiredService<IHubContext<WeatherUpdateHub>>();
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
await hub.Clients.All.SendAsync("ProgressUpdate", "None", $$"""{"percentage": "{{i}}", "message": "{{DateTime.Now.Millisecond}}"}""");
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
|
||||
var forecast = Enumerable.Range(1, 2500).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user