mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
Enhance document loading and update UI in Blazor app
- Added `StateHasChanged()` call after loading documents in `Documents.razor`. - Introduced `LoadDocumentsAsync` method for document retrieval. - Updated page title in `Home.razor` and injected `IHttpClientFactory`. - Implemented loading spinner and markdown fetching in `OnAfterRenderAsync`. - Configured HTTP client with resilience handler in `Program.cs`.
This commit is contained in:
@@ -127,6 +127,8 @@ else
|
|||||||
await Task.Delay(2000);
|
await Task.Delay(2000);
|
||||||
await using var scope = ServiceProvider.CreateAsyncScope();
|
await using var scope = ServiceProvider.CreateAsyncScope();
|
||||||
await LoadDocumentsAsync(scope.ServiceProvider);
|
await LoadDocumentsAsync(scope.ServiceProvider);
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadDocumentsAsync(IServiceProvider services)
|
private async Task LoadDocumentsAsync(IServiceProvider services)
|
||||||
@@ -142,8 +144,6 @@ else
|
|||||||
LocalCreationDateString = await GetLocalDateTimeStringAsync(dbDocument.CreationDate)
|
LocalCreationDateString = await GetLocalDateTimeStringAsync(dbDocument.CreationDate)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleFileSelected(InputFileChangeEventArgs e)
|
private void HandleFileSelected(InputFileChangeEventArgs e)
|
||||||
|
|||||||
@@ -1,12 +1,38 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
@rendermode @(new InteractiveServerRenderMode(prerender: false))
|
||||||
|
|
||||||
<PageTitle>Blazor Bootstrap - Web App (.NET 9) - Starter Template</PageTitle>
|
@inject IHttpClientFactory HttpClientFactory
|
||||||
|
|
||||||
<h1>Hello, world!</h1>
|
<PageTitle>SQL Database Vector Search</PageTitle>
|
||||||
|
|
||||||
Welcome to your new Blazor Bootstrap - Web App (.NET 9).
|
@if (markdown is null)
|
||||||
<br />
|
{
|
||||||
<br />
|
<div class="d-flex justify-content-center">
|
||||||
Interactive render mode: Server
|
<Spinner Type="SpinnerType.Border" Color="SpinnerColor.Primary" />
|
||||||
<br />
|
</div>
|
||||||
Interactivity location: Global
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<Markdown style="overflow-y:auto;">@markdown</Markdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private string markdown = default!;
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (!firstRender)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
markdown = await HttpClientFactory.CreateClient().GetStringAsync("https://raw.githubusercontent.com/marcominerva/SqlDatabaseVectorSearch/refs/heads/master/README.md");
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,6 +51,7 @@ builder.Services.AddHybridCache(options =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddHttpClient();
|
||||||
builder.Services.ConfigureHttpClientDefaults(builder =>
|
builder.Services.ConfigureHttpClientDefaults(builder =>
|
||||||
{
|
{
|
||||||
builder.AddStandardResilienceHandler();
|
builder.AddStandardResilienceHandler();
|
||||||
|
|||||||
Reference in New Issue
Block a user