diff --git a/src/Koogle.Application/DependencyInjection.cs b/src/Koogle.Application/DependencyInjection.cs index 4d6437f..fb9d3bc 100644 --- a/src/Koogle.Application/DependencyInjection.cs +++ b/src/Koogle.Application/DependencyInjection.cs @@ -42,6 +42,7 @@ namespace Koogle.Application // Note: Game types are registered in Koogle.Web where Blazor components are defined // Use services.AddGameType() to register game types + return services; } } diff --git a/src/Koogle.Web/Components/Pages/Days/DayDetails.razor b/src/Koogle.Web/Components/Pages/Days/DayDetails.razor index 6bf2b44..afa033e 100644 --- a/src/Koogle.Web/Components/Pages/Days/DayDetails.razor +++ b/src/Koogle.Web/Components/Pages/Days/DayDetails.razor @@ -103,15 +103,17 @@ else - + + - + + - + Teilnehmer (@Day.ParticipantCount) @if (Day.Status != DayStatus.Closed) @@ -164,7 +166,7 @@ else Size="Size.Small" Color="Color.Error" OnClick="@(() => RemoveParticipant(participant))" - OnClickStopPropagation="true" /> + OnClickStopPropagation="true"/> } @@ -182,77 +184,20 @@ else - + - - - - Details - - - - - - Status - - - @GetStatusLabel(Day.Status) - - - - - Datum - @Day.PostDate.ToString("dd.MM.yyyy") - - - Teilnehmer - @Day.ParticipantCount - - - Erstellt - @Day.CreatedAt.ToString("dd.MM.yyyy HH:mm") - - @if (Day.ModifiedAt.HasValue) - { - - Geändert - @Day.ModifiedAt.Value.ToString("dd.MM.yyyy HH:mm") - - } - - - - - - Status-Workflow - - - Neu - - - - Gestartet - - - - Abgeschlossen - - - + + + + - + Strafen / Kosten (@FilteredExpenses.Count@(_selectedParticipantId.HasValue && Expenses.Count != FilteredExpenses.Count ? $"/{Expenses.Count}" : "")) @if (Day.Status != DayStatus.Closed) @@ -292,7 +237,7 @@ else @if (DayState.Value.IsLoadingExpenses) { - + } @if (Day.Participants.Count == 0) @@ -388,7 +333,7 @@ else Size="Size.Small" Color="Color.Success" OnClick="@(() => MarkAsPaid(context))" - Title="Als bezahlt markieren" /> + Title="Als bezahlt markieren"/> } else { @@ -396,7 +341,7 @@ else Size="Size.Small" Color="Color.Warning" OnClick="@(() => MarkAsOpen(context))" - Title="Als offen markieren" /> + Title="Als offen markieren"/> } @if (Day.Status != DayStatus.Closed) { @@ -404,7 +349,7 @@ else Size="Size.Small" Color="Color.Error" OnClick="@(() => ConfirmDeleteExpense(context))" - Title="Löschen" /> + Title="Löschen"/> } @@ -413,10 +358,80 @@ else } - - - + + + + + + + + + + + + + Details + + + + + + Status + + + @GetStatusLabel(Day.Status) + + + + + Datum + @Day.PostDate.ToString("dd.MM.yyyy") + + + Teilnehmer + @Day.ParticipantCount + + + Erstellt + @Day.CreatedAt.ToString("dd.MM.yyyy HH:mm") + + @if (Day.ModifiedAt.HasValue) + { + + Geändert + @Day.ModifiedAt.Value.ToString("dd.MM.yyyy HH:mm") + + } + + + + + + Status-Workflow + + + Neu + + + + Gestartet + + + + Abgeschlossen + + + + + + diff --git a/src/Koogle.Web/Components/Shared/PlayerStatisticsChart.razor b/src/Koogle.Web/Components/Shared/PlayerStatisticsChart.razor new file mode 100644 index 0000000..e38f585 --- /dev/null +++ b/src/Koogle.Web/Components/Shared/PlayerStatisticsChart.razor @@ -0,0 +1,128 @@ +@using ApexCharts +@using Koogle.Application.DTOs +@using Koogle.Application.Interfaces +@using Color = MudBlazor.Color +@using Size = MudBlazor.Size + +@inject IPlayerStatisticsService StatisticsService +@inject ISnackbar Snackbar + + + + + Statistik + +@if (_isLoading) +{ + +} +else if (_stats != null) + { + @if (_stats.PlayerStats.Count == 0) + { + + Noch keine Statistiken vorhanden. Spiele ein paar Runden! + + } + else + { + + + + + + + + + + + + + + + } + } + + + +@code { + private List Data { get; set; } = new(); + + public class MyData + { + public string Name { get; set; } = string.Empty; + public int TotalPins { get; set; } + public int TotalGutters { get; set; } + public int TotalThrows { get; set; } + public int TotalStrikes { get; set; } + public int TotalCircles { get; set; } + public int TotalCleared { get; set; } + } + + + [Parameter, EditorRequired] + public Guid DayId { get; set; } + + private DayStatisticsDto? _stats; + private bool _isLoading = true; + + protected override async Task OnInitializedAsync() + { + try + { + _stats = await StatisticsService.GetDayStatisticsAsync(DayId); + Data.AddRange( + _stats.PlayerStats.Select(s => new MyData + { + Name = s.PersonName, + TotalPins = s.TotalPins, + TotalGutters = s.TotalGutters, + TotalThrows = s.TotalThrows, + TotalStrikes = s.TotalStrikes, + TotalCircles = s.TotalCircles, + TotalCleared = s.TotalCleared + }) + ); + } + catch (Exception ex) + { + Snackbar.Add($"Fehler beim Laden der Statistiken: {ex.Message}", Severity.Error); + } + finally + { + _isLoading = false; + } + } + +} diff --git a/src/Koogle.Web/Koogle.Web.csproj b/src/Koogle.Web/Koogle.Web.csproj index fd865e6..2782eb3 100644 --- a/src/Koogle.Web/Koogle.Web.csproj +++ b/src/Koogle.Web/Koogle.Web.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Koogle.Web/Program.cs b/src/Koogle.Web/Program.cs index 772643e..a49ec59 100644 --- a/src/Koogle.Web/Program.cs +++ b/src/Koogle.Web/Program.cs @@ -1,12 +1,13 @@ -using System.Reflection; +using ApexCharts; using Fluxor; using Fluxor.Blazor.Web.ReduxDevTools; using Koogle.Application; using Koogle.Application.Games; -using Koogle.Application.Games.Training; -using Koogle.Application.Games.Shit; using Koogle.Application.Games.DeathBox; +using Koogle.Application.Games.Shit; +using Koogle.Application.Games.Training; using Koogle.Infrastructure; +using Koogle.Infrastructure.Data; using Koogle.Infrastructure.Security; using Koogle.Web.Components; using Koogle.Web.Hubs; @@ -15,7 +16,7 @@ using Koogle.Web.Store.AuthState; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Server; using MudBlazor.Services; -using Koogle.Infrastructure.Data; +using System.Reflection; var builder = WebApplication.CreateBuilder(args); @@ -65,6 +66,18 @@ builder.Services.AddScoped(sp => builder.Services.AddMudServices(); + +// ApexCharts - https://github.com/apexcharts/Blazor-ApexCharts +builder.Services.AddApexCharts(e => +{ + e.GlobalOptions = new ApexChartBaseOptions + { + Debug = true, + Theme = new Theme { Palette = PaletteType.Palette6 } + }; +}); + + var app = builder.Build(); // Configure the HTTP request pipeline.