| | 1 | | @namespace Syki.Front.Pages.Student |
| | 2 | |
|
| | 3 | | @page "/student/frequency" |
| | 4 | | @attribute [Authorize(Roles = "Student")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Frequência" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.Class" Title="Frequência" /> |
| | 10 | | <MudAlert Class="my-4 pl-6" NoIcon="true" Severity="Severity.Normal" Variant="Variant.Text" Elevation="1"> |
| | 11 | | <MudText>A frequência mínima para ser aprovado é <b>70.00%</b></MudText> |
| | 12 | | </MudAlert> |
| | 13 | | <MudContainer Class="px-0"> |
| | 14 | | <MudCard> |
| | 15 | | <MudCardContent Class="px-6"> |
| 0 | 16 | | @if (_loading) |
| | 17 | | { |
| | 18 | | <MudProgressLinear Color="Color.Info" Indeterminate="true" /> |
| | 19 | | } |
| | 20 | | else |
| | 21 | | { |
| | 22 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2"> |
| | 23 | | <MudProgressLinear Color="@GetFrequencyColor(_student.Frequency)" Rounded="true" Size="Size.Larg |
| | 24 | | <MudText Typo="Typo.body1"> |
| | 25 | | <b>@GetFrequency()</b> |
| | 26 | | </MudText> |
| | 27 | | <MudText Typo="Typo.h4" Class="mx-2"> |
| | 28 | | <b> · </b> |
| | 29 | | </MudText> |
| | 30 | | <MudText Typo="Typo.body1"> |
| | 31 | | <b>@_student.Frequency.Format()%</b> |
| | 32 | | </MudText> |
| | 33 | | </MudProgressLinear> |
| | 34 | | <MudTooltip Text="Total de presenças durante todo o curso" Arrow="true" Placement="Placement.Bot |
| | 35 | | <MudIconButton Icon="@Icons.Material.Filled.Info" Size="Size.Small" /> |
| | 36 | | </MudTooltip> |
| | 37 | | </MudStack> |
| | 38 | | } |
| | 39 | | </MudCardContent> |
| | 40 | | </MudCard> |
| | 41 | | </MudContainer> |
| | 42 | | <MudContainer Class="px-0 my-4"> |
| | 43 | | <MudContainer Class="px-0 mb-4"> |
| | 44 | | <MudTable |
| | 45 | | T="GetStudentFrequenciesOut" |
| | 46 | | Items="@_frequencies" |
| | 47 | | Class="pa-4" |
| | 48 | | Breakpoint="Breakpoint.Sm" |
| | 49 | | Dense="true" |
| | 50 | | Hover="true" |
| | 51 | | Filter="@_quickFilter" |
| | 52 | | Loading="@_loading" |
| | 53 | | RowsPerPage="100" |
| | 54 | | > |
| | 55 | | <ToolBarContent> |
| | 56 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por disciplina"/> |
| | 57 | | </ToolBarContent> |
| | 58 | | <HeaderContent> |
| | 59 | | <MudTh>Disciplina</MudTh> |
| | 60 | | <MudTh>Período</MudTh> |
| | 61 | | <MudTh>Status</MudTh> |
| | 62 | | <MudTh>Aulas</MudTh> |
| | 63 | | <MudTh>Frequência</MudTh> |
| | 64 | | </HeaderContent> |
| | 65 | | <RowTemplate> |
| | 66 | | <MudTd DataLabel="Disciplina">@context.Name</MudTd> |
| | 67 | | <MudTd DataLabel="Período">@context.Period</MudTd> |
| | 68 | | <MudTd DataLabel="Status">@context.Status.GetDescription()</MudTd> |
| | 69 | | <MudTd DataLabel="Aulas">@context.GetFormated()</MudTd> |
| | 70 | | <MudTd DataLabel="Frequência"> |
| | 71 | | <MudProgressLinear Color="@GetFrequencyColor(context.GetPercentage())" Rounded="true" Size="Size |
| | 72 | | <MudText Typo="Typo.body1"> |
| | 73 | | <b>@context.GetPercentage().Format()%</b> |
| | 74 | | </MudText> |
| | 75 | | </MudProgressLinear> |
| | 76 | | </MudTd> |
| | 77 | | </RowTemplate> |
| | 78 | | <LoadingContent> |
| 0 | 79 | | @if (_breakpoint == Breakpoint.Xs) |
| | 80 | | { |
| | 81 | | <MudProgressLinear Color="Color.Info" Indeterminate="true"/> |
| | 82 | | } |
| | 83 | | </LoadingContent> |
| | 84 | | </MudTable> |
| | 85 | | </MudContainer> |
| | 86 | | </MudContainer> |
| | 87 | | </MudContainer> |
| | 88 | |
|
| | 89 | | @inject GetStudentFrequencyClient FrequencyClient |
| | 90 | | @inject GetStudentFrequenciesClient FrequenciesClient |
| | 91 | | @inject IBrowserViewportService BrowserViewportService |
| | 92 | |
|
| | 93 | | @code |
| | 94 | | { |
| | 95 | | private bool _loading; |
| | 96 | | private string _searchString; |
| | 97 | | private Breakpoint _breakpoint; |
| 0 | 98 | | private GetStudentFrequencyOut _student = new(); |
| 0 | 99 | | private List<GetStudentFrequenciesOut> _frequencies = []; |
| | 100 | |
|
| 0 | 101 | | private Func<GetStudentFrequenciesOut, bool> _quickFilter => x => _searchString.IsIn(x.Name); |
| | 102 | |
|
| | 103 | | protected override async Task OnInitializedAsync() |
| | 104 | | { |
| 0 | 105 | | _loading = true; |
| 0 | 106 | | _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 107 | | _student = await FrequencyClient.Get(); |
| 0 | 108 | | var response = await FrequenciesClient.Get(); |
| 0 | 109 | | if (response.IsSuccess()) _frequencies = response.GetSuccess(); |
| 0 | 110 | | _loading = false; |
| 0 | 111 | | } |
| | 112 | |
|
| | 113 | | private string GetFrequency() |
| | 114 | | { |
| 0 | 115 | | return $"{_student.Presences} / {_student.Attendances}"; |
| | 116 | | } |
| | 117 | |
|
| | 118 | | private Color GetFrequencyColor(decimal frequency) |
| | 119 | | { |
| 0 | 120 | | return frequency >= 70 ? Color.Tertiary : Color.Error; |
| | 121 | | } |
| | 122 | | } |