From bf9d0082f19810941183c698f3263aded74e5eb6 Mon Sep 17 00:00:00 2001
From: Xian55 <367101+Xian55@users.noreply.github.com>
Date: Mon, 23 Dec 2024 08:20:04 +0100
Subject: [PATCH] Frontend: Replace BlazorTable with QuickGrid.
Frontend: Refactor History page to be suitable for QuickGrid
---
BlazorServer/App.razor | 1 +
Core/Session/IGrindSessionDAO.cs | 5 +-
Core/Session/LocalGrindSessionDAO.cs | 11 ++--
Frontend/DependencyInjection.cs | 5 +-
Frontend/Pages/History.razor | 84 +++++++++++++++++++++-------
Frontend/_Imports.razor | 2 +-
6 files changed, 74 insertions(+), 34 deletions(-)
diff --git a/BlazorServer/App.razor b/BlazorServer/App.razor
index f9f62b3fa..aee799e88 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 be5325849..f260c0680 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 492032d8b..e2723c6b5 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 e3b30f83c..063028312 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 9fc3b50b1..85b041c33 100644
--- a/Frontend/Pages/History.razor
+++ b/Frontend/Pages/History.razor
@@ -6,25 +6,40 @@
@if (Sessions.Any())
{
-
-
-
-
-
-
- @{
- @context.TotalTimeInMinutes minutes
- }
-
-
-
-
-
-
-
-
-
-
+
+ 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 8c7f7acf1..3be432e61 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