< Summary - Syki

Information
Class: Syki.Front.Pages.Academic.AcademicCampiPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicCampiPage.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 33
Coverable lines: 33
Total lines: 114
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%
get__quickFilter()100%210%
OpenDialog()0%620%
OpenEditDialog()0%620%
GetNotFoundMessage()0%620%

File(s)

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

#LineLine coverage
 1@using Syki.Front.Features.Academic.GetCampi
 2@using Syki.Front.Features.Academic.CreateCampus
 3@using Syki.Front.Features.Academic.UpdateCampus
 4
 5@namespace Syki.Front.Pages.Academic
 6
 7@page "/academic/campi"
 8@attribute [Authorize(Roles = "Academic")]
 9
 10<SykiPageTitle Title="Campi" />
 11
 12<MudContainer Class="my-4 px-4">
 13    <SykiPageHeader Icon="@Icons.Material.Filled.GroupWork" Title="Campi" ButtonText="Novo Campus" OnClick="@OpenDialog"
 14    <SykiPageAlert Text="Sua instituição pode ser formada por vários campus." />
 15    <MudContainer Class="px-0 mb-4">
 16        <MudDataGrid
 17            T="CampusOut"
 18            Class="pa-4"
 19            Items="@_campi"
 20            QuickFilter="@_quickFilter"
 21            Dense="true"
 22            Hover="true"
 23            ReadOnly="true"
 24            Loading="@_loading"
 25            RowsPerPage="10"
 26        >
 27            <ToolBarContent>
 28                <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por nome, estado ou cidade
 29            </ToolBarContent>
 30            <Columns>
 31                <PropertyColumn Property="x => x.Name" Title="Nome" />
 32                <PropertyColumn Property="x => x.State" Title="Estado" />
 33                <PropertyColumn Property="x => x.City" Title="Cidade" />
 34                <PropertyColumn Property="x => x.Students.ToThousandSeparated()" Title="Alunos" />
 35                <PropertyColumn Property="x => x.Capacity.ToThousandSeparated()" Title="Capacidade" />
 36                <PropertyColumn Property="x => x.GetFillRate()" Title="Ocupação" />
 37                <PropertyColumn Property="x => x.Teachers.ToThousandSeparated()" Title="Professores" />
 38                <TemplateColumn CellClass="d-flex justify-end">
 39                    <CellTemplate>
 040                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Edit" OnClick="@(() => OpenEdit
 41                    </CellTemplate>
 42                </TemplateColumn>
 43            </Columns>
 44            <NoRecordsContent>
 045                @(GetNotFoundMessage())
 46            </NoRecordsContent>
 47            <PagerContent>
 48                <SykiDataGridPager T="@CampusOut" />
 49            </PagerContent>
 50        </MudDataGrid>
 51    </MudContainer>
 52</MudContainer>
 53
 54@inject GetCampiClient Client
 55@inject IDialogService DialogService
 56@inject IBrowserViewportService BrowserViewportService
 57
 58@code
 59{
 60    private bool _loading;
 61    private string _searchString;
 062    private List<CampusOut> _campi = [];
 63
 64    protected override async Task OnInitializedAsync()
 65    {
 066        _loading = true;
 067        _campi = await Client.Get();
 068        _loading = false;
 069    }
 70
 071    private Func<CampusOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.State.ToString(), x.City);
 72
 73    private async Task OpenDialog()
 74    {
 075        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 076        var options = new DialogOptions {
 077            MaxWidth = MaxWidth.Small,
 078            FullWidth = true,
 079            FullScreen = breakpoint == Breakpoint.Xs,
 080        };
 081        var dialog = await DialogService.ShowAsync<CreateCampusDialog>("", options);
 82
 083        var result = await dialog.Result;
 84
 085        if (result!.Canceled) return;
 86
 087        await OnInitializedAsync();
 088    }
 89
 90    private async Task OpenEditDialog(CampusOut item)
 91    {
 092        var parameters = new DialogParameters<UpdateCampusDialog>();
 093        parameters.Add(x => x.Campus, item);
 94
 095        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 096        var options = new DialogOptions {
 097            MaxWidth = MaxWidth.Small,
 098            FullWidth = true,
 099            FullScreen = breakpoint == Breakpoint.Xs,
 0100        };
 0101        var dialog = await DialogService.ShowAsync<UpdateCampusDialog>("", parameters, options);
 102
 0103        var result = await dialog.Result;
 104
 0105        if (result!.Canceled) return;
 106
 0107        await OnInitializedAsync();
 0108    }
 109
 110    private string GetNotFoundMessage()
 111    {
 0112        return (_searchString.IsEmpty()) ? "Não existem campus cadastrados ainda." : "Nenhum campus encontrado.";
 113    }
 114}