fix(adminui): lane D-b review r0 fixes (I1, M1, M2, M5-M9, N1-N3, N5, H3)
I1: /hosts eviction keyed off the AUTHORED DriverInstances, so a driver deleted in /raw but not yet deployed - still running, still publishing - vanished every tick. The stores' sweep is now EvictUnconfiguredStale(set, olderThanUtc): an entry goes only when unconfigured AND its PublishedUtc is older than 60 s. Tests cover unconfigured+fresh kept (positive control), unconfigured+stale evicted, configured+stale kept, and the deploy hand-off. M1: Test Connect falls back to the driver's documented ProbeTimeoutSeconds default (Galaxy 30, OpcUaClient 15, ...) when the key is absent. M2: the budget never undercuts the config's root timeoutMs (+1 s). M5: RawBrowseModal compares the open generation captured before the await, so a close-then-reopen mid-open closes the stale session. M6: /alarms-historian keeps a 30 s re-poll on 'not registered' (a driver node may still be starting) instead of stopping for good. M7: /scripts source fetch failure shows in the dialog, not the error boundary. M8: the export modal maps only its preview rows; the endpoint writes via Results.Text (no second byte[] copy). M9: /hosts config queries are ordered, so SequenceEqual change detection holds. N1 tooltip, N2 CRLF-safe regex, N3 throttled Warning for subscriber faults, N5 equipment-import help text now describes RFC 4180 quoting. H3: MonacoEditor documents that themes are page-global. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -32,9 +32,13 @@ public static class RawTagCsvExport
|
||||
/// <param name="tagGroupId">When set, only this group's subtree is exported.</param>
|
||||
/// <param name="driverType">The driver type (selects the typed columns); resolved from the device when blank.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <param name="maxRows">When set, only the first <paramref name="maxRows"/> tags are mapped into
|
||||
/// <see cref="RawTagCsvExportResult.Csv"/> (the modal's preview — review r0 M8: it used to map the whole
|
||||
/// export only to keep 50 lines); <see cref="RawTagCsvExportResult.RowCount"/> is always the full count.</param>
|
||||
/// <returns>The export, or null when the target device cannot be resolved.</returns>
|
||||
public static async Task<RawTagCsvExportResult?> BuildAsync(
|
||||
RawTagCsvExportReader reader, string? deviceId, string? tagGroupId, string? driverType, CancellationToken ct = default)
|
||||
RawTagCsvExportReader reader, string? deviceId, string? tagGroupId, string? driverType,
|
||||
CancellationToken ct = default, int? maxRows = null)
|
||||
{
|
||||
string? groupPath = null;
|
||||
if (!string.IsNullOrEmpty(tagGroupId))
|
||||
@@ -66,7 +70,8 @@ public static class RawTagCsvExport
|
||||
}
|
||||
|
||||
var list = tags.ToList();
|
||||
return new RawTagCsvExportResult(RawTagCsvMapper.Export(driverType, list), BuildFileName(deviceId), list.Count, groupPath);
|
||||
var mapped = maxRows is { } max && max >= 0 && max < list.Count ? list.Take(max) : list;
|
||||
return new RawTagCsvExportResult(RawTagCsvMapper.Export(driverType, mapped), BuildFileName(deviceId), list.Count, groupPath);
|
||||
}
|
||||
|
||||
/// <summary>The first <paramref name="maxLines"/> lines of <paramref name="csv"/>, without copying the rest.</summary>
|
||||
@@ -118,14 +123,17 @@ public static class RawTagCsvExport
|
||||
/// <returns>The route handler builder.</returns>
|
||||
public static RouteHandlerBuilder MapRawTagCsvExport(this IEndpointRouteBuilder app) =>
|
||||
app.MapGet(DownloadPath, async (
|
||||
string? deviceId, string? tagGroupId, string? driverType,
|
||||
HttpContext http, string? deviceId, string? tagGroupId, string? driverType,
|
||||
RawTagCsvExportReader reader, CancellationToken ct) =>
|
||||
{
|
||||
var export = await BuildAsync(reader, deviceId, tagGroupId, driverType, ct);
|
||||
// File(..., fileDownloadName) sends Content-Disposition: attachment, so the browser saves it.
|
||||
return export is null
|
||||
? Results.NotFound()
|
||||
: Results.File(System.Text.Encoding.UTF8.GetBytes(export.Csv), "text/csv; charset=utf-8", export.FileName);
|
||||
if (export is null) return Results.NotFound();
|
||||
|
||||
// Attachment, so the browser saves rather than renders. Results.Text writes the string
|
||||
// through the response encoder, so no second whole-file byte[] copy is held (review r0 M8).
|
||||
http.Response.Headers.ContentDisposition =
|
||||
new System.Net.Mime.ContentDisposition { FileName = export.FileName, DispositionType = "attachment" }.ToString();
|
||||
return Results.Text(export.Csv, "text/csv; charset=utf-8", System.Text.Encoding.UTF8);
|
||||
})
|
||||
.RequireAuthorization(AdminUiPolicies.ConfigEditor)
|
||||
.WithName("RawTagCsvExport");
|
||||
|
||||
Reference in New Issue
Block a user