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