| | 1 | | @namespace Syki.Front.Pages.Adm |
| | 2 | |
|
| | 3 | | @page "/adm/users" |
| | 4 | | @attribute [Authorize(Roles = "Adm")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Usuários" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.People" Title="Usuários" /> |
| | 10 | | <MudContainer Class="px-0 my-4"> |
| | 11 | | <MudDataGrid Class="pa-4" Items="@_users" QuickFilter="@_quickFilter" Hover="true" Loading="@_loading" Dense="tr |
| | 12 | | <ToolBarContent> |
| | 13 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo" /> |
| | 14 | | </ToolBarContent> |
| | 15 | | <Columns> |
| | 16 | | <PropertyColumn Property="x => x.Name" Title="Nome" /> |
| | 17 | | <PropertyColumn Property="x => x.Email" Title="Email" /> |
| | 18 | | <PropertyColumn Property="x => x.Institution" Title="Instituição" /> |
| | 19 | | <PropertyColumn Property="x => x.Role" Title="Role" /> |
| | 20 | | </Columns> |
| | 21 | | <NoRecordsContent> |
| | 22 | | @(GetNotFoundMessage()) |
| | 23 | | </NoRecordsContent> |
| | 24 | | <PagerContent> |
| | 25 | | <SykiDataGridPager T="UserOut" /> |
| | 26 | | </PagerContent> |
| | 27 | | </MudDataGrid> |
| | 28 | | </MudContainer> |
| | 29 | | </MudContainer> |
| | 30 | |
|
| | 31 | | @inject GetUsersClient GetUsersClient |
| | 32 | |
|
| | 33 | | @code |
| | 34 | | { |
| | 35 | | private bool _loading; |
| | 36 | | private string _searchString; |
| 0 | 37 | | private List<UserOut> _users = []; |
| | 38 | |
|
| | 39 | | protected override async Task OnInitializedAsync() |
| | 40 | | { |
| 0 | 41 | | _loading = true; |
| 0 | 42 | | _users = await GetUsersClient.Get(); |
| 0 | 43 | | _loading = false; |
| 0 | 44 | | } |
| | 45 | |
|
| 0 | 46 | | private Func<UserOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email, x.Institution, x.Role); |
| | 47 | |
|
| | 48 | | private string GetNotFoundMessage() |
| | 49 | | { |
| 0 | 50 | | return (_searchString.IsEmpty()) ? "Não existem usuários cadastrados ainda." : "Nenhum usuário encontrado."; |
| | 51 | | } |
| | 52 | | } |