< Summary

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

File(s)

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

#LineLine coverage
 1@using Syki.Front.Features.Academic.CreateNotification
 2
 3@namespace Syki.Front.Pages.Academic
 4
 5@page "/academic/notifications"
 6@attribute [Authorize(Roles = "Academic")]
 7
 8<SykiPageTitle Title="Notificações" />
 9
 10<MudContainer Class="my-4 px-4">
 11    <SykiPageHeader Icon="@Icons.Material.Filled.Notifications" Title="Notificações" ButtonText="Nova Notificação" OnCli
 12    <SykiPageAlert Text="Aqui você pode escolher quais usuários serão notificados e acompanhar o status de visualização 
 13    <MudContainer Class="px-0 mb-4">
 14        <MudDataGrid
 15            T="NotificationOut"
 16            Class="pa-4"
 17            Items="@_notifications"
 18            QuickFilter="@_quickFilter"
 19            Dense="true"
 20            Hover="true"
 21            ReadOnly="true"
 22            Loading="@_loading"
 23            RowsPerPage="10"
 24            FooterClass="d-flex"
 25        >
 26            <ToolBarContent>
 27                <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por título ou descrição" /
 28            </ToolBarContent>
 29            <Columns>
 30                <PropertyColumn Property="x => x.Title" Title="Título" />
 31                <PropertyColumn Property="x => x.Description" Title="Descrição" />
 32                <PropertyColumn Property="x => x.CreatedAt.ToLocalTime().Format()" Title="Criada em" />
 33                <PropertyColumn Property="x => x.Target.GetDescription()" Title="Audiência" />
 34                <PropertyColumn Property="x => x.Views" Title="Visualizações" />
 35            </Columns>
 36            <NoRecordsContent>
 37                @(GetNotFoundMessage())
 38            </NoRecordsContent>
 39            <PagerContent>
 40                <SykiDataGridPager T="NotificationOut"/>
 41            </PagerContent>
 42        </MudDataGrid>
 43    </MudContainer>
 44</MudContainer>
 45
 46@inject IDialogService DialogService
 47@inject GetNotificationsClient GetNotificationsClient
 48@inject IBrowserViewportService BrowserViewportService
 49
 50@code
 51{
 52    private bool _loading;
 53    private string _searchString;
 054    private List<NotificationOut> _notifications = [];
 55
 56    protected override async Task OnInitializedAsync()
 57    {
 058        _loading = true;
 059        _notifications = await GetNotificationsClient.Get();
 060        _loading = false;
 061    }
 62
 63    private async Task OpenDialog()
 64    {
 065        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 066        var options = new DialogOptions {
 067            MaxWidth = MaxWidth.Small,
 068            FullWidth = true,
 069            FullScreen = breakpoint == Breakpoint.Xs,
 070        };
 071        var dialog = await DialogService.ShowAsync<CreateNotificationDialog>("", options);
 72
 073        var result = await dialog.Result;
 74
 075        if (result!.Canceled) return;
 76
 077        await OnInitializedAsync();
 078    }
 79
 080    private Func<NotificationOut, bool> _quickFilter => x => _searchString.IsIn(x.Title, x.Description);
 81
 82    private string GetNotFoundMessage()
 83    {
 084        return (_searchString.IsEmpty()) ? "Não existem notificações cadastradas ainda." : "Nenhuma notificação encontra
 85    }
 86}