| | | 1 | | @using Syki.Front.Features.Academic.CreateStudent |
| | | 2 | | |
| | | 3 | | @namespace Syki.Front.Pages.Academic |
| | | 4 | | |
| | | 5 | | @page "/academic/students" |
| | | 6 | | @attribute [Authorize(Roles = "Academic")] |
| | | 7 | | |
| | | 8 | | <SykiPageTitle Title="Alunos" /> |
| | | 9 | | |
| | | 10 | | <MudContainer Class="my-4 px-4"> |
| | | 11 | | <SykiPageHeader Icon="@Icons.Material.Filled.People" Title="Alunos" ButtonText="Novo Aluno" OnClick="@OpenDialog" /> |
| | | 12 | | <SykiPageAlert Text="Um aluno precisa necessariamente estar vinculado à uma oferta de curso." /> |
| | | 13 | | <MudContainer Class="px-0 mb-4"> |
| | | 14 | | <MudTable |
| | | 15 | | Class="pa-4" |
| | | 16 | | Items="@_students" |
| | | 17 | | Filter="@_quickFilter" |
| | | 18 | | Dense |
| | | 19 | | Hover |
| | | 20 | | Loading="@_loading" |
| | | 21 | | RowsPerPage="10" |
| | | 22 | | > |
| | | 23 | | <ToolBarContent> |
| | | 24 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo"/> |
| | | 25 | | </ToolBarContent> |
| | | 26 | | <HeaderContent> |
| | | 27 | | <MudTh>Nome</MudTh> |
| | | 28 | | <MudTh>Email</MudTh> |
| | | 29 | | <MudTh>Matrícula</MudTh> |
| | | 30 | | <MudTh>Curso</MudTh> |
| | | 31 | | <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext"> |
| | | 32 | | <MudTh></MudTh> |
| | | 33 | | </AuthorizeView> |
| | | 34 | | </HeaderContent> |
| | | 35 | | <RowTemplate> |
| | 0 | 36 | | <MudTd DataLabel="Nome">@context.Name</MudTd> |
| | 0 | 37 | | <MudTd DataLabel="Email">@context.Email</MudTd> |
| | 0 | 38 | | <MudTd DataLabel="Matrícula">@context.EnrollmentCode</MudTd> |
| | 0 | 39 | | <MudTd DataLabel="Curso">@context.CourseOffering</MudTd> |
| | | 40 | | <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext"> |
| | | 41 | | <MudTd> |
| | | 42 | | <MudTooltip Text="Cross Login" Arrow Placement="Placement.Top" ShowOnFocus="false"> |
| | 0 | 43 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Login" OnClick="@(() => Cross |
| | | 44 | | </MudTooltip> |
| | | 45 | | </MudTd> |
| | | 46 | | </AuthorizeView> |
| | | 47 | | </RowTemplate> |
| | | 48 | | <LoadingContent> |
| | 0 | 49 | | @if (_breakpoint == Breakpoint.Xs) |
| | | 50 | | { |
| | | 51 | | <MudProgressLinear Color="Color.Info" Indeterminate /> |
| | | 52 | | } |
| | | 53 | | </LoadingContent> |
| | | 54 | | <NoRecordsContent> |
| | 0 | 55 | | @(GetNotFoundMessage()) |
| | | 56 | | </NoRecordsContent> |
| | | 57 | | <PagerContent> |
| | | 58 | | <SykiTablePager /> |
| | | 59 | | </PagerContent> |
| | | 60 | | </MudTable> |
| | | 61 | | </MudContainer> |
| | | 62 | | </MudContainer> |
| | | 63 | | |
| | | 64 | | @inject NavigationManager Nav |
| | | 65 | | @inject GetStudentsClient Client |
| | | 66 | | @inject IDialogService DialogService |
| | | 67 | | @inject CrossLoginClient CrossLoginClient |
| | | 68 | | @inject IBrowserViewportService BrowserViewportService |
| | | 69 | | |
| | | 70 | | @code |
| | | 71 | | { |
| | | 72 | | private bool _loading; |
| | | 73 | | private string _searchString; |
| | 0 | 74 | | private List<StudentOut> _students = []; |
| | | 75 | | |
| | | 76 | | private Breakpoint _breakpoint; |
| | | 77 | | |
| | | 78 | | protected override async Task OnInitializedAsync() |
| | | 79 | | { |
| | 0 | 80 | | _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 81 | | _loading = true; |
| | 0 | 82 | | _students = await Client.Get(); |
| | 0 | 83 | | _loading = false; |
| | 0 | 84 | | } |
| | | 85 | | |
| | | 86 | | private async Task CrossLogin(StudentOut student) |
| | | 87 | | { |
| | 0 | 88 | | _loading = true; |
| | 0 | 89 | | await CrossLoginClient.Login(student.Id); |
| | 0 | 90 | | Nav.NavigateTo("/", forceLoad: true); |
| | 0 | 91 | | _loading = false; |
| | 0 | 92 | | } |
| | | 93 | | |
| | 0 | 94 | | private Func<StudentOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email, x.EnrollmentCode, x.CourseOf |
| | | 95 | | |
| | | 96 | | private async Task OpenDialog() |
| | | 97 | | { |
| | 0 | 98 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 99 | | var options = new DialogOptions { |
| | 0 | 100 | | MaxWidth = MaxWidth.Small, |
| | 0 | 101 | | FullWidth = true, |
| | 0 | 102 | | FullScreen = breakpoint == Breakpoint.Xs, |
| | 0 | 103 | | }; |
| | 0 | 104 | | var dialog = await DialogService.ShowAsync<CreateStudentDialog>("", options); |
| | | 105 | | |
| | 0 | 106 | | var result = await dialog.Result; |
| | | 107 | | |
| | 0 | 108 | | if (result!.Canceled) return; |
| | | 109 | | |
| | 0 | 110 | | await OnInitializedAsync(); |
| | 0 | 111 | | } |
| | | 112 | | |
| | | 113 | | private string GetNotFoundMessage() |
| | | 114 | | { |
| | 0 | 115 | | return (_searchString.IsEmpty()) ? "Não existem alunos cadastrados ainda." : "Nenhum aluno encontrado."; |
| | | 116 | | } |
| | | 117 | | } |