Test
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<NavMenu/>
|
||||
</div>
|
||||
|
||||
<main>
|
||||
<header class="top-navbar">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="status-pill @GetStatusClass()">
|
||||
<span class="status-dot @GetStatusDotClass()"></span>
|
||||
<span>@GetStatusText()</span>
|
||||
</div>
|
||||
@if (health?.IsConnected == true)
|
||||
{
|
||||
<span class="text-secondary small">
|
||||
<i class="bi bi-clock-history"></i> @(health.ResponseTimeMs)ms latency
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<button class="btn btn-sm btn-chrono-secondary" @onclick="RefreshHealthAsync" title="Refresh Health Check">
|
||||
<i class="bi bi-arrow-clockwise @(isChecking ? "spin" : "")"></i> Refresh
|
||||
</button>
|
||||
<a href="test-suite" class="btn btn-sm btn-chrono-primary">
|
||||
<i class="bi bi-play-circle-fill"></i> Run Test Suite
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<article class="content-container">
|
||||
@Body
|
||||
</article>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui" class="bg-danger text-white p-3 position-fixed bottom-0 start-0 end-0 d-none">
|
||||
An unhandled error has occurred.
|
||||
<a href="." class="text-white text-decoration-underline ms-2">Reload</a>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private DatabaseHealthStatus? health;
|
||||
private bool isChecking;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ConfigService.OnConfigurationChanged += HandleConfigChanged;
|
||||
await RefreshHealthAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshHealthAsync()
|
||||
{
|
||||
isChecking = true;
|
||||
StateHasChanged();
|
||||
health = await DbService.CheckHealthAsync();
|
||||
isChecking = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void HandleConfigChanged()
|
||||
{
|
||||
_ = RefreshHealthAsync();
|
||||
}
|
||||
|
||||
private string GetStatusClass()
|
||||
{
|
||||
if (health == null) return "status-inmemory";
|
||||
if (!health.IsConnected) return "status-disconnected";
|
||||
if (health.ProviderType == DatabaseProviderType.InMemory) return "status-inmemory";
|
||||
return "status-connected";
|
||||
}
|
||||
|
||||
private string GetStatusDotClass()
|
||||
{
|
||||
if (health == null) return "purple";
|
||||
if (!health.IsConnected) return "red";
|
||||
if (health.ProviderType == DatabaseProviderType.InMemory) return "purple";
|
||||
return "green";
|
||||
}
|
||||
|
||||
private string GetStatusText()
|
||||
{
|
||||
if (health == null) return "Checking connection...";
|
||||
if (!health.IsConnected) return "Disconnected";
|
||||
if (health.ProviderType == DatabaseProviderType.InMemory) return "In-Memory Active";
|
||||
return "PostgreSQL Connected";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ConfigService.OnConfigurationChanged -= HandleConfigChanged;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user