| | 1 | | @using Syki.Front.Components.Summaries |
| | 2 | | @using Syki.Front.Features.Adm.GetCommands |
| | 3 | | @using Syki.Front.Features.Adm.GetCommandsSummary |
| | 4 | |
|
| | 5 | | @namespace Syki.Front.Pages.Adm |
| | 6 | |
|
| | 7 | | @page "/adm/batches" |
| | 8 | | @attribute [Authorize(Roles = "Adm")] |
| | 9 | |
|
| | 10 | | <SykiPageTitle Title="Lotes" /> |
| | 11 | |
|
| | 12 | | <MudContainer Class="my-4 px-4"> |
| | 13 | | <MudCard> |
| | 14 | | <MudCardContent> |
| | 15 | | <MudGrid> |
| | 16 | | <MudItem xs="12" sm="8" md="8" lg="8"> |
| | 17 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 18 | | <MudIcon Icon="@Icons.Material.Filled.BorderOuter" Class="mb-1" Size="Size.Large"/> |
| | 19 | | <MudText Typo="Typo.h5" Style="font-weight: bold">Lotes</MudText> |
| | 20 | | </MudStack> |
| | 21 | | </MudItem> |
| | 22 | | <MudItem xs="12" sm="4" md="4" lg="4" Class="d-flex justify-end"> |
| 0 | 23 | | <MudText Typo="Typo.h4" Style="font-weight: bold">@_data.Summary.Total.ToThousandSeparated()</MudTex |
| | 24 | | </MudItem> |
| | 25 | | </MudGrid> |
| | 26 | | </MudCardContent> |
| | 27 | | </MudCard> |
| | 28 | |
|
| | 29 | | <MudContainer Class="px-0 my-4"> |
| | 30 | | <MudGrid Spacing="2"> |
| | 31 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Rounded.WarningAmber" Color="MudBlazor.Color.Warning" |
| | 32 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.Autorenew" Color="MudBlazor.Color.Info" Text=" |
| | 33 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.ErrorOutline" Color="MudBlazor.Color.Error" Te |
| | 34 | | <SummaryCard Loading="@_loading" Icon="@Icons.Material.Filled.CheckCircleOutline" Color="MudBlazor.Color.Suc |
| | 35 | | </MudGrid> |
| | 36 | | </MudContainer> |
| | 37 | |
|
| | 38 | | <style> |
| | 39 | | .mud-table-toolbar { |
| | 40 | | height: auto; |
| | 41 | | } |
| | 42 | | </style> |
| | 43 | | <MudContainer Class="px-0 my-4"> |
| | 44 | | <MudTable |
| | 45 | | Class="mb-4" |
| | 46 | | Dense="true" |
| | 47 | | Hover="true" |
| | 48 | | Items="@_batches" |
| | 49 | | RowsPerPage="10" |
| | 50 | | T="CommandBatchTableOut" |
| | 51 | | Loading="@_tableLoading" |
| | 52 | | Breakpoint="Breakpoint.Sm" |
| | 53 | | > |
| | 54 | | <ToolBarContent> |
| | 55 | | <MudCard Class="my-4 mr-2" Style="width: 100%" Elevation="0" Outlined="true"> |
| | 56 | | <MudCardContent> |
| | 57 | | <MudGrid Spacing="3"> |
| | 58 | | <MudItem xs="12" sm="3" md="3" lg="3"> |
| | 59 | | <MudSelect |
| | 60 | | Dense="true" |
| | 61 | | Margin="Margin.Dense" |
| | 62 | | Variant="Variant.Outlined" |
| | 63 | | @bind-Value="@_status" |
| | 64 | | Label="Status" |
| | 65 | | Clearable="true" |
| | 66 | | AdornmentColor="Color.Primary |
| | 67 | | "> |
| 0 | 68 | | @foreach (CommandBatchStatus? item in Enum.GetValues<CommandBatchStatus>()) |
| | 69 | | { |
| | 70 | | <MudSelectItem Value="@item"> |
| | 71 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 72 | | <MudIcon Class="mb-1" Icon="@item.Value.GetIcon()" Color="@item.Value.Ge |
| 0 | 73 | | <MudText>@item.GetDescription()</MudText> |
| | 74 | | </MudStack> |
| | 75 | | </MudSelectItem> |
| | 76 | | } |
| | 77 | | </MudSelect> |
| | 78 | | </MudItem> |
| | 79 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | 80 | | <MudSelect |
| | 81 | | Dense="true" |
| | 82 | | Margin="Margin.Dense" |
| | 83 | | Variant="Variant.Outlined" |
| | 84 | | @bind-Value="@_type" |
| | 85 | | Label="Tipo" |
| | 86 | | Clearable="true" |
| | 87 | | AdornmentColor="Color.Primary |
| | 88 | | "> |
| 0 | 89 | | @foreach (CommandBatchType? item in _data.Types.Select(x => x.Type)) |
| | 90 | | { |
| 0 | 91 | | <MudSelectItem Value="@item">@item.GetDescription()</MudSelectItem> |
| | 92 | | } |
| | 93 | | </MudSelect> |
| | 94 | | </MudItem> |
| | 95 | | <MudItem xs="12" sm="5" md="5" lg="5"> |
| | 96 | | <MudAutocomplete |
| | 97 | | T="TinyInstitutionOut" |
| | 98 | | MaxItems="50" |
| | 99 | | SearchFunc="@SearchInstitution" |
| | 100 | | Dense="true" |
| | 101 | | Margin="Margin.Dense" |
| | 102 | | Variant="Variant.Outlined" |
| | 103 | | @bind-Value="@_institution" |
| | 104 | | Label="Instituição" |
| | 105 | | Clearable="true" |
| 0 | 106 | | OnClearButtonClick="@(() => _institution = null)" |
| | 107 | | AdornmentColor="Color.Primary" |
| | 108 | | /> |
| | 109 | | </MudItem> |
| | 110 | | <MudItem xs="12" sm="12" md="12" lg="12" Class="d-flex justify-end align-center pt-1"> |
| | 111 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> |
| 0 | 112 | | <MudChip T="string" Variant="Variant.Text" Color="Color.Primary" Class="mt-1 pt-1">@ |
| | 113 | | <MudButton |
| | 114 | | OnClick="@Filter" |
| | 115 | | Size="Size.Medium" |
| | 116 | | Color="Color.Primary" |
| | 117 | | IconSize="Size.Medium" |
| | 118 | | Variant="Variant.Filled" |
| | 119 | | StartIcon="@Icons.Material.Outlined.FilterList" |
| | 120 | | > |
| | 121 | | Filtrar |
| | 122 | | </MudButton> |
| | 123 | | </MudStack> |
| | 124 | | </MudItem> |
| | 125 | | </MudGrid> |
| | 126 | | </MudCardContent> |
| | 127 | | </MudCard> |
| | 128 | | </ToolBarContent> |
| | 129 | |
|
| | 130 | | <HeaderContent> |
| | 131 | | <MudTh>Tipo</MudTh> |
| | 132 | | <MudTh>Criação</MudTh> |
| | 133 | | <MudTh>Processamento</MudTh> |
| | 134 | | <MudTh>Comandos</MudTh> |
| | 135 | | <MudTh></MudTh> |
| | 136 | | </HeaderContent> |
| | 137 | | <RowTemplate> |
| | 138 | | <MudTd DataLabel="Tipo"> |
| | 139 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> |
| | 140 | | <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Small" / |
| 0 | 141 | | <MudText Typo="Typo.body2">@context.Type.GetDescription()</MudText> |
| | 142 | | </MudStack> |
| | 143 | | </MudTd> |
| 0 | 144 | | <MudTd DataLabel="Criação">@context.CreatedAt.ToMinuteString()</MudTd> |
| 0 | 145 | | <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd> |
| 0 | 146 | | <MudTd DataLabel="Comandos">@context.Size.ToThousandSeparated()</MudTd> |
| | 147 | | <MudTd> |
| 0 | 148 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => GoToDe |
| | 149 | | </MudTd> |
| | 150 | | </RowTemplate> |
| | 151 | | <NoRecordsContent> |
| 0 | 152 | | @(GetNotFoundMessage()) |
| | 153 | | </NoRecordsContent> |
| | 154 | | <PagerContent> |
| | 155 | | <SykiTablePager /> |
| | 156 | | </PagerContent> |
| | 157 | | </MudTable> |
| | 158 | | </MudContainer> |
| | 159 | | </MudContainer> |
| | 160 | |
|
| | 161 | | @inject NavigationManager Nav |
| | 162 | | @inject GetBatchesClient GetBatchesClient |
| | 163 | | @inject GetBatchesSummaryClient GetBatchesSummaryClient |
| | 164 | |
|
| | 165 | | @code |
| | 166 | | { |
| | 167 | | private bool _loading; |
| | 168 | | private bool _tableLoading; |
| 0 | 169 | | private GetBatchesSummaryOut _data = new(); |
| 0 | 170 | | private List<CommandBatchTableOut> _batches = []; |
| | 171 | |
|
| | 172 | | private TinyInstitutionOut? _institution; |
| | 173 | | private CommandBatchType? _type; |
| | 174 | | private CommandBatchStatus? _status; |
| | 175 | |
|
| | 176 | | protected override async Task OnInitializedAsync() |
| | 177 | | { |
| 0 | 178 | | _loading = true; |
| 0 | 179 | | _tableLoading = true; |
| 0 | 180 | | _data = await GetBatchesSummaryClient.Get(); |
| 0 | 181 | | await Filter(); |
| 0 | 182 | | _loading = false; |
| 0 | 183 | | } |
| | 184 | |
|
| | 185 | | private async Task Filter() |
| | 186 | | { |
| 0 | 187 | | _tableLoading = true; |
| 0 | 188 | | var filters = new CommandBatchTableFilterIn() |
| 0 | 189 | | { |
| 0 | 190 | | Type = _type, |
| 0 | 191 | | Status = _status, |
| 0 | 192 | | InstitutionId = _institution?.Id, |
| 0 | 193 | | }; |
| 0 | 194 | | _batches = await GetBatchesClient.Get(filters); |
| 0 | 195 | | _tableLoading = false; |
| 0 | 196 | | } |
| | 197 | |
|
| | 198 | | private async Task<IEnumerable<TinyInstitutionOut>> SearchInstitution(string value, CancellationToken cancellationTo |
| | 199 | | { |
| 0 | 200 | | await Task.Delay(0); |
| | 201 | |
|
| 0 | 202 | | if (string.IsNullOrEmpty(value)) |
| 0 | 203 | | return _data.Institutions; |
| | 204 | |
|
| 0 | 205 | | return _data.Institutions.Where(x => value.IsIn(x.Name)); |
| 0 | 206 | | } |
| | 207 | |
|
| | 208 | | private void GoToDetails(Guid id) |
| | 209 | | { |
| 0 | 210 | | Nav.NavigateTo($"adm/batches/{id}"); |
| 0 | 211 | | } |
| | 212 | |
|
| | 213 | | private string GetNotFoundMessage() |
| | 214 | | { |
| 0 | 215 | | return _tableLoading ? "" : "Não existem lotes ainda."; |
| | 216 | | } |
| | 217 | | } |