@using ScadaLink.CentralUI.Components.Shared @using ScadaLink.CentralUI.Services @using ScadaLink.Commons.Entities.Audit @using ScadaLink.Commons.Types.Audit @using ScadaLink.Commons.Types.Enums @inject IAuditLogQueryService QueryService
@if (_error is not null) {
@_error
}
@foreach (var col in OrderedColumns()) { // @key keeps Blazor reusing one DOM node per column across // re-renders (reorder/resize), so audit-grid.js binds drag // listeners exactly once per } @if (_rows.Count == 0) { } else { @foreach (var row in _rows) { @foreach (var col in OrderedColumns()) { } } }
and never leaks them onto // discarded nodes — the __auditGridCellBound guard relies on // this node stability to be fully sound. @col.Label
@if (_loading) { Loading… } else { No audit events match the current filter. }
@RenderCell(col.Key, row)
Page @_pageNumber · @_rows.Count rows
@code { // Compact display for Guid id columns: the first 8 hex digits, mirroring // the drilldown drawer's ShortEventId presentation. The full value is kept // in the cell's title attribute so it stays copy-paste accessible. private static string ShortGuid(Guid value) { var n = value.ToString("N"); return n.Length >= 8 ? n[..8] : n; } private RenderFragment RenderCell(string key, AuditEvent row) => __builder => { switch (key) { case "OccurredAtUtc": var occurredOffset = new DateTimeOffset(DateTime.SpecifyKind(row.OccurredAtUtc, DateTimeKind.Utc)); break; case "Site": @(row.SourceSiteId ?? "—") break; case "Channel": @row.Channel break; case "Kind": @row.Kind break; case "Status": @row.Status break; case "Target": @(row.Target ?? "—") break; case "Actor": @(row.Actor ?? "—") break; case "ExecutionId": @if (row.ExecutionId is { } executionId) { @ShortGuid(executionId) } else { } break; case "ParentExecutionId": @if (row.ParentExecutionId is { } parentExecutionId) { @ShortGuid(parentExecutionId) } else { } break; case "DurationMs": @(row.DurationMs?.ToString() ?? "—") break; case "HttpStatus": @(row.HttpStatus?.ToString() ?? "—") break; case "ErrorMessage": @TruncateError(row.ErrorMessage) break; } }; }