[CHANGE] event console own component

This commit is contained in:
max
2025-09-10 20:09:58 +02:00
parent 9be6f5be89
commit b1e5b0dc68
4 changed files with 12 additions and 25 deletions

View File

@@ -10,7 +10,7 @@
<MudSwitch @bind-Value="@_autoScroll">Auto-scroll</MudSwitch>
</MudStack>
<div @ref="@_consoleContainer" class="console-container" @onwheel="OnUserScroll">
<Virtualize ItemsProvider="VirtualizedItemsProvider" Context="serviceEvent">
<Virtualize @ref="_virtualize" TItem="ServiceEvent" ItemsProvider="VirtualizedItemsProvider" Context="serviceEvent">
<div class="log-line">
@TimeZoneInfo.ConvertTime(serviceEvent.DateUtc, _timeZone)&nbsp;
<span class="log-severity @GetLogClass(serviceEvent)">@serviceEvent.Severity</span>&nbsp;[<span style="color: #1565c0">@serviceEvent.Source</span>]&nbsp;

View File

@@ -9,7 +9,7 @@ namespace Manager.App.Components.Application.System;
public partial class EventConsole : ComponentBase
{
private const int BatchDelayMs = 1000;
private const int BatchDelayMs = 2000;
private List<ServiceEvent> _serviceEvents = [];
private readonly List<ServiceEvent> _batchBuffer = [];
private readonly SemaphoreSlim _batchLock = new(1, 1);
@@ -17,6 +17,7 @@ public partial class EventConsole : ComponentBase
private bool _autoScroll = true;
private CancellationTokenSource _cts = new();
private TimeZoneInfo _timeZone = TimeZoneInfo.Local;
private Virtualize<ServiceEvent>? _virtualize;
[Parameter]
public List<ServiceEvent> InitialEvents { get; set; } = [];
@@ -109,12 +110,17 @@ public partial class EventConsole : ComponentBase
_serviceEvents.AddRange(batch);
_lastBatchUpdate = DateTime.UtcNow;
await InvokeAsync(StateHasChanged);
if (_virtualize != null)
{
await _virtualize.RefreshDataAsync();
}
if (_autoScroll)
{
await JsRuntime.InvokeVoidAsync("scrollToBottom", _consoleContainer);
}
await InvokeAsync(StateHasChanged);
_updateScheduled = false;
break;