| | 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="true" |
| | 19 | | Hover="true" |
| | 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> |
| | 36 | | <MudTd DataLabel="Nome">@context.Name</MudTd> |
| | 37 | | <MudTd DataLabel="Email">@context.Email</MudTd> |
| | 38 | | <MudTd DataLabel="Matrícula">@context.EnrollmentCode</MudTd> |
| | 39 | | <MudTd DataLabel="Curso">@context.CourseOffering</MudTd> |
| | 40 | | <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext"> |
| | 41 | | <MudTd> |
| 0 | 42 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Login" OnClick="@(() => CrossLogi |
| | 43 | | </MudTd> |
| | 44 | | </AuthorizeView> |
| | 45 | | </RowTemplate> |
| | 46 | | <LoadingContent> |
| 0 | 47 | | @if (_breakpoint == Breakpoint.Xs) |
| | 48 | | { |
| | 49 | | <MudProgressLinear Color="Color.Info" Indeterminate="true" /> |
| | 50 | | } |
| | 51 | | </LoadingContent> |
| | 52 | | <NoRecordsContent> |
| | 53 | | @(GetNotFoundMessage()) |
| | 54 | | </NoRecordsContent> |
| | 55 | | <PagerContent> |
| | 56 | | <SykiTablePager /> |
| | 57 | | </PagerContent> |
| | 58 | | </MudTable> |
| | 59 | | </MudContainer> |
| | 60 | | </MudContainer> |
| | 61 | |
|
| | 62 | | @inject NavigationManager Nav |
| | 63 | | @inject GetStudentsClient Client |
| | 64 | | @inject IDialogService DialogService |
| | 65 | | @inject CrossLoginClient CrossLoginClient |
| | 66 | | @inject IBrowserViewportService BrowserViewportService |
| | 67 | |
|
| | 68 | | @code |
| | 69 | | { |
| | 70 | | private bool _loading; |
| | 71 | | private string _searchString; |
| 0 | 72 | | private List<StudentOut> _students = []; |
| | 73 | |
|
| | 74 | | private Breakpoint _breakpoint; |
| | 75 | |
|
| | 76 | | protected override async Task OnInitializedAsync() |
| | 77 | | { |
| 0 | 78 | | _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 79 | | _loading = true; |
| 0 | 80 | | _students = await Client.Get(); |
| 0 | 81 | | _loading = false; |
| 0 | 82 | | } |
| | 83 | |
|
| | 84 | | private async Task CrossLogin(StudentOut student) |
| | 85 | | { |
| 0 | 86 | | _loading = true; |
| 0 | 87 | | await CrossLoginClient.Login(student.Id); |
| 0 | 88 | | Nav.NavigateTo("/", forceLoad: true); |
| 0 | 89 | | _loading = false; |
| 0 | 90 | | } |
| | 91 | |
|
| 0 | 92 | | private Func<StudentOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email, x.EnrollmentCode, x.CourseOf |
| | 93 | |
|
| | 94 | | private async Task OpenDialog() |
| | 95 | | { |
| 0 | 96 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 97 | | var options = new DialogOptions { |
| 0 | 98 | | MaxWidth = MaxWidth.Small, |
| 0 | 99 | | FullWidth = true, |
| 0 | 100 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 101 | | }; |
| 0 | 102 | | var dialog = await DialogService.ShowAsync<CreateStudentDialog>("", options); |
| | 103 | |
|
| 0 | 104 | | var result = await dialog.Result; |
| | 105 | |
|
| 0 | 106 | | if (result!.Canceled) return; |
| | 107 | |
|
| 0 | 108 | | await OnInitializedAsync(); |
| 0 | 109 | | } |
| | 110 | |
|
| | 111 | | private string GetNotFoundMessage() |
| | 112 | | { |
| 0 | 113 | | return (_searchString.IsEmpty()) ? "Não existem alunos cadastrados ainda." : "Nenhum aluno encontrado."; |
| | 114 | | } |
| | 115 | | } |