74 lines
2.6 KiB
Plaintext
74 lines
2.6 KiB
Plaintext
@page "/clusters/{ClusterId}/draft/{GenerationId:long}/diff"
|
|
@using ZB.MOM.WW.OtOpcUa.Admin.Services
|
|
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
|
|
@using ZB.MOM.WW.OtOpcUa.Configuration.Enums
|
|
@inject GenerationService GenerationSvc
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<div>
|
|
<h1 class="mb-0">Draft diff</h1>
|
|
<small class="text-muted">
|
|
Cluster <code>@ClusterId</code> — from last published (@(_fromLabel)) → to draft @GenerationId
|
|
</small>
|
|
</div>
|
|
<a class="btn btn-outline-secondary" href="/clusters/@ClusterId/draft/@GenerationId">Back to editor</a>
|
|
</div>
|
|
|
|
@if (_rows is null)
|
|
{
|
|
<p>Computing diff…</p>
|
|
}
|
|
else if (_error is not null)
|
|
{
|
|
<div class="alert alert-danger">@_error</div>
|
|
}
|
|
else if (_rows.Count == 0)
|
|
{
|
|
<p class="text-muted">No differences — draft is structurally identical to the last published generation.</p>
|
|
}
|
|
else
|
|
{
|
|
<table class="table table-hover table-sm">
|
|
<thead><tr><th>Table</th><th>LogicalId</th><th>ChangeKind</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var r in _rows)
|
|
{
|
|
<tr>
|
|
<td>@r.TableName</td>
|
|
<td><code>@r.LogicalId</code></td>
|
|
<td>
|
|
@switch (r.ChangeKind)
|
|
{
|
|
case "Added": <span class="badge bg-success">@r.ChangeKind</span> break;
|
|
case "Removed": <span class="badge bg-danger">@r.ChangeKind</span> break;
|
|
case "Modified": <span class="badge bg-warning text-dark">@r.ChangeKind</span> break;
|
|
default: <span class="badge bg-secondary">@r.ChangeKind</span> break;
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public string ClusterId { get; set; } = string.Empty;
|
|
[Parameter] public long GenerationId { get; set; }
|
|
|
|
private List<DiffRow>? _rows;
|
|
private string _fromLabel = "(empty)";
|
|
private string? _error;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
try
|
|
{
|
|
var all = await GenerationSvc.ListRecentAsync(ClusterId, 50, CancellationToken.None);
|
|
var from = all.FirstOrDefault(g => g.Status == GenerationStatus.Published);
|
|
_fromLabel = from is null ? "(empty)" : $"gen {from.GenerationId}";
|
|
_rows = await GenerationSvc.ComputeDiffAsync(from?.GenerationId ?? 0, GenerationId, CancellationToken.None);
|
|
}
|
|
catch (Exception ex) { _error = ex.Message; }
|
|
}
|
|
}
|