[Blazor] Implement home page.

This commit is contained in:
2025-07-27 04:02:17 +01:00
parent cf7186adbb
commit 9c91d76561
5 changed files with 122 additions and 49 deletions

View File

@@ -1,6 +1,8 @@
@page "/"
@using RomRepoMgr.Database
@rendermode InteractiveServer
@inject IDialogService DialogService
@inject Context ctx
<PageTitle>ROM Repository Manager</PageTitle>
@@ -11,3 +13,24 @@
<FluentButton Disabled="true">Import ROMs</FluentButton>
<FluentButton Disabled="true">Export ROMs</FluentButton>
</FluentToolbar>
<FluentDataGrid @ref="romSetsGrid" Items="@RomSets" Style="width: 100%;" AutoFit="true" Pagination="@pagination"
AutoItemsPerPage="true" ResizableColumns="true">
<PropertyColumn Property="@(p => p.Name)" Title="Name"/>
<PropertyColumn Property="@(p => p.Version)" Title="Version"/>
<PropertyColumn Property="@(p => p.Author)" Title="Author"/>
<PropertyColumn Property="@(p => p.Category)" Title="Category"/>
<PropertyColumn Property="@(p => p.Date)" Title="Date"/>
<PropertyColumn Property="@(p => p.Description)" Title="Description"/>
<PropertyColumn Property="@(p => p.Comment)" Title="Comment"/>
<PropertyColumn Property="@(p => p.Homepage)" Title="Homepage"/>
<PropertyColumn Property="@(p => p.TotalMachines)" Title="Total machines"/>
<PropertyColumn Property="@(p => p.CompleteMachines)" Title="Complete machines"/>
<PropertyColumn Property="@(p => p.IncompleteMachines)" Title="Incomplete machines"/>
<PropertyColumn Property="@(p => p.TotalRoms)" Title="Total ROMs"/>
<PropertyColumn Property="@(p => p.HaveRoms)" Title="Have ROMs"/>
<PropertyColumn Property="@(p => p.MissRoms)" Title="Miss ROMs"/>
</FluentDataGrid>
<FluentPaginator State="@pagination"/>

View File

@@ -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<RomSetModel>? romSetsGrid;
public IQueryable<RomSetModel>? RomSets { get; set; }
async Task ImportDatsAsync()
{
IDialogReference dialog = await DialogService.ShowDialogAsync<ImportDats>(new DialogParameters());
}
/// <inheritdoc />
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);
}
}

View File

@@ -70,6 +70,8 @@ builder.Services.AddDbContextFactory<Context>(options =>
#endif
});
builder.Services.AddDataGridEntityFrameworkAdapter();
Log.Debug("Setting the settings...");
Settings.Current = new SetSettings

View File

@@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite"/>
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components"/>
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.DataGrid.EntityFrameworkAdapter"/>
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons"/>
<PackageReference Include="Serilog"/>
<PackageReference Include="Serilog.AspNetCore"/>