diff --git a/OrcanodeMonitor/Pages/Index.cshtml b/OrcanodeMonitor/Pages/Index.cshtml index 0dc3513..de60fc3 100644 --- a/OrcanodeMonitor/Pages/Index.cshtml +++ b/OrcanodeMonitor/Pages/Index.cshtml @@ -71,7 +71,7 @@ } - + @Model.GetUptimePercentage(item)% @if (item.OrcasoundStatus == Models.OrcanodeOnlineStatus.Absent) diff --git a/OrcanodeMonitor/Pages/Index.cshtml.cs b/OrcanodeMonitor/Pages/Index.cshtml.cs index 2909393..8f080e9 100644 --- a/OrcanodeMonitor/Pages/Index.cshtml.cs +++ b/OrcanodeMonitor/Pages/Index.cshtml.cs @@ -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;