feat(dashboard): distinct 'forced' subtag provider badge
Render Fallback:Mode=ForceSubtag as a cyan 'Subtag monitoring (forced)' badge, distinct from the amber failover 'degraded' badge, so an intentional configuration isn't shown as a fault. Distinguished by the shared AlarmProviderReasons.ForcedSubtag reason carried on the provider-status feed.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ZB.MOM.WW.MxGateway.Contracts.Proto;
|
||||
using ZB.MOM.WW.MxGateway.Server.Alarms;
|
||||
|
||||
namespace ZB.MOM.WW.MxGateway.Server.Dashboard;
|
||||
|
||||
@@ -22,9 +23,20 @@ public sealed record DashboardAlarmProviderStatus(
|
||||
/// <summary>Badge label shown when the feed has fallen back to subtag monitoring.</summary>
|
||||
public const string DegradedLabel = "Subtag monitoring (degraded)";
|
||||
|
||||
/// <summary>
|
||||
/// Badge label shown when the feed is in subtag monitoring because it was
|
||||
/// deliberately configured (<c>Fallback:Mode=ForceSubtag</c>), as opposed
|
||||
/// to an unexpected failover. A stable, intended state rather than a fault.
|
||||
/// </summary>
|
||||
public const string ForcedSubtagLabel = "Subtag monitoring (forced)";
|
||||
|
||||
private const string HealthyBadge = "bg-success";
|
||||
private const string DegradedBadge = "bg-warning text-dark";
|
||||
|
||||
// Cyan/info badge: visually distinct from the amber failover-degraded badge —
|
||||
// forced subtag is an intentional configuration, not an alarm-manager fault.
|
||||
private const string ForcedSubtagBadge = "bg-info text-dark";
|
||||
|
||||
/// <summary>
|
||||
/// The default status assumed before the first provider-status message
|
||||
/// arrives: healthy alarm-manager mode.
|
||||
@@ -48,13 +60,24 @@ public sealed record DashboardAlarmProviderStatus(
|
||||
// the contract sets degraded=true whenever mode == SUBTAG, but guard
|
||||
// against either being set independently.
|
||||
bool degraded = status.Degraded || status.Mode == AlarmProviderMode.Subtag;
|
||||
string reason = status.Reason ?? string.Empty;
|
||||
|
||||
// A configured ForceSubtag start carries the well-known forced reason and
|
||||
// is a deliberate mode, not a failover — render it distinctly so an
|
||||
// operator isn't alarmed by a "(degraded)" badge for an intended config.
|
||||
bool forced = degraded
|
||||
&& status.Mode == AlarmProviderMode.Subtag
|
||||
&& string.Equals(reason, AlarmProviderReasons.ForcedSubtag, StringComparison.Ordinal);
|
||||
|
||||
string label = !degraded ? AlarmManagerLabel : forced ? ForcedSubtagLabel : DegradedLabel;
|
||||
string badge = !degraded ? HealthyBadge : forced ? ForcedSubtagBadge : DegradedBadge;
|
||||
|
||||
return new DashboardAlarmProviderStatus(
|
||||
Mode: status.Mode,
|
||||
IsDegraded: degraded,
|
||||
Label: degraded ? DegradedLabel : AlarmManagerLabel,
|
||||
BadgeCssClass: degraded ? DegradedBadge : HealthyBadge,
|
||||
Reason: status.Reason ?? string.Empty,
|
||||
Label: label,
|
||||
BadgeCssClass: badge,
|
||||
Reason: reason,
|
||||
SinceUtc: status.Since?.ToDateTimeOffset());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user