|
| 1 | +@page "/health" |
| 2 | + |
| 3 | +@using Arbiter.CommandQuery.Commands |
| 4 | +@using Arbiter.CommandQuery.Models |
| 5 | +@using Arbiter.Dispatcher.Client |
| 6 | +@using Humanizer |
| 7 | + |
| 8 | +<PageTitle>Health Check</PageTitle> |
| 9 | + |
| 10 | +<div class="container-fluid"> |
| 11 | + <LoadingBlock IsLoading="HealthReport == null"> |
| 12 | + <table class="table table-bordered"> |
| 13 | + <tbody> |
| 14 | + <tr> |
| 15 | + <th class="table-secondary">Overall Status</th> |
| 16 | + <td> |
| 17 | + <IconSelector Name="@HealthReport?.Status" /> |
| 18 | + @HealthReport?.Status |
| 19 | + </td> |
| 20 | + <th class="table-secondary">Total Duration</th> |
| 21 | + <td>@HealthReport?.TotalDuration?.Humanize()</td> |
| 22 | + </tr> |
| 23 | + </tbody> |
| 24 | + </table> |
| 25 | + |
| 26 | + <table class="table table-bordered table-hover"> |
| 27 | + <colgroup> |
| 28 | + <col style="width: 30px" /> |
| 29 | + <col style="" /> |
| 30 | + <col style="width: 120px" /> |
| 31 | + <col style="width: 180px" /> |
| 32 | + <col style="" /> |
| 33 | + <col style="width: 170px" /> |
| 34 | + </colgroup> |
| 35 | + <thead> |
| 36 | + <tr class="table-secondary"> |
| 37 | + <th scope="col"></th> |
| 38 | + <th scope="col">Name</th> |
| 39 | + <th scope="col">Status</th> |
| 40 | + <th scope="col">Tags</th> |
| 41 | + <th scope="col">Description</th> |
| 42 | + <th scope="col">Duration</th> |
| 43 | + </tr> |
| 44 | + </thead> |
| 45 | + <tbody> |
| 46 | + @foreach (var healthEntiry in HealthReport?.Entries ?? []) |
| 47 | + { |
| 48 | + <tr> |
| 49 | + <td class="text-center"> |
| 50 | + <IconSelector Name="@healthEntiry.Status" /> |
| 51 | + </td> |
| 52 | + <td>@healthEntiry.Key</td> |
| 53 | + <td>@healthEntiry.Status</td> |
| 54 | + <td>@healthEntiry.Tags?.Humanize(",")</td> |
| 55 | + <td> |
| 56 | + @healthEntiry.Description |
| 57 | + @healthEntiry.Message |
| 58 | + </td> |
| 59 | + <td> |
| 60 | + @healthEntiry.Duration?.Humanize() |
| 61 | + </td> |
| 62 | + </tr> |
| 63 | + } |
| 64 | + </tbody> |
| 65 | + </table> |
| 66 | + </LoadingBlock> |
| 67 | +</div> |
| 68 | + |
| 69 | +@code { |
| 70 | + [Inject] |
| 71 | + public NotificationService NotificationService { get; set; } = null!; |
| 72 | + |
| 73 | + [Inject] |
| 74 | + public IDispatcher Dispatcher { get; set; } = null!; |
| 75 | + |
| 76 | + protected HealthReportModel? HealthReport { get; set; } |
| 77 | + |
| 78 | + protected override async Task OnInitializedAsync() |
| 79 | + { |
| 80 | + try |
| 81 | + { |
| 82 | + var command = new HealthCheckCommand(null); |
| 83 | + var result = await Dispatcher.Send(command); |
| 84 | + |
| 85 | + HealthReport = result; |
| 86 | + } |
| 87 | + catch (Exception ex) |
| 88 | + { |
| 89 | + NotificationService.ShowError(ex); |
| 90 | + } |
| 91 | + finally |
| 92 | + { |
| 93 | + await InvokeAsync(StateHasChanged); |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments