Files
lmxopcua/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Shared/DeploymentFeedback.razor
T

109 lines
5.5 KiB
Plaintext

@using ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin
@using ZB.MOM.WW.OtOpcUa.Configuration.Enums
<section class="panel p-3 mb-3" aria-label="Deployment feedback">
<div role="status" aria-live="polite" aria-atomic="true">
@if (InitialLoading)
{
<p class="mb-0">Loading deployment history…</p>
}
else
{
@if (RequestPending)
{
<p class="mb-2">Waiting for request acceptance…</p>
}
else if (RequestResultUnavailable)
{
<p class="mb-2">The request result could not be confirmed. Refresh status before retrying.</p>
}
else if (RequestOutcome == StartDeploymentOutcome.Accepted)
{
<p class="mb-2">@(Status is null or DeploymentStatus.Dispatching or DeploymentStatus.AwaitingApplyAcks ? "Request accepted — deployment in progress." : "Request accepted.")</p>
}
else if (RequestOutcome == StartDeploymentOutcome.NoChanges)
{
<p class="mb-2">No configuration changes; no new deployment was requested.</p>
}
else if (RequestOutcome == StartDeploymentOutcome.AnotherDeploymentInFlight)
{
<p class="mb-2">Another deployment is already in progress. This request was not started.</p>
}
else if (RequestOutcome == StartDeploymentOutcome.Rejected)
{
<p class="mb-2">Request rejected. @(string.IsNullOrEmpty(RequestMessage) ? "No reason was supplied." : "Open the request details below for the recorded reason.")</p>
}
@if (!HistoryAvailable)
{
<p class="mb-0">Deployment history is unavailable. Refresh to try again.</p>
}
else if (Status is not null)
{
<div>
@ContextLabel: <StatusPill State="@RecordedState">@(Status == DeploymentStatus.AwaitingApplyAcks ? "Awaiting acks" : RecordedLabel)</StatusPill>
@if (Status == DeploymentStatus.AwaitingApplyAcks)
{
<div class="small">Awaiting apply acknowledgements</div>
}
</div>
}
else if (RequestOutcome == StartDeploymentOutcome.Accepted)
{
<p class="mb-0">The requested deployment status is not yet observed in the loaded history. Refresh status to check application progress.</p>
}
else
{
<p class="mb-0">No deployment history recorded.</p>
}
}
</div>
@* Full diagnostics are outside the live region: opening one must not announce an entire payload. *@
@if (!string.IsNullOrEmpty(RequestMessage))
{
<div class="mt-2"><DiagnosticDetails Summary="Request details" Text="@RequestMessage" /></div>
}
@if (!string.IsNullOrEmpty(FailureReason))
{
<div class="mt-2"><DiagnosticDetails Summary="Application failure details" Text="@FailureReason" /></div>
}
</section>
@code {
/// <summary>The actual actor reply outcome, absent before a confirmed reply.</summary>
[Parameter] public StartDeploymentOutcome? RequestOutcome { get; set; }
/// <summary>True only while waiting for the request reply, not while application proceeds.</summary>
[Parameter] public bool RequestPending { get; set; }
/// <summary>A transport failure left the reply unknown; it does not establish server rejection.</summary>
[Parameter] public bool RequestResultUnavailable { get; set; }
/// <summary>Complete existing request metadata, disclosed outside the short live outcome.</summary>
[Parameter] public string? RequestMessage { get; set; }
/// <summary>The recorded status of the explicitly named loaded deployment.</summary>
[Parameter] public DeploymentStatus? Status { get; set; }
/// <summary>Complete recorded application failure metadata, including sealed degradation.</summary>
[Parameter] public string? FailureReason { get; set; }
/// <summary>The initial history query is still pending, distinct from a confirmed empty read.</summary>
[Parameter] public bool InitialLoading { get; set; }
/// <summary>Whether any history read has succeeded; false avoids inventing an empty history.</summary>
[Parameter] public bool HistoryAvailable { get; set; } = true;
/// <summary>Identifies whose recorded status is shown, e.g. the requested deployment.</summary>
[Parameter] public string ContextLabel { get; set; } = "Most recent recorded deployment";
private string RecordedLabel => Status switch
{
DeploymentStatus.Dispatching => "Dispatching",
DeploymentStatus.AwaitingApplyAcks => "Awaiting apply acknowledgements",
DeploymentStatus.Sealed when !string.IsNullOrEmpty(FailureReason) => "Sealed (degraded)",
DeploymentStatus.Sealed => "Sealed",
DeploymentStatus.PartiallyFailed => "Partially failed",
DeploymentStatus.TimedOut => "Timed out",
_ => $"Unknown status ({(int?)Status})",
};
private StatusState RecordedState => Status switch
{
DeploymentStatus.Sealed when string.IsNullOrEmpty(FailureReason) => StatusState.Ok,
DeploymentStatus.Sealed => StatusState.Warn,
DeploymentStatus.PartiallyFailed or DeploymentStatus.TimedOut => StatusState.Bad,
DeploymentStatus.Dispatching or DeploymentStatus.AwaitingApplyAcks => StatusState.Info,
_ => StatusState.Idle,
};
}