mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
[Blazor] Implement home page.
This commit is contained in:
@@ -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"/>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,8 @@ builder.Services.AddDbContextFactory<Context>(options =>
|
||||
#endif
|
||||
});
|
||||
|
||||
builder.Services.AddDataGridEntityFrameworkAdapter();
|
||||
|
||||
Log.Debug("Setting the settings...");
|
||||
|
||||
Settings.Current = new SetSettings
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user