< Summary

Information
Class: Syki.Front.Pages.Academic.AcademicClassesPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicClassesPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 59
Coverable lines: 59
Total lines: 213
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
OnInitializedAsync()100%210%
Action(...)100%210%
get__quickFilter()100%210%
OpenDialog()0%620%
OpenReleaseDialog()0%620%
OpenStartDialog()0%620%
OpenFinalizeDialog()0%620%
GetNotFoundMessage()0%620%

File(s)

/home/runner/work/syki/syki/Front/Pages/Academic/AcademicClassesPage.razor

#LineLine coverage
 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>
 089                    <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.StickyNote2" OnClick="@(() => Action(
 90                </MudTd>
 91            </RowTemplate>
 92            <LoadingContent>
 093                @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;
 0120    private List<ClassOut> _classes = [];
 121    private Breakpoint _breakpoint;
 122
 123    protected override async Task OnInitializedAsync()
 124    {
 0125        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0126        _loading = true;
 0127        _classes = await GetAcademicClassesClient.Get();
 0128        _showReleaseButton = _classes.Any(c => c.Status == ClassStatus.OnPreEnrollment);
 0129        _showStartButton = _classes.Any(c => c.Status == ClassStatus.AwaitingStart);
 0130        _showFinalizeButton = _classes.Any(c => c.Status == ClassStatus.Started && c.Lessons.All(l => l.Status == Lesson
 0131        _loading = false;
 0132    }
 133
 134    private void Action(ClassOut item)
 135    {
 0136        Nav.NavigateTo($"/academic/classes/{item.Id}");
 0137    }
 138
 0139    private Func<ClassOut, bool> _quickFilter => x => _searchString.IsIn(x.Discipline, x.Teacher, x.Period, x.Status.Get
 140
 141    private async Task OpenDialog()
 142    {
 0143        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0144        var options = new DialogOptions {
 0145            MaxWidth = MaxWidth.Small,
 0146            FullWidth = true,
 0147            FullScreen = breakpoint == Breakpoint.Xs,
 0148        };
 0149        var dialog = await DialogService.ShowAsync<CreateClassDialog>("", options);
 150
 0151        var result = await dialog.Result;
 152
 0153        if (result!.Canceled) return;
 154
 0155        await OnInitializedAsync();
 0156    }
 157
 158    private async Task OpenReleaseDialog()
 159    {
 0160        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0161        var options = new DialogOptions {
 0162            FullWidth = true,
 0163            MaxWidth = MaxWidth.Medium,
 0164            FullScreen = breakpoint == Breakpoint.Xs,
 0165        };
 0166        var dialog = await DialogService.ShowAsync<ReleaseClassesForEnrollmentDialog>("", options);
 167
 0168        var result = await dialog.Result;
 169
 0170        if (result!.Canceled) return;
 171
 0172        await OnInitializedAsync();
 0173    }
 174
 175    private async Task OpenStartDialog()
 176    {
 0177        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0178        var options = new DialogOptions {
 0179            FullWidth = true,
 0180            MaxWidth = MaxWidth.Medium,
 0181            FullScreen = breakpoint == Breakpoint.Xs,
 0182        };
 0183        var dialog = await DialogService.ShowAsync<StartClassesDialog>("", options);
 184
 0185        var result = await dialog.Result;
 186
 0187        if (result!.Canceled) return;
 188
 0189        await OnInitializedAsync();
 0190    }
 191
 192    private async Task OpenFinalizeDialog()
 193    {
 0194        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0195        var options = new DialogOptions {
 0196            FullWidth = true,
 0197            MaxWidth = MaxWidth.Medium,
 0198            FullScreen = breakpoint == Breakpoint.Xs,
 0199        };
 0200        var dialog = await DialogService.ShowAsync<FinalizeClassesDialog>("", options);
 201
 0202        var result = await dialog.Result;
 203
 0204        if (result!.Canceled) return;
 205
 0206        await OnInitializedAsync();
 0207    }
 208
 209    private string GetNotFoundMessage()
 210    {
 0211        return (_searchString.IsEmpty()) ? "Não existem turmas cadastradas ainda." : "Nenhuma turma encontrada.";
 212    }
 213}