| | 1 | | @namespace Syki.Front.Pages.Academic |
| | 2 | |
|
| | 3 | | @page "/academic/classes" |
| | 4 | | @attribute [Authorize(Roles = "Academic")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Turmas" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.CenterFocusStrong" Title="Turmas" ButtonText="Nova Turma" OnClick="@Ope |
| | 10 | | <MudCard Class="pl-1 my-4"> |
| | 11 | | <MudCardContent> |
| | 12 | | <MudGrid Spacing="3"> |
| | 13 | | <MudItem> |
| | 14 | | <MudButton |
| | 15 | | IconSize="Size.Medium" |
| | 16 | | StartIcon="@Icons.Material.Filled.Article" |
| | 17 | | Variant="Variant.Filled" |
| | 18 | | Size="Size.Medium" |
| | 19 | | Color="Color.Tertiary" |
| | 20 | | Disabled="@(!_showReleaseButton)" |
| | 21 | | OnClick="@OpenReleaseDialog" |
| | 22 | | > |
| | 23 | | Liberar matrícula |
| | 24 | | </MudButton> |
| | 25 | | </MudItem> |
| | 26 | | <MudItem> |
| | 27 | | <MudButton |
| | 28 | | IconSize="Size.Medium" |
| | 29 | | StartIcon="@Icons.Material.Filled.PlayLesson" |
| | 30 | | Variant="Variant.Filled" |
| | 31 | | Size="Size.Medium" |
| | 32 | | Color="Color.Info" |
| | 33 | | Disabled="@(!_showStartButton)" |
| | 34 | | OnClick="@OpenStartDialog" |
| | 35 | | > |
| | 36 | | Iniciar |
| | 37 | | </MudButton> |
| | 38 | | </MudItem> |
| | 39 | | <MudItem> |
| | 40 | | <MudButton |
| | 41 | | IconSize="Size.Medium" |
| | 42 | | StartIcon="@Icons.Material.Filled.FactCheck" |
| | 43 | | Variant="Variant.Filled" |
| | 44 | | Size="Size.Medium" |
| | 45 | | Color="Color.Warning" |
| | 46 | | Disabled="@(!_showFinalizeButton)" |
| | 47 | | OnClick="@OpenFinalizeDialog" |
| | 48 | | > |
| | 49 | | Finalizar |
| | 50 | | </MudButton> |
| | 51 | | </MudItem> |
| | 52 | | </MudGrid> |
| | 53 | | </MudCardContent> |
| | 54 | | </MudCard> |
| | 55 | | <MudContainer Class="px-0 mb-4"> |
| | 56 | | <MudTable |
| | 57 | | Items="@_classes" |
| | 58 | | Class="pa-4" |
| | 59 | | Dense="true" |
| | 60 | | Hover="true" |
| | 61 | | Filter="@_quickFilter" |
| | 62 | | Loading="@_loading" |
| | 63 | | RowsPerPage="10" |
| | 64 | | > |
| | 65 | | <ToolBarContent> |
| | 66 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo"/> |
| | 67 | | </ToolBarContent> |
| | 68 | | <HeaderContent> |
| | 69 | | <MudTh>Disciplina</MudTh> |
| | 70 | | <MudTh>Professor</MudTh> |
| | 71 | | <MudTh>Período</MudTh> |
| | 72 | | <MudTh>Status</MudTh> |
| | 73 | | <MudTh>Frequência</MudTh> |
| | 74 | | <MudTh></MudTh> |
| | 75 | | </HeaderContent> |
| | 76 | | <RowTemplate> |
| | 77 | | <MudTd DataLabel="Disciplina">@context.Discipline</MudTd> |
| | 78 | | <MudTd DataLabel="Professor">@context.Teacher</MudTd> |
| | 79 | | <MudTd DataLabel="Período">@context.Period</MudTd> |
| | 80 | | <MudTd DataLabel="Status">@context.Status.GetDescription()</MudTd> |
| | 81 | | <MudTd DataLabel="Frequência"> |
| | 82 | | <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value="@decimal.ToDouble(c |
| | 83 | | <MudText Typo="Typo.body1"> |
| | 84 | | <b>@context.Frequency.Format()%</b> |
| | 85 | | </MudText> |
| | 86 | | </MudProgressLinear> |
| | 87 | | </MudTd> |
| | 88 | | <MudTd> |
| 0 | 89 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.StickyNote2" OnClick="@(() => Action( |
| | 90 | | </MudTd> |
| | 91 | | </RowTemplate> |
| | 92 | | <LoadingContent> |
| 0 | 93 | | @if (_breakpoint == Breakpoint.Xs) |
| | 94 | | { |
| | 95 | | <MudProgressLinear Color="Color.Info" Indeterminate="true" /> |
| | 96 | | } |
| | 97 | | </LoadingContent> |
| | 98 | | <NoRecordsContent> |
| | 99 | | @(GetNotFoundMessage()) |
| | 100 | | </NoRecordsContent> |
| | 101 | | <PagerContent> |
| | 102 | | <SykiTablePager /> |
| | 103 | | </PagerContent> |
| | 104 | | </MudTable> |
| | 105 | | </MudContainer> |
| | 106 | | </MudContainer> |
| | 107 | |
|
| | 108 | | @inject NavigationManager Nav |
| | 109 | | @inject IDialogService DialogService |
| | 110 | | @inject IBrowserViewportService BrowserViewportService |
| | 111 | | @inject GetAcademicClassesClient GetAcademicClassesClient |
| | 112 | |
|
| | 113 | | @code |
| | 114 | | { |
| | 115 | | private bool _loading; |
| | 116 | | private string _searchString; |
| | 117 | | private bool _showReleaseButton; |
| | 118 | | private bool _showStartButton; |
| | 119 | | private bool _showFinalizeButton; |
| 0 | 120 | | private List<ClassOut> _classes = []; |
| | 121 | | private Breakpoint _breakpoint; |
| | 122 | |
|
| | 123 | | protected override async Task OnInitializedAsync() |
| | 124 | | { |
| 0 | 125 | | _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 126 | | _loading = true; |
| 0 | 127 | | _classes = await GetAcademicClassesClient.Get(); |
| 0 | 128 | | _showReleaseButton = _classes.Any(c => c.Status == ClassStatus.OnPreEnrollment); |
| 0 | 129 | | _showStartButton = _classes.Any(c => c.Status == ClassStatus.AwaitingStart); |
| 0 | 130 | | _showFinalizeButton = _classes.Any(c => c.Status == ClassStatus.Started && c.Lessons.All(l => l.Status == Lesson |
| 0 | 131 | | _loading = false; |
| 0 | 132 | | } |
| | 133 | |
|
| | 134 | | private void Action(ClassOut item) |
| | 135 | | { |
| 0 | 136 | | Nav.NavigateTo($"/academic/classes/{item.Id}"); |
| 0 | 137 | | } |
| | 138 | |
|
| 0 | 139 | | private Func<ClassOut, bool> _quickFilter => x => _searchString.IsIn(x.Discipline, x.Teacher, x.Period, x.Status.Get |
| | 140 | |
|
| | 141 | | private async Task OpenDialog() |
| | 142 | | { |
| 0 | 143 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 144 | | var options = new DialogOptions { |
| 0 | 145 | | MaxWidth = MaxWidth.Small, |
| 0 | 146 | | FullWidth = true, |
| 0 | 147 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 148 | | }; |
| 0 | 149 | | var dialog = await DialogService.ShowAsync<CreateClassDialog>("", options); |
| | 150 | |
|
| 0 | 151 | | var result = await dialog.Result; |
| | 152 | |
|
| 0 | 153 | | if (result!.Canceled) return; |
| | 154 | |
|
| 0 | 155 | | await OnInitializedAsync(); |
| 0 | 156 | | } |
| | 157 | |
|
| | 158 | | private async Task OpenReleaseDialog() |
| | 159 | | { |
| 0 | 160 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 161 | | var options = new DialogOptions { |
| 0 | 162 | | FullWidth = true, |
| 0 | 163 | | MaxWidth = MaxWidth.Medium, |
| 0 | 164 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 165 | | }; |
| 0 | 166 | | var dialog = await DialogService.ShowAsync<ReleaseClassesForEnrollmentDialog>("", options); |
| | 167 | |
|
| 0 | 168 | | var result = await dialog.Result; |
| | 169 | |
|
| 0 | 170 | | if (result!.Canceled) return; |
| | 171 | |
|
| 0 | 172 | | await OnInitializedAsync(); |
| 0 | 173 | | } |
| | 174 | |
|
| | 175 | | private async Task OpenStartDialog() |
| | 176 | | { |
| 0 | 177 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 178 | | var options = new DialogOptions { |
| 0 | 179 | | FullWidth = true, |
| 0 | 180 | | MaxWidth = MaxWidth.Medium, |
| 0 | 181 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 182 | | }; |
| 0 | 183 | | var dialog = await DialogService.ShowAsync<StartClassesDialog>("", options); |
| | 184 | |
|
| 0 | 185 | | var result = await dialog.Result; |
| | 186 | |
|
| 0 | 187 | | if (result!.Canceled) return; |
| | 188 | |
|
| 0 | 189 | | await OnInitializedAsync(); |
| 0 | 190 | | } |
| | 191 | |
|
| | 192 | | private async Task OpenFinalizeDialog() |
| | 193 | | { |
| 0 | 194 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 195 | | var options = new DialogOptions { |
| 0 | 196 | | FullWidth = true, |
| 0 | 197 | | MaxWidth = MaxWidth.Medium, |
| 0 | 198 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 199 | | }; |
| 0 | 200 | | var dialog = await DialogService.ShowAsync<FinalizeClassesDialog>("", options); |
| | 201 | |
|
| 0 | 202 | | var result = await dialog.Result; |
| | 203 | |
|
| 0 | 204 | | if (result!.Canceled) return; |
| | 205 | |
|
| 0 | 206 | | await OnInitializedAsync(); |
| 0 | 207 | | } |
| | 208 | |
|
| | 209 | | private string GetNotFoundMessage() |
| | 210 | | { |
| 0 | 211 | | return (_searchString.IsEmpty()) ? "Não existem turmas cadastradas ainda." : "Nenhuma turma encontrada."; |
| | 212 | | } |
| | 213 | | } |