| | 1 | | @using Syki.Front.Components.Summaries |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Adm |
| | 4 | |
|
| | 5 | | @page "/adm/events" |
| | 6 | | @attribute [Authorize(Roles = "Adm")] |
| | 7 | |
|
| | 8 | | <SykiPageTitle Title="Eventos" /> |
| | 9 | |
|
| | 10 | | <MudContainer Class="my-4 px-4"> |
| | 11 | | <MudCard> |
| | 12 | | <MudCardContent> |
| | 13 | | <MudGrid> |
| | 14 | | <MudItem xs="12" sm="8" md="8" lg="8"> |
| | 15 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 16 | | <MudIcon Icon="@Icons.Material.Filled.StickyNote2" Class="mb-1" Size="Size.Large"/> |
| | 17 | | <MudText Typo="Typo.h5" Style="font-weight: bold">Eventos</MudText> |
| | 18 | | </MudStack> |
| | 19 | | </MudItem> |
| | 20 | | <MudItem xs="12" sm="4" md="4" lg="4" Class="d-flex justify-end"> |
| 0 | 21 | | <MudText Typo="Typo.h4" Style="font-weight: bold">@_data.Summary.Total.ToThousandSeparated()</MudTex |
| | 22 | | </MudItem> |
| | 23 | | </MudGrid> |
| | 24 | | </MudCardContent> |
| | 25 | | </MudCard> |
| | 26 | |
|
| | 27 | | <MudExpansionPanels Class="mt-4"> |
| | 28 | | <MudExpansionPanel Expanded="@_expanded"> |
| | 29 | | <TitleContent> |
| | 30 | | <div class="d-flex"> |
| | 31 | | <MudIcon Icon="@Icons.Material.Filled.Dashboard" class="mr-3"></MudIcon> |
| | 32 | | <MudText><strong>Dashboard</strong></MudText> |
| | 33 | | </div> |
| | 34 | | </TitleContent> |
| | 35 | | <ChildContent> |
| | 36 | | <MudContainer Class="px-0 mb-2"> |
| | 37 | | <MudGrid Spacing="2"> |
| | 38 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Rounded.WarningAmber" Color="Color.Warnin |
| | 39 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.Autorenew" Color="Color.Info" Text |
| | 40 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.ErrorOutline" Color="Color.Error" |
| | 41 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.CheckCircleOutline" Color="Color.S |
| | 42 | | </MudGrid> |
| | 43 | | </MudContainer> |
| | 44 | | <MudContainer Class="px-0"> |
| | 45 | | <MudGrid Spacing="2"> |
| | 46 | | <MudItem xs="12" sm="6" md="6" lg="6"> |
| | 47 | | <MudPaper Class="px-4 pt-4"> |
| 0 | 48 | | @if (!_loading) |
| | 49 | | { |
| | 50 | | <ApexCharts.ApexChart TItem="LastDomainEventOut" Title="Últimos eventos"> |
| | 51 | | <ApexCharts.ApexPointSeries |
| | 52 | | Name="Eventos" |
| | 53 | | TItem="LastDomainEventOut" |
| | 54 | | Items="@_data.LastEvents" |
| | 55 | | SeriesType="ApexCharts.SeriesType.Line" |
| 0 | 56 | | XValue="@(e => e.Date.ToString("HH:mm:ss"))" |
| 0 | 57 | | YValue="@(e => e.Total)" |
| | 58 | | /> |
| | 59 | | </ApexCharts.ApexChart> |
| | 60 | | } |
| | 61 | | </MudPaper> |
| | 62 | | </MudItem> |
| | 63 | | <MudItem xs="12" sm="6" md="6" lg="6"> |
| | 64 | | <MudPaper Class="px-4 pt-4" Style="height: 100%"> |
| 0 | 65 | | @if (!_loading) |
| | 66 | | { |
| | 67 | | <ApexCharts.ApexChart TItem="DomainEventTypeCountOut" Title="Quantidade por tipo"> |
| | 68 | | <ApexCharts.ApexPointSeries |
| | 69 | | Name="Tipos" |
| | 70 | | TItem="DomainEventTypeCountOut" |
| | 71 | | Items="@_data.EventTypes" |
| | 72 | | SeriesType="ApexCharts.SeriesType.Pie" |
| 0 | 73 | | XValue="@(e => e.Description)" |
| 0 | 74 | | YValue="@(e => e.Total)" |
| | 75 | | PointColor="GetPointColor" |
| | 76 | | /> |
| | 77 | | </ApexCharts.ApexChart> |
| | 78 | | } |
| | 79 | | </MudPaper> |
| | 80 | | </MudItem> |
| | 81 | | </MudGrid> |
| | 82 | | </MudContainer> |
| | 83 | | </ChildContent> |
| | 84 | | </MudExpansionPanel> |
| | 85 | | </MudExpansionPanels> |
| | 86 | |
|
| | 87 | | <style> |
| | 88 | | .mud-table-toolbar { |
| | 89 | | height: auto; |
| | 90 | | } |
| | 91 | | </style> |
| | 92 | | <MudContainer Class="px-0 my-4"> |
| | 93 | | <MudTable |
| | 94 | | Class="mb-4" |
| | 95 | | Dense="true" |
| | 96 | | Hover="true" |
| | 97 | | Items="@_events" |
| | 98 | | RowsPerPage="10" |
| | 99 | | T="DomainEventTableOut" |
| | 100 | | Loading="@_tableLoading" |
| | 101 | | Breakpoint="Breakpoint.Sm" |
| | 102 | | > |
| | 103 | | <ToolBarContent> |
| | 104 | | <MudCard Class="my-4 mr-2" Style="width: 100%" Elevation="0" Outlined="true"> |
| | 105 | | <MudCardContent> |
| | 106 | | <MudGrid Spacing="2"> |
| | 107 | | <MudItem xs="12" sm="3" md="3" lg="3"> |
| | 108 | | <MudSelect |
| | 109 | | Dense="true" |
| | 110 | | Margin="Margin.Dense" |
| | 111 | | Variant="Variant.Outlined" |
| | 112 | | @bind-Value="@_status" |
| | 113 | | Label="Status" |
| | 114 | | Clearable="true" |
| | 115 | | AdornmentColor="Color.Primary |
| | 116 | | "> |
| 0 | 117 | | @foreach (DomainEventStatus? item in Enum.GetValues<DomainEventStatus>()) |
| | 118 | | { |
| | 119 | | <MudSelectItem Value="@item"> |
| | 120 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 121 | | <MudIcon Class="mb-1" Icon="@item.Value.GetIcon()" Color="@item.Value.Ge |
| 0 | 122 | | <MudText>@item.GetDescription()</MudText> |
| | 123 | | </MudStack> |
| | 124 | | </MudSelectItem> |
| | 125 | | } |
| | 126 | | </MudSelect> |
| | 127 | | </MudItem> |
| | 128 | |
|
| | 129 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | 130 | | <MudSelect |
| | 131 | | Dense="true" |
| | 132 | | Margin="Margin.Dense" |
| | 133 | | Variant="Variant.Outlined" |
| | 134 | | @bind-Value="@_type" |
| | 135 | | Label="Tipo" |
| | 136 | | Clearable="true" |
| | 137 | | AdornmentColor="Color.Primary |
| | 138 | | "> |
| 0 | 139 | | @foreach (DomainEventTypeCountOut item in _data.EventTypes) |
| | 140 | | { |
| | 141 | | <MudSelectItem Value="@item.Type"> |
| | 142 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 143 | | <MudIcon Class="mb-1" Icon="@Icons.Material.Filled.Circle" Style="@($"co |
| 0 | 144 | | <MudText>@item.Description</MudText> |
| | 145 | | </MudStack> |
| | 146 | | </MudSelectItem> |
| | 147 | | } |
| | 148 | | </MudSelect> |
| | 149 | | </MudItem> |
| | 150 | |
|
| | 151 | | <MudItem xs="12" sm="5" md="5" lg="5"> |
| | 152 | | <MudAutocomplete |
| | 153 | | T="TinyInstitutionOut" |
| | 154 | | MaxItems="50" |
| | 155 | | SearchFunc="@SearchInstitution" |
| | 156 | | Dense="true" |
| | 157 | | Margin="Margin.Dense" |
| | 158 | | Variant="Variant.Outlined" |
| | 159 | | @bind-Value="@_institution" |
| | 160 | | Label="Instituição" |
| | 161 | | Clearable="true" |
| 0 | 162 | | OnClearButtonClick="@(() => _institution = null)" |
| | 163 | | AdornmentColor="Color.Primary" |
| | 164 | | /> |
| | 165 | | </MudItem> |
| | 166 | |
|
| | 167 | | <MudItem xs="12" sm="3" md="3" lg="3" Class="pt-1"> |
| | 168 | | <MudSelect |
| | 169 | | Dense="true" |
| | 170 | | Margin="Margin.Dense" |
| | 171 | | Variant="Variant.Outlined" |
| | 172 | | @bind-Value="@_commands" |
| | 173 | | Label="Comandos" |
| | 174 | | Clearable="true" |
| | 175 | | AdornmentColor="Color.Primary |
| | 176 | | "> |
| 0 | 177 | | @foreach (CommandStatus? item in Enum.GetValues<CommandStatus>()) |
| | 178 | | { |
| | 179 | | <MudSelectItem Value="@item"> |
| | 180 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 181 | | <MudIcon Class="mb-1" Icon="@item.Value.GetIcon()" Color="@item.Value.Ge |
| 0 | 182 | | <MudText>@item.GetDescription()</MudText> |
| | 183 | | </MudStack> |
| | 184 | | </MudSelectItem> |
| | 185 | | } |
| | 186 | | </MudSelect> |
| | 187 | | </MudItem> |
| | 188 | | <MudItem xs="12" sm="9" md="9" lg="9" Class="d-flex justify-end align-center pt-1"> |
| | 189 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> |
| 0 | 190 | | <MudChip T="string" Variant="Variant.Text" Color="Color.Primary" Class="mt-1 pt-1">@ |
| | 191 | | <MudButton |
| | 192 | | OnClick="@Filter" |
| | 193 | | Size="Size.Medium" |
| | 194 | | Color="Color.Primary" |
| | 195 | | IconSize="Size.Medium" |
| | 196 | | Variant="Variant.Filled" |
| | 197 | | StartIcon="@Icons.Material.Outlined.FilterList" |
| | 198 | | > |
| | 199 | | Filtrar |
| | 200 | | </MudButton> |
| | 201 | | </MudStack> |
| | 202 | | </MudItem> |
| | 203 | | </MudGrid> |
| | 204 | | </MudCardContent> |
| | 205 | | </MudCard> |
| | 206 | | </ToolBarContent> |
| | 207 | |
|
| | 208 | | <HeaderContent> |
| | 209 | | <MudTh>Tipo</MudTh> |
| | 210 | | <MudTh>Ocorrido</MudTh> |
| | 211 | | <MudTh>Processado</MudTh> |
| | 212 | | <MudTh>Comandos</MudTh> |
| | 213 | | <MudTh></MudTh> |
| | 214 | | </HeaderContent> |
| | 215 | | <RowTemplate> |
| | 216 | | <MudTd DataLabel="Tipo"> |
| | 217 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> |
| | 218 | | <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Small" / |
| 0 | 219 | | <MudText Typo="Typo.body2">@context.Description</MudText> |
| | 220 | | </MudStack> |
| | 221 | | </MudTd> |
| 0 | 222 | | <MudTd DataLabel="Ocorrido">@context.OccurredAt.ToMinuteString()</MudTd> |
| 0 | 223 | | <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd> |
| | 224 | | <MudTd DataLabel="Comandos"> |
| 0 | 225 | | @foreach (CommandStatus command in context.Commands) |
| | 226 | | { |
| | 227 | | <MudIcon Icon="@command.GetIcon()" Color="@command.GetColor()" Size="Size.Small" /> |
| | 228 | | } |
| | 229 | | </MudTd> |
| | 230 | | <MudTd> |
| 0 | 231 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => GoToDe |
| | 232 | | </MudTd> |
| | 233 | | </RowTemplate> |
| | 234 | | <NoRecordsContent> |
| 0 | 235 | | @(GetNotFoundMessage()) |
| | 236 | | </NoRecordsContent> |
| | 237 | | <PagerContent> |
| | 238 | | <SykiTablePager /> |
| | 239 | | </PagerContent> |
| | 240 | | </MudTable> |
| | 241 | | </MudContainer> |
| | 242 | |
|
| | 243 | | </MudContainer> |
| | 244 | |
|
| | 245 | | @inject NavigationManager Nav |
| | 246 | | @inject GetDomainEventsClient GetDomainEventsClient |
| | 247 | | @inject GetDomainEventsSummaryClient GetDomainEventsSummaryClient |
| | 248 | |
|
| | 249 | | @code |
| | 250 | | { |
| | 251 | | private bool _loading; |
| | 252 | | private bool _tableLoading; |
| 0 | 253 | | private bool _expanded = true; |
| | 254 | |
|
| 0 | 255 | | private GetDomainEventsSummaryOut _data = new(); |
| 0 | 256 | | private List<DomainEventTableOut> _events = []; |
| | 257 | |
|
| | 258 | | private DomainEventStatus? _status; |
| | 259 | | private string? _type; |
| | 260 | | private TinyInstitutionOut? _institution; |
| | 261 | | private CommandStatus? _commands; |
| | 262 | |
|
| | 263 | | protected override async Task OnInitializedAsync() |
| | 264 | | { |
| 0 | 265 | | _loading = true; |
| 0 | 266 | | _tableLoading = true; |
| 0 | 267 | | _data = await GetDomainEventsSummaryClient.Get(); |
| 0 | 268 | | await Filter(); |
| 0 | 269 | | _loading = false; |
| 0 | 270 | | } |
| | 271 | |
|
| | 272 | | private async Task Filter() |
| | 273 | | { |
| 0 | 274 | | _tableLoading = true; |
| 0 | 275 | | var filters = new DomainEventTableFilterIn() |
| 0 | 276 | | { |
| 0 | 277 | | Type = _type, |
| 0 | 278 | | Commands = _commands, |
| 0 | 279 | | Status = _status, |
| 0 | 280 | | InstitutionId = _institution?.Id, |
| 0 | 281 | | }; |
| 0 | 282 | | _events = await GetDomainEventsClient.Get(filters); |
| 0 | 283 | | _tableLoading = false; |
| 0 | 284 | | } |
| | 285 | |
|
| | 286 | | private async Task<IEnumerable<TinyInstitutionOut>> SearchInstitution(string value, CancellationToken cancellationTo |
| | 287 | | { |
| 0 | 288 | | await Task.Delay(0); |
| | 289 | |
|
| 0 | 290 | | return value.IsEmpty() ? _data.Institutions : _data.Institutions.Where(x => value.IsIn(x.Name)); |
| 0 | 291 | | } |
| | 292 | |
|
| | 293 | | private void GoToDetails(Guid id) |
| | 294 | | { |
| 0 | 295 | | Nav.NavigateTo($"adm/events/{id}"); |
| 0 | 296 | | } |
| | 297 | |
|
| | 298 | | private string GetNotFoundMessage() |
| | 299 | | { |
| 0 | 300 | | return _tableLoading ? "" : "Nenhum evento econtrado."; |
| | 301 | | } |
| | 302 | |
|
| | 303 | | private string GetPointColor(DomainEventTypeCountOut evt) |
| | 304 | | { |
| 0 | 305 | | var index = _data.EventTypes.ConvertAll(x => x.Type).IndexOf(evt.Type); |
| 0 | 306 | | return SykiColors.Colors[index]; |
| | 307 | | } |
| | 308 | | } |