< Summary - Syki

Information
Class: Syki.Front.Pages.Student.StudentClassFrequenciesTab
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Student/StudentClassFrequenciesTab.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 59
Coverable lines: 59
Total lines: 136
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ClassId()100%210%
.ctor()100%210%
OnParametersSetAsync()100%210%
RenderChart()100%210%
GetTooltipIcon(...)0%7280%
GetTooltipIconColor(...)0%7280%

File(s)

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

#LineLine coverage
 1@using Syki.Front.Components.Summaries
 2
 3@namespace Syki.Front.Pages.Student
 4
 5<MudContainer Class="my-4 px-0">
 6    <MudGrid Spacing="2">
 7        <MudItem xs="12" sm="6" md="4" lg="4">
 8            <SummaryTextCard
 9                Loading="@_loading"
 10                Icon="@Icons.Material.Filled.CheckCircleOutline"
 11                Color="Color.Success"
 12                Text="@(_frequency.Presences == 1 ? "Presença" : "Presenças")"
 13                Value="@_frequency.Presences.ToThousandSeparated()"
 14            />
 15        </MudItem>
 16        <MudItem xs="12" sm="6" md="4" lg="4">
 17            <SummaryTextCard
 18                Loading="@_loading"
 19                Icon="@Icons.Material.Filled.Cancel"
 20                Color="Color.Error"
 21                Text="@(_frequency.Absences == 1 ? "Falta" : "Faltas")"
 22                Value="@_frequency.Absences.ToThousandSeparated()"/>
 23        </MudItem>
 24        <MudItem xs="12" sm="6" md="4" lg="4">
 25            <SummaryTextCard Loading="@_loading" Icon="@Icons.Material.Filled.BookmarkAdded" Color="Color.Info" Text="Au
 26        </MudItem>
 27    </MudGrid>
 28</MudContainer>
 29
 30<MudContainer Class="my-4 px-0">
 31    <MudPaper Class="px-4 pt-4">
 032        <ApexCharts.ApexChart @ref="@_chart" TItem="GetStudentClassLessonFrequencyOut" Options="@_options" Height="350">
 033            <ApexPointTooltip>
 034                <MudPaper Class="pa-4">
 035                    <MudStack Row="true" Class="mb-2" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
 036                        <MudText><b>@context.DataPoint.X.ToString().Split(" - ").First()</b></MudText>
 037                        <MudIcon
 38                            Icon="@GetTooltipIcon(context.DataPoint.Items.FirstOrDefault()?.Frequency)"
 39                            Color="@GetTooltipIconColor(context.DataPoint.Items.FirstOrDefault()?.Frequency)"
 40                            Class="mb-1" Size="Size.Medium" />
 41                    </MudStack>
 042                    <MudText>@context.DataPoint.X.ToString().Split(" - ").Last()</MudText>
 43                </MudPaper>
 44            </ApexPointTooltip>
 45            <ChildContent>
 46                <ApexCharts.ApexPointSeries
 47                    Name="Presente"
 48                    TItem="GetStudentClassLessonFrequencyOut"
 49                    Items="@_frequency.Lessons"
 50                    SeriesType="ApexCharts.SeriesType.Heatmap"
 051                    XValue="@(a => a.GetLesson())"
 052                    YValue="@(e => e.Frequency)"/>
 53            </ChildContent>
 54        </ApexCharts.ApexChart>
 55    </MudPaper>
 56</MudContainer>
 57
 58@inject NavigationManager Nav
 59@inject GetStudentClassFrequencyClient GetStudentClassFrequencyClient
 60
 61@code
 62{
 63  [Parameter]
 064  public Guid ClassId { get; set; }
 65
 66    private bool _loading;
 067    private GetStudentClassFrequencyOut _frequency = new();
 68
 69    protected override async Task OnParametersSetAsync()
 70    {
 071        _loading = true;
 072        _frequency = await GetStudentClassFrequencyClient.Get(ClassId);
 073        await RenderChart();
 074        _loading = false;
 075    }
 76
 77    private ApexCharts.ApexChart<GetStudentClassLessonFrequencyOut> _chart;
 078    private ApexCharts.ApexChartOptions<GetStudentClassLessonFrequencyOut> _options = new()
 079    {
 080        Colors = ["#87C0ED", "#21E7A4", "#F44336"],
 081        Tooltip = new ApexCharts.Tooltip { Enabled = true },
 082        Chart = new ApexCharts.Chart { Toolbar = new ApexCharts.Toolbar { Show = false } },
 083        Xaxis = new ApexCharts.XAxis
 084        {
 085            Tooltip = new ApexCharts.XAxisTooltip { Enabled = false },
 086            Labels = new ApexCharts.XAxisLabels
 087            {
 088                Formatter = @"function (value) {
 089                    if (value === undefined) {return '';}
 090                    return value.split(' - ')[0];
 091                }"
 092            }
 093        },
 094        Yaxis = [ new ApexCharts.YAxis { Labels = new ApexCharts.YAxisLabels { Show = false }, Tooltip = new ApexCharts.
 095        PlotOptions = new ApexCharts.PlotOptions
 096        {
 097            Heatmap = new ApexCharts.PlotOptionsHeatmap
 098            {
 099                EnableShades = true,
 0100                ColorScale = new ApexCharts.PlotOptionsHeatmapColorScale
 0101                {
 0102                    Ranges =
 0103                    [
 0104                        new() { Color = "#F44336", From = 0, To = 0 },
 0105                        new() { Color = "#87C0ED", From = 0.50, To = 0.50 },
 0106                        new() { Color = "#21E7A4", From = 1, To = 1 },
 0107                    ]
 0108                }
 0109            }
 0110        }
 0111    };
 112
 113    private async Task RenderChart()
 114    {
 0115        StateHasChanged();
 0116        await _chart.RenderAsync();
 0117    }
 118
 119    private string GetTooltipIcon(decimal? frequency)
 120    {
 0121        if (frequency is null or 0.50M) return Icons.Material.Filled.BookmarkAdded;
 122
 0123        if (frequency == 0) return Icons.Material.Filled.Cancel;
 124
 0125        return Icons.Material.Filled.CheckCircleOutline;
 126    }
 127
 128    private Color GetTooltipIconColor(decimal? frequency)
 129    {
 0130        if (frequency is null or 0.50M) return Color.Info;
 131
 0132        if (frequency == 0) return Color.Error;
 133
 0134        return Color.Success;
 135    }
 136}