< Summary - Syki

Information
Class: Syki.Front.Pages.Student.StudentFrequencyPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Student/StudentFrequencyPage.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 141
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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%
get__quickFilter()100%210%
OnInitializedAsync()0%620%
GetFrequency()100%210%
GetFrequencyColor(...)0%620%

File(s)

/home/runner/work/syki/syki/Front/Pages/Student/StudentFrequencyPage.razor

#LineLine coverage
 1@using Syki.Front.Components.Summaries
 2
 3@namespace Syki.Front.Pages.Student
 4
 5@page "/student/frequency"
 6@attribute [Authorize(Roles = "Student")]
 7
 8<SykiPageTitle Title="Frequência" />
 9
 10<MudContainer Class="my-4 px-4">
 11    <SykiPageHeader Icon="@Icons.Material.Filled.Class" Title="Frequência" />
 12
 13    <MudContainer Class="my-4 px-0">
 14        <MudGrid Spacing="2">
 15            <MudItem xs="12" sm="6" md="4" lg="4">
 16                <SummaryTextCard
 17                    Loading="@_loading"
 18                    Icon="@Icons.Material.Filled.CheckCircleOutline"
 19                    Color="Color.Success"
 20                    Text="@(_student.Presences == 1 ? "Presença" : "Presenças")"
 21                    Value="@_student.Presences.ToThousandSeparated()"
 22                />
 23            </MudItem>
 24            <MudItem xs="12" sm="6" md="4" lg="4">
 25                <SummaryTextCard
 26                    Loading="@_loading"
 27                    Icon="@Icons.Material.Filled.Cancel"
 28                    Color="Color.Error"
 29                    Text="@(_student.Absences == 1 ? "Falta" : "Faltas")"
 30                    Value="@_student.Absences.ToThousandSeparated()"/>
 31            </MudItem>
 32            <MudItem xs="12" sm="6" md="4" lg="4">
 33                <SummaryTextCard Loading="@_loading" Icon="@Icons.Material.Filled.BookmarkAdded" Color="Color.Info" Text
 34            </MudItem>
 35        </MudGrid>
 36    </MudContainer>
 37
 38    <MudContainer Class="px-0">
 39        <MudCard>
 40            <MudCardContent Class="px-6">
 041                @if (_loading)
 42                {
 43                    <MudProgressLinear Color="Color.Info" Indeterminate="true" />
 44                }
 45                else
 46                {
 47                    <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
 48                        <MudProgressLinear Color="@GetFrequencyColor(_student.Frequency)" Rounded="true" Size="Size.Larg
 49                            <MudText Typo="Typo.body1">
 050                                <b>@_student.Frequency.Format()%</b>
 51                            </MudText>
 52                        </MudProgressLinear>
 53                        <MudTooltip Text="Total de presenças durante todo o curso" Arrow="true" Placement="Placement.Bot
 54                            <MudIconButton Icon="@Icons.Material.Filled.Info" Size="Size.Small" />
 55                        </MudTooltip>
 56                    </MudStack>
 57                }
 58            </MudCardContent>
 59        </MudCard>
 60    </MudContainer>
 61    <MudContainer Class="px-0 my-4">
 62        <MudContainer Class="px-0 mb-4">
 63            <MudTable
 64                T="GetStudentFrequenciesOut"
 65                Items="@_frequencies"
 66                Class="pa-4"
 67                Breakpoint="Breakpoint.Sm"
 68                Dense="true"
 69                Hover="true"
 70                Filter="@_quickFilter"
 71                Loading="@_loading"
 72                RowsPerPage="100"
 73            >
 74                <ToolBarContent>
 75                    <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por disciplina"/>
 76                </ToolBarContent>
 77                <HeaderContent>
 78                    <MudTh>Disciplina</MudTh>
 79                    <MudTh>Período</MudTh>
 80                    <MudTh>Status</MudTh>
 81                    <MudTh>Aulas</MudTh>
 82                    <MudTh>Frequência</MudTh>
 83                </HeaderContent>
 84                <RowTemplate>
 085                    <MudTd DataLabel="Disciplina">@context.Name</MudTd>
 086                    <MudTd DataLabel="Período">@context.Period</MudTd>
 087                    <MudTd DataLabel="Status">@context.Status.GetDescription()</MudTd>
 088                    <MudTd DataLabel="Aulas">@context.GetFormated()</MudTd>
 89                    <MudTd DataLabel="Frequência">
 90                        <MudProgressLinear Color="@GetFrequencyColor(context.GetPercentage())" Rounded="true" Size="Size
 91                            <MudText Typo="Typo.body1">
 092                                <b>@context.GetPercentage().Format()%</b>
 93                            </MudText>
 94                        </MudProgressLinear>
 95                    </MudTd>
 96                </RowTemplate>
 97                <LoadingContent>
 098                    @if (_breakpoint == Breakpoint.Xs)
 99                    {
 100                        <MudProgressLinear Color="Color.Info" Indeterminate="true"/>
 101                    }
 102                </LoadingContent>
 103            </MudTable>
 104        </MudContainer>
 105    </MudContainer>
 106</MudContainer>
 107
 108@inject GetStudentFrequencyClient FrequencyClient
 109@inject GetStudentFrequenciesClient FrequenciesClient
 110@inject IBrowserViewportService BrowserViewportService
 111
 112@code
 113{
 114    private bool _loading;
 115    private string _searchString;
 116    private Breakpoint _breakpoint;
 0117    private GetStudentFrequencyOut _student = new();
 0118    private List<GetStudentFrequenciesOut> _frequencies = [];
 119
 0120    private Func<GetStudentFrequenciesOut, bool> _quickFilter => x => _searchString.IsIn(x.Name);
 121
 122    protected override async Task OnInitializedAsync()
 123    {
 0124        _loading = true;
 0125        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0126        _student = await FrequencyClient.Get();
 0127        var response = await FrequenciesClient.Get();
 0128        if (response.IsSuccess) _frequencies = response.Success;
 0129        _loading = false;
 0130    }
 131
 132    private string GetFrequency()
 133    {
 0134        return $"{_student.Presences} / {_student.Attendances}";
 135    }
 136
 137    private Color GetFrequencyColor(decimal frequency)
 138    {
 0139        return frequency >= 70 ? Color.Tertiary : Color.Error;
 140    }
 141}