Skip to content

Commit 37f5183

Browse files
authored
Distinguish between expected red vs unexpected red (#307)
Fixes #266 Signed-off-by: Dave Thaler <[email protected]>
1 parent bb04d89 commit 37f5183

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

OrcanodeMonitor/Pages/Index.cshtml.cs

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public string LastChecked
4141
}
4242
}
4343

44-
private string GetBackgroundColor(OrcanodeOnlineStatus status)
44+
private string GetBackgroundColor(OrcanodeOnlineStatus status, OrcanodeOnlineStatus? orcasoundStatus = null)
4545
{
4646
if (status == OrcanodeOnlineStatus.Online)
4747
{
@@ -51,6 +51,10 @@ private string GetBackgroundColor(OrcanodeOnlineStatus status)
5151
{
5252
return ColorTranslator.ToHtml(Color.Yellow);
5353
}
54+
if (orcasoundStatus.HasValue && (orcasoundStatus != OrcanodeOnlineStatus.Online))
55+
{
56+
return ColorTranslator.ToHtml(Color.FromArgb(0xff, 0xcc, 0xcb));
57+
}
5458
return ColorTranslator.ToHtml(Color.Red);
5559
}
5660

@@ -65,35 +69,52 @@ private string GetTextColor(OrcanodeOnlineStatus status)
6569
return ColorTranslator.ToHtml(Color.White);
6670
}
6771

68-
public string NodeS3BackgroundColor(Orcanode node) => GetBackgroundColor(node.S3StreamStatus);
72+
private string GetTextColor(string backgroundColor)
73+
{
74+
if (backgroundColor == ColorTranslator.ToHtml(Color.Red))
75+
{
76+
return ColorTranslator.ToHtml(Color.White);
77+
}
78+
return ColorTranslator.ToHtml(Color.FromArgb(0, 0, 238));
79+
}
80+
81+
public string NodeS3BackgroundColor(Orcanode node) => GetBackgroundColor(node.S3StreamStatus, node.OrcasoundStatus);
6982

70-
public string NodeS3TextColor(Orcanode node) => GetTextColor(node.S3StreamStatus);
83+
public string NodeS3TextColor(Orcanode node) => GetTextColor(NodeS3BackgroundColor(node));
7184

72-
public string NodeOrcaHelloTextColor(Orcanode node) => GetTextColor(node.OrcaHelloStatus);
85+
public string NodeOrcaHelloTextColor(Orcanode node) => GetTextColor(NodeOrcaHelloBackgroundColor(node));
7386

74-
public string NodeOrcaHelloBackgroundColor(Orcanode node) => GetBackgroundColor(node.OrcaHelloStatus);
87+
public string NodeOrcaHelloBackgroundColor(Orcanode node) => GetBackgroundColor(node.OrcaHelloStatus, node.OrcasoundStatus);
7588

7689
/// <summary>
7790
/// Gets the text color for the Mezmo status of the specified node.
7891
/// </summary>
7992
/// <param name="node">The Orcanode instance.</param>
8093
/// <returns>A string representation of the text color.</returns>
81-
public string NodeMezmoTextColor(Orcanode node) => GetTextColor(node.MezmoStatus);
94+
public string NodeMezmoTextColor(Orcanode node) => GetTextColor(NodeMezmoBackgroundColor(node));
8295

8396
/// <summary>
8497
/// Gets the background color for the Mezmo status of the specified node.
8598
/// </summary>
8699
/// <param name="node">The Orcanode instance.</param>
87100
/// <returns>A string representation of the background color.</returns>
88-
public string NodeMezmoBackgroundColor(Orcanode node) => GetBackgroundColor(node.MezmoStatus);
101+
public string NodeMezmoBackgroundColor(Orcanode node) => GetBackgroundColor(node.MezmoStatus, node.OrcasoundStatus);
89102

90-
public string NodeDataplicityBackgroundColor(Orcanode node) => GetBackgroundColor(node.DataplicityConnectionStatus);
103+
public string NodeDataplicityBackgroundColor(Orcanode node) => GetBackgroundColor(node.DataplicityConnectionStatus, node.OrcasoundStatus);
91104

92-
public string NodeDataplicityTextColor(Orcanode node) => GetTextColor(node.DataplicityConnectionStatus);
105+
public string NodeDataplicityTextColor(Orcanode node) => GetTextColor(NodeDataplicityBackgroundColor(node));
93106

94-
public string NodeOrcasoundBackgroundColor(Orcanode node) => GetBackgroundColor(node.OrcasoundStatus);
107+
public string NodeOrcasoundBackgroundColor(Orcanode node)
108+
{
109+
string color = GetBackgroundColor(node.OrcasoundStatus);
110+
if ((node.Type != "Live") && (color == ColorTranslator.ToHtml(Color.Red)))
111+
{
112+
return ColorTranslator.ToHtml(Color.FromArgb(0xff, 0xcc, 0xcb));
113+
}
114+
return color;
115+
}
95116

96-
public string NodeOrcasoundTextColor(Orcanode node) => GetTextColor(node.OrcasoundStatus);
117+
public string NodeOrcasoundTextColor(Orcanode node) => GetTextColor(NodeOrcasoundBackgroundColor(node));
97118

98119
private DateTime SinceTime => DateTime.UtcNow.AddDays(-7);
99120

@@ -104,6 +125,10 @@ public string NodeUptimePercentageBackgroundColor(Orcanode node)
104125
int value = GetUptimePercentage(node);
105126
if (value < 1)
106127
{
128+
if (node.OrcasoundStatus != OrcanodeOnlineStatus.Online)
129+
{
130+
return ColorTranslator.ToHtml(Color.FromArgb(0xff, 0xcc, 0xcb));
131+
}
107132
return ColorTranslator.ToHtml(Color.Red);
108133
}
109134
else if (value > 99)
@@ -113,14 +138,7 @@ public string NodeUptimePercentageBackgroundColor(Orcanode node)
113138

114139
return ColorTranslator.ToHtml(Color.Yellow);
115140
}
116-
public string NodeUptimePercentageTextColor(Orcanode node)
117-
{
118-
if (NodeUptimePercentageBackgroundColor(node) == ColorTranslator.ToHtml(Color.Red))
119-
{
120-
return ColorTranslator.ToHtml(Color.White);
121-
}
122-
return ColorTranslator.ToHtml(Color.FromArgb(0, 0, 238));
123-
}
141+
public string NodeUptimePercentageTextColor(Orcanode node) => GetTextColor(NodeUptimePercentageBackgroundColor(node));
124142

125143
public string NodeDataplicityUpgradeColor(Orcanode node)
126144
{

0 commit comments

Comments
 (0)