< Summary

Information
Class: Syki.Front.Pages.Academic.AcademicStudentsPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicStudentsPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 115
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%
CrossLogin()100%210%
get__quickFilter()100%210%
OpenDialog()0%620%
GetNotFoundMessage()0%620%

File(s)

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

#LineLine coverage
 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>
 042                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Login" OnClick="@(() => CrossLogi
 43                    </MudTd>
 44                </AuthorizeView>
 45            </RowTemplate>
 46            <LoadingContent>
 047                @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;
 072    private List<StudentOut> _students = [];
 73
 74    private Breakpoint _breakpoint;
 75
 76    protected override async Task OnInitializedAsync()
 77    {
 078        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 079        _loading = true;
 080        _students = await Client.Get();
 081        _loading = false;
 082    }
 83
 84    private async Task CrossLogin(StudentOut student)
 85    {
 086        _loading = true;
 087        await CrossLoginClient.Login(student.Id);
 088        Nav.NavigateTo("/", forceLoad: true);
 089        _loading = false;
 090    }
 91
 092    private Func<StudentOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email, x.EnrollmentCode, x.CourseOf
 93
 94    private async Task OpenDialog()
 95    {
 096        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 097        var options = new DialogOptions {
 098            MaxWidth = MaxWidth.Small,
 099            FullWidth = true,
 0100            FullScreen = breakpoint == Breakpoint.Xs,
 0101        };
 0102        var dialog = await DialogService.ShowAsync<CreateStudentDialog>("", options);
 103
 0104        var result = await dialog.Result;
 105
 0106        if (result!.Canceled) return;
 107
 0108        await OnInitializedAsync();
 0109    }
 110
 111    private string GetNotFoundMessage()
 112    {
 0113        return (_searchString.IsEmpty()) ? "Não existem alunos cadastrados ainda." : "Nenhum aluno encontrado.";
 114    }
 115}