< Summary - Syki

Information
Class: Syki.Front.Pages.Academic.AcademicStudentsPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicStudentsPage.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 31
Coverable lines: 31
Total lines: 117
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>
 036                <MudTd DataLabel="Nome">@context.Name</MudTd>
 037                <MudTd DataLabel="Email">@context.Email</MudTd>
 038                <MudTd DataLabel="Matrícula">@context.EnrollmentCode</MudTd>
 039                <MudTd DataLabel="Curso">@context.CourseOffering</MudTd>
 40                <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext">
 41                    <MudTd>
 42                        <MudTooltip Text="Cross Login" Arrow="true" Placement="Placement.Top" ShowOnFocus="false">
 043                            <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Login" OnClick="@(() => Cross
 44                        </MudTooltip>
 45                    </MudTd>
 46                </AuthorizeView>
 47            </RowTemplate>
 48            <LoadingContent>
 049                @if (_breakpoint == Breakpoint.Xs)
 50                {
 51                    <MudProgressLinear Color="Color.Info" Indeterminate="true" />
 52                }
 53            </LoadingContent>
 54            <NoRecordsContent>
 055                @(GetNotFoundMessage())
 56            </NoRecordsContent>
 57            <PagerContent>
 58                <SykiTablePager />
 59            </PagerContent>
 60        </MudTable>
 61    </MudContainer>
 62</MudContainer>
 63
 64@inject NavigationManager Nav
 65@inject GetStudentsClient Client
 66@inject IDialogService DialogService
 67@inject CrossLoginClient CrossLoginClient
 68@inject IBrowserViewportService BrowserViewportService
 69
 70@code
 71{
 72    private bool _loading;
 73    private string _searchString;
 074    private List<StudentOut> _students = [];
 75
 76    private Breakpoint _breakpoint;
 77
 78    protected override async Task OnInitializedAsync()
 79    {
 080        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 081        _loading = true;
 082        _students = await Client.Get();
 083        _loading = false;
 084    }
 85
 86    private async Task CrossLogin(StudentOut student)
 87    {
 088        _loading = true;
 089        await CrossLoginClient.Login(student.Id);
 090        Nav.NavigateTo("/", forceLoad: true);
 091        _loading = false;
 092    }
 93
 094    private Func<StudentOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email, x.EnrollmentCode, x.CourseOf
 95
 96    private async Task OpenDialog()
 97    {
 098        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 099        var options = new DialogOptions {
 0100            MaxWidth = MaxWidth.Small,
 0101            FullWidth = true,
 0102            FullScreen = breakpoint == Breakpoint.Xs,
 0103        };
 0104        var dialog = await DialogService.ShowAsync<CreateStudentDialog>("", options);
 105
 0106        var result = await dialog.Result;
 107
 0108        if (result!.Canceled) return;
 109
 0110        await OnInitializedAsync();
 0111    }
 112
 113    private string GetNotFoundMessage()
 114    {
 0115        return (_searchString.IsEmpty()) ? "Não existem alunos cadastrados ainda." : "Nenhum aluno encontrado.";
 116    }
 117}