diff --git a/BlazorServer/App.razor b/BlazorServer/App.razor index f9f62b3f..aee799e8 100644 --- a/BlazorServer/App.razor +++ b/BlazorServer/App.razor @@ -24,6 +24,7 @@ + diff --git a/Core/Session/IGrindSessionDAO.cs b/Core/Session/IGrindSessionDAO.cs index be532584..f260c068 100644 --- a/Core/Session/IGrindSessionDAO.cs +++ b/Core/Session/IGrindSessionDAO.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; +using System.Linq; namespace Core.Session; public interface IGrindSessionDAO { - IEnumerable Load(); + IQueryable Load(); void Save(GrindSession session); -} +} \ No newline at end of file diff --git a/Core/Session/LocalGrindSessionDAO.cs b/Core/Session/LocalGrindSessionDAO.cs index 492032d8..e2723c6b 100644 --- a/Core/Session/LocalGrindSessionDAO.cs +++ b/Core/Session/LocalGrindSessionDAO.cs @@ -21,14 +21,13 @@ public LocalGrindSessionDAO(DataConfig dataConfig) Directory.CreateDirectory(dataConfig.ExpHistory); } - public IEnumerable Load() + public IQueryable Load() { - List sessions = Directory.EnumerateFiles(dataConfig.ExpHistory, "*.json") + var sessions = Directory.EnumerateFiles(dataConfig.ExpHistory, "*.json") .Select(file => DeserializeObject(File.ReadAllText(file))!) - .OrderByDescending(grindingSession => grindingSession.SessionStart) - .ToList(); + .OrderByDescending(s => s.SessionStart); - if (sessions.Count != 0) + if (sessions.Any()) { int[] expList = ExperienceProvider.Get(dataConfig); foreach (GrindSession? s in sessions) @@ -37,7 +36,7 @@ public IEnumerable Load() } } - return sessions; + return sessions.AsQueryable(); } public void Save(GrindSession session) diff --git a/Frontend/DependencyInjection.cs b/Frontend/DependencyInjection.cs index e3b30f83..06302831 100644 --- a/Frontend/DependencyInjection.cs +++ b/Frontend/DependencyInjection.cs @@ -1,5 +1,4 @@ -using BlazorTable; -using MatBlazor; +using MatBlazor; using Microsoft.Extensions.DependencyInjection; @@ -16,8 +15,6 @@ public static IServiceCollection AddFrontend(this IServiceCollection services) services.AddRazorComponents() .AddInteractiveServerComponents(); - services.AddBlazorTable(); - return services; } } diff --git a/Frontend/Pages/History.razor b/Frontend/Pages/History.razor index 9fc3b50b..85b041c3 100644 --- a/Frontend/Pages/History.razor +++ b/Frontend/Pages/History.razor @@ -6,25 +6,40 @@ @if (Sessions.Any()) { - - - - - - - - - - - - - - -
+

+ Show: + +

+ + + + @if (showPath) + { + + + + + + } + + + + + + + + + + + + + + + } else { @@ -32,8 +47,35 @@ else } @code { - private readonly List pageSize = new() { 15, 25, 50, 100 }; - private IEnumerable Sessions = null!; + + PaginationState pagination = new PaginationState { ItemsPerPage = 15 }; + + private IQueryable Sessions = null!; + + private bool showPath = true; + + private string pathFilter = string.Empty; + private string classFilter = string.Empty; + + private IQueryable Filtered + { + get + { + var result = Sessions; + + if (!string.IsNullOrEmpty(pathFilter)) + { + result = result.Where(c => c.PathName.Contains(pathFilter, StringComparison.CurrentCultureIgnoreCase)); + } + + if (!string.IsNullOrEmpty(classFilter)) + { + result = result.Where(c => c.PlayerClass.ToStringF().Contains(classFilter, StringComparison.CurrentCultureIgnoreCase)); + } + + return result; + } + } protected override void OnInitialized() { diff --git a/Frontend/_Imports.razor b/Frontend/_Imports.razor index 8c7f7acf..3be432e6 100644 --- a/Frontend/_Imports.razor +++ b/Frontend/_Imports.razor @@ -13,5 +13,5 @@ @using SharedLib @using Core @using Game -@using BlazorTable +@using Microsoft.AspNetCore.Components.QuickGrid @using static Microsoft.AspNetCore.Components.Web.RenderMode \ No newline at end of file