Initial version
This commit is contained in:
commit
e5b6226a85
68 changed files with 7338 additions and 0 deletions
38
DataTransfer.Client/Components/ServerLoad.razor
Normal file
38
DataTransfer.Client/Components/ServerLoad.razor
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@implements IDisposable
|
||||
@inject ServerStatusMonitor Monitor
|
||||
|
||||
@if (Monitor.Current is { } status)
|
||||
{
|
||||
<span class="server-load @LoadClass(status)" title="@Describe(status)" data-testid="server-load">
|
||||
<span class="server-load-dot" aria-hidden="true"></span>
|
||||
<span class="server-load-count">@status.ActiveConnections/@status.MaxConnections</span>
|
||||
<span class="server-load-label">connections</span>
|
||||
@if (status.QueuedClients > 0)
|
||||
{
|
||||
<span class="server-load-queue">· @status.QueuedClients queued</span>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Monitor.Changed += OnMonitorChanged;
|
||||
Monitor.EnsureStarted();
|
||||
}
|
||||
|
||||
public void Dispose() => Monitor.Changed -= OnMonitorChanged;
|
||||
|
||||
private void OnMonitorChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private static string LoadClass(ServerStatus status) =>
|
||||
status.ActiveConnections >= status.MaxConnections ? "is-full"
|
||||
: status.ActiveConnections * 5 >= status.MaxConnections * 4 ? "is-high"
|
||||
: "is-ok";
|
||||
|
||||
private static string Describe(ServerStatus status) =>
|
||||
$"{status.ActiveConnections} of {status.MaxConnections} connections in use"
|
||||
+ (status.QueuedClients > 0 ? $", {status.QueuedClients} waiting in the queue" : null);
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue