From 9c91d7656114b490702f69e4f1825e2fb2f70c8f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 27 Jul 2025 04:02:17 +0100 Subject: [PATCH] [Blazor] Implement home page. --- Directory.Packages.props | 99 ++++++++++--------- RomRepoMgr.Blazor/Components/Pages/Home.razor | 23 +++++ .../Components/Pages/Home.razor.cs | 46 +++++++++ RomRepoMgr.Blazor/Program.cs | 2 + RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj | 1 + 5 files changed, 122 insertions(+), 49 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 106b0af..435a962 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,53 +1,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RomRepoMgr.Blazor/Components/Pages/Home.razor b/RomRepoMgr.Blazor/Components/Pages/Home.razor index e1a94d0..a74fb28 100644 --- a/RomRepoMgr.Blazor/Components/Pages/Home.razor +++ b/RomRepoMgr.Blazor/Components/Pages/Home.razor @@ -1,6 +1,8 @@ @page "/" +@using RomRepoMgr.Database @rendermode InteractiveServer @inject IDialogService DialogService +@inject Context ctx ROM Repository Manager @@ -11,3 +13,24 @@ Import ROMs Export ROMs + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RomRepoMgr.Blazor/Components/Pages/Home.razor.cs b/RomRepoMgr.Blazor/Components/Pages/Home.razor.cs index 88d600b..a7a9fc6 100644 --- a/RomRepoMgr.Blazor/Components/Pages/Home.razor.cs +++ b/RomRepoMgr.Blazor/Components/Pages/Home.razor.cs @@ -1,13 +1,59 @@ using Microsoft.AspNetCore.Components; using Microsoft.FluentUI.AspNetCore.Components; using RomRepoMgr.Blazor.Components.Dialogs; +using RomRepoMgr.Core.Models; namespace RomRepoMgr.Blazor.Components.Pages; public partial class Home : ComponentBase { + readonly PaginationState pagination = new() + { + ItemsPerPage = 10 + }; + FluentDataGrid? romSetsGrid; + + public IQueryable? RomSets { get; set; } + async Task ImportDatsAsync() { IDialogReference dialog = await DialogService.ShowDialogAsync(new DialogParameters()); } + + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + romSetsGrid?.SetLoadingState(true); + + RomSets = ctx.RomSets.OrderBy(r => r.Name) + .ThenBy(r => r.Version) + .ThenBy(r => r.Date) + .ThenBy(r => r.Description) + .ThenBy(r => r.Comment) + .ThenBy(r => r.Filename) + .Select(r => new RomSetModel + { + Id = r.Id, + Author = r.Author, + Comment = r.Comment, + Date = r.Date, + Description = r.Description, + Filename = r.Filename, + Homepage = r.Homepage, + Name = r.Name, + Sha384 = r.Sha384, + Version = r.Version, + TotalMachines = r.Statistics.TotalMachines, + CompleteMachines = r.Statistics.CompleteMachines, + IncompleteMachines = r.Statistics.IncompleteMachines, + TotalRoms = r.Statistics.TotalRoms, + HaveRoms = r.Statistics.HaveRoms, + MissRoms = r.Statistics.MissRoms, + Category = r.Category + }); + + romSetsGrid?.SetLoadingState(false); + } } \ No newline at end of file diff --git a/RomRepoMgr.Blazor/Program.cs b/RomRepoMgr.Blazor/Program.cs index c2e42d5..ceefe18 100644 --- a/RomRepoMgr.Blazor/Program.cs +++ b/RomRepoMgr.Blazor/Program.cs @@ -70,6 +70,8 @@ builder.Services.AddDbContextFactory(options => #endif }); +builder.Services.AddDataGridEntityFrameworkAdapter(); + Log.Debug("Setting the settings..."); Settings.Current = new SetSettings diff --git a/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj b/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj index 32ee31d..54cf428 100644 --- a/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj +++ b/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj @@ -9,6 +9,7 @@ +