Skip to content

Commit

Permalink
Add color to column
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler committed Oct 23, 2024
1 parent 1fae635 commit c3c1bfe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OrcanodeMonitor/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</a>
</td>
}
<td>
<td style="background-color: @Model.NodeUptimePercentageBackgroundColor(item); color: @Model.NodeUptimePercentageTextColor(item)">
@Model.GetUptimePercentage(item)%
</td>
@if (item.OrcasoundStatus == Models.OrcanodeOnlineStatus.Absent)
Expand Down
23 changes: 23 additions & 0 deletions OrcanodeMonitor/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,29 @@ public int GetUptimePercentage(Orcanode node)
return (int)((100.0 * up) / _uptimeEvaluationPeriod + 0.5);
}

public string NodeUptimePercentageBackgroundColor(Orcanode node)
{
int value = GetUptimePercentage(node);
if (value < 1)
{
return ColorTranslator.ToHtml(Color.Red);
}
else if (value > 99)
{
return ColorTranslator.ToHtml(Color.LightGreen);
}

return ColorTranslator.ToHtml(Color.Yellow);
}
public string NodeUptimePercentageTextColor(Orcanode node)
{
if (NodeUptimePercentageBackgroundColor(node) == ColorTranslator.ToHtml(Color.Red))
{
return ColorTranslator.ToHtml(Color.White);
}
return ColorTranslator.ToHtml(Color.FromArgb(0, 0, 238));
}

public string NodeDataplicityUpgradeColor(Orcanode node)
{
OrcanodeUpgradeStatus status = node.DataplicityUpgradeStatus;
Expand Down

0 comments on commit c3c1bfe

Please sign in to comment.