fix(adminui): alias update pins invariants + LoadAliasTagAsync + null-driver guard (review)

This commit is contained in:
Joseph Doherty
2026-06-11 21:25:06 -04:00
parent 9f13101896
commit fe068652b3
4 changed files with 76 additions and 0 deletions
@@ -204,6 +204,16 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
.FirstOrDefaultAsync(ct);
}
/// <inheritdoc />
public async Task<AliasTagEditDto?> LoadAliasTagAsync(string tagId, CancellationToken ct = default)
{
await using var db = await dbFactory.CreateDbContextAsync(ct);
var t = await db.Tags.AsNoTracking().FirstOrDefaultAsync(x => x.TagId == tagId, ct);
if (t is null) return null;
return new AliasTagEditDto(t.TagId, t.Name, t.DriverInstanceId, t.DataType, t.AccessLevel,
ExtractTagConfigFullName(t.TagConfig) ?? string.Empty, t.RowVersion);
}
/// <inheritdoc />
public async Task<VirtualTagEditDto?> LoadVirtualTagAsync(string virtualTagId, CancellationToken ct = default)
{
@@ -975,6 +985,8 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
entity.DataType = input.DataType;
entity.AccessLevel = input.AccessLevel;
entity.FolderPath = null;
entity.WriteIdempotent = false;
entity.PollGroupId = null;
entity.TagConfig = BuildAliasTagConfig(input.FullName);
try
@@ -1397,6 +1409,9 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
string? equipmentCluster,
CancellationToken ct)
{
if (string.IsNullOrWhiteSpace(driverInstanceId))
return new UnsMutationResult(false, "An alias must be bound to a Galaxy gateway.");
var driver = await db.DriverInstances.FirstOrDefaultAsync(d => d.DriverInstanceId == driverInstanceId, ct);
if (driver is null)
{