< Summary

Information
Class: Syki.Front.Pages.Academic.AcademicTeachersPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicTeachersPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 111
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/AcademicTeachersPage.razor

#LineLine coverage
 1@using Syki.Front.Features.Academic.CreateTeacher
 2
 3@namespace Syki.Front.Pages.Academic
 4
 5@page "/academic/teachers"
 6@attribute [Authorize(Roles = "Academic")]
 7
 8<SykiPageTitle Title="Professores" />
 9
 10<MudContainer Class="my-4 px-4">
 11    <SykiPageHeader Icon="@Icons.Material.Filled.Person4" Title="Professores" ButtonText="Novo Professor" OnClick="@Open
 12    <SykiPageAlert Text="Um professor pode lecionar várias disciplinas ao longo de um período, inclusive em mais de um c
 13    <MudContainer Class="px-0 mb-4">
 14        <MudTable
 15            Class="pa-4"
 16            Items="@_teachers"
 17            Filter="@_quickFilter"
 18            Hover="true"
 19            Loading="@_loading"
 20            Dense="true"
 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                <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext">
 30                    <MudTh></MudTh>
 31                </AuthorizeView>
 32            </HeaderContent>
 33            <RowTemplate>
 34                <MudTd DataLabel="Nome">@context.Name</MudTd>
 35                <MudTd DataLabel="Email">@context.Email</MudTd>
 36                <AuthorizeView Policy="@FrontPolicy.CrossLogin" Context="authContext">
 37                    <MudTd>
 038                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Login" OnClick="@(() => CrossLogi
 39                    </MudTd>
 40                </AuthorizeView>
 41            </RowTemplate>
 42            <LoadingContent>
 043                @if (_breakpoint == Breakpoint.Xs)
 44                {
 45                    <MudProgressLinear Color="Color.Info" Indeterminate="true" />
 46                }
 47            </LoadingContent>
 48            <NoRecordsContent>
 49                @(GetNotFoundMessage())
 50            </NoRecordsContent>
 51            <PagerContent>
 52                <SykiTablePager />
 53            </PagerContent>
 54        </MudTable>
 55    </MudContainer>
 56</MudContainer>
 57
 58@inject NavigationManager Nav
 59@inject IDialogService DialogService
 60@inject CrossLoginClient CrossLoginClient
 61@inject GetTeachersClient GetTeachersClient
 62@inject IBrowserViewportService BrowserViewportService
 63
 64@code
 65{
 66    private bool _loading;
 67    private string _searchString;
 068    private List<TeacherOut> _teachers = [];
 69
 70    private Breakpoint _breakpoint;
 71
 72    protected override async Task OnInitializedAsync()
 73    {
 074        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 075        _loading = true;
 076        _teachers = await GetTeachersClient.Get();
 077        _loading = false;
 078    }
 79
 80    private async Task CrossLogin(TeacherOut teacher)
 81    {
 082        _loading = true;
 083        await CrossLoginClient.Login(teacher.Id);
 084        Nav.NavigateTo("/", forceLoad: true);
 085        _loading = false;
 086    }
 87
 088    private Func<TeacherOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Email);
 89
 90    private async Task OpenDialog()
 91    {
 092        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 093        var options = new DialogOptions {
 094            MaxWidth = MaxWidth.Small,
 095            FullWidth = true,
 096            FullScreen = breakpoint == Breakpoint.Xs,
 097        };
 098        var dialog = await DialogService.ShowAsync<CreateTeacherDialog>("", options);
 99
 0100        var result = await dialog.Result;
 101
 0102        if (result!.Canceled) return;
 103
 0104        await OnInitializedAsync();
 0105    }
 106
 107    private string GetNotFoundMessage()
 108    {
 0109        return (_searchString.IsEmpty()) ? "Não existem professores cadastrados ainda." : "Nenhum professor encontrado."
 110    }
 111}