Browse Source

Add simple row colouring to show overall status

finitereality/replica-status-colors
FiniteReality 6 years ago
committed by Justin Kotalik
parent
commit
03f6145955
  1. 30
      src/Microsoft.Tye.Hosting/Dashboard/Pages/Index.razor

30
src/Microsoft.Tye.Hosting/Dashboard/Pages/Index.razor

@ -20,7 +20,8 @@
{
var logsPath = $"logs/{service.Description.Name}";
var servicePath = $"services/{service.Description.Name}";
<tr @key="service.Description.Name">
var status = GetServiceStatusColor(service);
<tr @key="service.Description.Name" class="@status">
<td>
@if(service.ServiceType == ServiceType.External)
{
@ -96,6 +97,33 @@
return $"{(b.Protocol ?? "tcp")}://{b.Host ?? "localhost"}:{b.Port}";
}
string GetServiceStatusColor(Service service)
{
foreach (var replica in service.Replicas)
{
switch (replica.Value.State)
{
// Replica was recently restarted
case ReplicaState.Removed:
case ReplicaState.Added:
case ReplicaState.Started:
case ReplicaState.Stopped:
return "table-danger";
// Replica has passed liveness, but not readiness
case ReplicaState.Healthy:
return "table-warning";
// Replica passed both liveness and readiness
case ReplicaState.Ready:
continue;
}
}
// All replicas have passed liveness and readiness
return "table-success";
}
protected override void OnInitialized()
{
foreach (var a in application.Services.Values)

Loading…
Cancel
Save