From 352a7dbfdef9d1d1e0f94afb36588a8c9ff16dca Mon Sep 17 00:00:00 2001 From: Penry Date: Tue, 24 Mar 2026 00:00:55 +0100 Subject: [PATCH] Made Create GlobalEntity to function and added MudCard for GlobalEntitys --- .../Dialogs/AddNewGlobalEntityDialog.razor | 2 +- .../Pages/GlobalList/GlobalList.razor | 61 ++++++++++++++++++- .../Pages/{ => PrivateList}/PrivateList.razor | 0 .../{ => PrivateList}/PrivateList.razor.css | 0 CouchLog/Program.cs | 6 +- 5 files changed, 64 insertions(+), 5 deletions(-) rename CouchLog/Components/Pages/{ => PrivateList}/PrivateList.razor (100%) rename CouchLog/Components/Pages/{ => PrivateList}/PrivateList.razor.css (100%) diff --git a/CouchLog/Components/Pages/GlobalList/Dialogs/AddNewGlobalEntityDialog.razor b/CouchLog/Components/Pages/GlobalList/Dialogs/AddNewGlobalEntityDialog.razor index ede80ed..6ea6f0c 100644 --- a/CouchLog/Components/Pages/GlobalList/Dialogs/AddNewGlobalEntityDialog.razor +++ b/CouchLog/Components/Pages/GlobalList/Dialogs/AddNewGlobalEntityDialog.razor @@ -276,4 +276,4 @@ _isSaving = false; } } -} +} \ No newline at end of file diff --git a/CouchLog/Components/Pages/GlobalList/GlobalList.razor b/CouchLog/Components/Pages/GlobalList/GlobalList.razor index 53927f2..41693ba 100644 --- a/CouchLog/Components/Pages/GlobalList/GlobalList.razor +++ b/CouchLog/Components/Pages/GlobalList/GlobalList.razor @@ -7,17 +7,18 @@ @using Microsoft.EntityFrameworkCore @using CouchLog.Components.Pages.GlobalList.Dialogs -@inject ApplicationDbContext CouchLogDB +@inject ApplicationDbContext CouchLogDb @inject UserManager UserManager @inject AuthenticationStateProvider AuthenticationStateProvider @inject NavigationManager NavigationManager @inject IDialogService DialogService +@inject ISnackbar Snackbar @attribute [Authorize] GlobalList - + @*Top of the Page*@ @@ -33,13 +34,67 @@ +
+ + + @foreach (var entity in _globalEntities) + { + if (!entity.IsPrivate || (entity.IsPrivate && (entity.CreatorId == _appUser?.Id))) + { + + + + + @entity.Title + + + + + + + + + + + + } + } + +
- @code { + private ApplicationUser? _appUser; + private List _globalEntities = []; + private HashSet _userPrivateEntityIds = []; + + protected override async Task OnInitializedAsync() + { + _globalEntities = await CouchLogDb.GlobalEntities.OrderByDescending(entity => entity.CreationTime).ToListAsync(); + + var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _appUser = await UserManager.GetUserAsync(authState.User); + + if (_appUser is null) + { + Snackbar.Add("Not authenticated.", Severity.Error); + return; + } + + _userPrivateEntityIds = await CouchLogDb.PrivateEntities + .Where(entity => entity.UserId == _appUser.Id) + .Select(p => p.GlobalEntityId) + .ToHashSetAsync(); + } + private async Task OpenAddNewGlobalEntityDialog() { var dialog = await DialogService.ShowAsync("Add new Global Entity"); } + + private async Task AddGlobalEntityToSharedList() + { + Snackbar.Add("Feature not implemented yet!", Severity.Error); + } } \ No newline at end of file diff --git a/CouchLog/Components/Pages/PrivateList.razor b/CouchLog/Components/Pages/PrivateList/PrivateList.razor similarity index 100% rename from CouchLog/Components/Pages/PrivateList.razor rename to CouchLog/Components/Pages/PrivateList/PrivateList.razor diff --git a/CouchLog/Components/Pages/PrivateList.razor.css b/CouchLog/Components/Pages/PrivateList/PrivateList.razor.css similarity index 100% rename from CouchLog/Components/Pages/PrivateList.razor.css rename to CouchLog/Components/Pages/PrivateList/PrivateList.razor.css diff --git a/CouchLog/Program.cs b/CouchLog/Program.cs index 8b3deec..0b0a80c 100644 --- a/CouchLog/Program.cs +++ b/CouchLog/Program.cs @@ -5,6 +5,7 @@ using CouchLog.Components; using CouchLog.Components.Account; using CouchLog.Data; using CouchLog; +using MudBlazor; using MudBlazor.Services; var builder = WebApplication.CreateBuilder(args); @@ -36,7 +37,10 @@ builder.Services.AddIdentityCore(options => options.SignIn.Requ .AddDefaultTokenProviders(); builder.Services.AddSingleton, IdentityNoOpEmailSender>(); -builder.Services.AddMudServices(); +builder.Services.AddMudServices(config => +{ + config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomCenter; +}); var app = builder.Build();