< Summary

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

File(s)

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

#LineLine coverage
 1@using Syki.Front.Features.Academic.CreateCourse
 2
 3@namespace Syki.Front.Pages.Academic
 4
 5@page "/academic/courses"
 6@attribute [Authorize(Roles = "Academic")]
 7
 8<SykiPageTitle Title="Cursos" />
 9
 10<MudContainer Class="my-4 px-4">
 11    <SykiPageHeader Icon="@Icons.Material.Filled.Class" Title="Cursos" ButtonText="Novo Curso" OnClick="@OpenDialog"/>
 12    <SykiPageAlert Text="Note que um mesmo curso pode ser ofertado em mais de um campus." />
 13    <MudContainer Class="px-0 mb-4">
 14        <MudDataGrid
 15            Class="pa-4"
 16            Items="@_courses"
 17            QuickFilter="@_quickFilter"
 18            Hover="true"
 19            Dense="true"
 20            Loading="@_loading"
 21            RowsPerPage="10"
 22        >
 23            <ToolBarContent>
 24                <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por nome ou tipo" />
 25            </ToolBarContent>
 26            <Columns>
 27                <PropertyColumn Property="x => x.Name" Title="Nome" />
 28                <PropertyColumn Property="x => x.Type.GetDescription()" Title="Tipo" />
 29            </Columns>
 30            <NoRecordsContent>
 31                @(GetNotFoundMessage())
 32            </NoRecordsContent>
 33            <PagerContent>
 34                <SykiDataGridPager T="CourseOut" />
 35            </PagerContent>
 36        </MudDataGrid>
 37    </MudContainer>
 38</MudContainer>
 39
 40@inject GetCoursesClient Client
 41@inject IDialogService DialogService
 42@inject IBrowserViewportService BrowserViewportService
 43
 44@code
 45{
 46    private bool _loading;
 47    private string _searchString;
 048    private List<CourseOut> _courses = [];
 49
 50    protected override async Task OnInitializedAsync()
 51    {
 052        _loading = true;
 053        _courses = await Client.Get() ?? [];
 054        _loading = false;
 055    }
 56
 057    private Func<CourseOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Type.GetDescription());
 58
 59    private async Task OpenDialog()
 60    {
 061        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 062        var options = new DialogOptions {
 063            MaxWidth = MaxWidth.Small,
 064            FullWidth = true,
 065            FullScreen = breakpoint == Breakpoint.Xs,
 066        };
 067        var dialog = await DialogService.ShowAsync<CreateCourseDialog>("", options);
 68
 069        var result = await dialog.Result;
 70
 071        if (result!.Canceled) return;
 72
 073        await OnInitializedAsync();
 074    }
 75
 76    private string GetNotFoundMessage()
 77    {
 078        return (_searchString.IsEmpty()) ? "Não existem cursos cadastrados ainda." : "Nenhum curso encontrado.";
 79    }
 80}