From 226cc38bf72db17bd6c46fc50200582e1b6f134f Mon Sep 17 00:00:00 2001 From: Penry Date: Wed, 27 May 2026 19:31:22 +0200 Subject: [PATCH] Started with Private List for 0.1.0-beta version --- .../Pages/GlobalList/GlobalList.razor | 5 +- .../PrivateList/Components/EntityCard.razor | 10 + .../Pages/PrivateList/PrivateList.razor | 258 ++++-------------- .../Pages/PrivateList/PrivateList.razor.css | 61 ----- 4 files changed, 72 insertions(+), 262 deletions(-) create mode 100644 CouchLog/Components/Pages/PrivateList/Components/EntityCard.razor delete mode 100644 CouchLog/Components/Pages/PrivateList/PrivateList.razor.css diff --git a/CouchLog/Components/Pages/GlobalList/GlobalList.razor b/CouchLog/Components/Pages/GlobalList/GlobalList.razor index 4bcb4be..ded1ba3 100644 --- a/CouchLog/Components/Pages/GlobalList/GlobalList.razor +++ b/CouchLog/Components/Pages/GlobalList/GlobalList.razor @@ -1,7 +1,6 @@ @page "/GlobalList" @rendermode InteractiveServer -@using System.Security.Claims @using Microsoft.AspNetCore.Authorization @using CouchLog.Data @using Microsoft.AspNetCore.Identity @@ -11,17 +10,17 @@ @inject ApplicationDbContext CouchLogDb @inject UserManager UserManager @inject AuthenticationStateProvider AuthenticationStateProvider -@inject NavigationManager NavigationManager @inject IDialogService DialogService @inject ISnackbar Snackbar @attribute [Authorize] GlobalList - +@* TODO: Add Paging TODO: Add only reload for the pages TODO: Make Search work +*@ @*Top of the Page*@ diff --git a/CouchLog/Components/Pages/PrivateList/Components/EntityCard.razor b/CouchLog/Components/Pages/PrivateList/Components/EntityCard.razor new file mode 100644 index 0000000..7cecc62 --- /dev/null +++ b/CouchLog/Components/Pages/PrivateList/Components/EntityCard.razor @@ -0,0 +1,10 @@ +@using CouchLog.Data + + + @PrivateEntity.GlobalEntity.Title + + +@code +{ + [Parameter] public PrivateEntity PrivateEntity { get; set; } = null!; +} diff --git a/CouchLog/Components/Pages/PrivateList/PrivateList.razor b/CouchLog/Components/Pages/PrivateList/PrivateList.razor index 293e060..4422a10 100644 --- a/CouchLog/Components/Pages/PrivateList/PrivateList.razor +++ b/CouchLog/Components/Pages/PrivateList/PrivateList.razor @@ -1,6 +1,7 @@ @page "/PrivateList" @rendermode InteractiveServer +@using CouchLog.Components.Pages.PrivateList.Components @using Microsoft.AspNetCore.Authorization @using CouchLog.Data @using Microsoft.AspNetCore.Identity @@ -15,218 +16,79 @@ Private List -
- - - @if (ActiveWatchingEntities.Any()) - { -
-

Aktiv am Schauen

-
- @foreach (var entity in ActiveWatchingEntities) - { - @RenderEntityCard(entity) - } -
-
- } - - - @if (LibraryEntities.Any()) - { -
-

Bibliothek

-
- @foreach (var entity in LibraryEntities) - { - @RenderEntityCard(entity) - } -
-
- } - - @if (!PrivateEntities.Any()) - { -
-

Keine Einträge vorhanden.

-
- } -
+ + @*Top of the Page*@ + + + @*Page Title*@ + Private List + + + +
+ + + + + + + + + +
+ + + + @foreach (var privateEntity in ActiveWatchingEntities) + { + + } + @foreach (var privateEntity in LibraryEntities) + { + + } + + +
@code { - private List PrivateEntities = new List(); - private List userWatchStatuses = new List(); - ApplicationUser? AppUser = new(); + //Search + private string _searchString; + + //User + private ApplicationUser? _appUser; + + //Entities + private List _privateEntities = []; + private List _userWatchStatuses = []; - private List ActiveWatchingEntities => PrivateEntities.Where(x => x.UserWatchStatus?.Name == "Watching").ToList(); - private List LibraryEntities => PrivateEntities.Where(x => x.UserWatchStatus?.Name != "Watching").ToList(); + private List ActiveWatchingEntities => _privateEntities.Where(x => x.UserWatchStatus?.Name == "Watching").ToList(); + private List LibraryEntities => _privateEntities.Where(x => x.UserWatchStatus?.Name != "Watching").ToList(); protected override async Task OnInitializedAsync() { - var AuthState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - AppUser = await UserManager.GetUserAsync(AuthState.User); + var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _appUser = await UserManager.GetUserAsync(authState.User); - if (AppUser != null) + if (_appUser != null) { - PrivateEntities = await CouchLogDB.PrivateEntities - .Where(x => x.UserId == AppUser.Id) + _privateEntities = await CouchLogDB.PrivateEntities + .Where(x => x.UserId == _appUser.Id) .Include(x => x.GlobalEntity) .Include(x => x.UserWatchStatus) .Include(x => x.GlobalEntity.MediaType) - .OrderByDescending(Entity => Entity.LastChange ?? Entity.CreationTime) + .OrderByDescending(entity => entity.LastChange ?? entity.CreationTime) .ToListAsync(); - userWatchStatuses = await CouchLogDB.UserWatchStatuses.OrderByDescending(Entity => Entity.Id).ToListAsync(); - } - } - - private RenderFragment RenderEntityCard(PrivateEntity Entity) => __builder => - { -
-
-
- -
- @if (!string.IsNullOrEmpty(Entity.GlobalEntity?.PicturePath)) - { - @Entity.GlobalEntity.Title - } - else - { -
- Kein Bild -
- } -
- - -
-
- - -
-
-
- @Entity.GlobalEntity?.Title -
- - @Entity.CreationTime.ToShortDateString() - -
- - -
- - - - - @if (Entity.GlobalEntity?.MediaType.Name == "Series" || Entity.GlobalEntity?.MediaType.Name == "Anime") - { - - - - } - - -
- -
-
-
-
-
- - - -
- }; - - private async Task RemoveEntityFromPrivateList(PrivateEntity entity) - { - //Delete DB - CouchLogDB.PrivateEntities.Remove(entity); - await CouchLogDB.SaveChangesAsync(); - - //Delete Memory List - PrivateEntities.Remove(entity); - } - - private async Task UpdateWatchStatus(PrivateEntity entity, object? newValue) - { - if (int.TryParse(newValue?.ToString(), out int newId)) - { - entity.UserWatchStatusId = newId; - entity.UserWatchStatus = userWatchStatuses.FirstOrDefault(s => s.Id == newId); - await CouchLogDB.SaveChangesAsync(); - } - } - - private async Task UpdateSeason(PrivateEntity entity, object? newSeasonValue) - { - if (int.TryParse(newSeasonValue?.ToString(), out int newSeason)) - { - entity.Season = newSeason; - entity.Episode = 1; - await CouchLogDB.SaveChangesAsync(); - } - } - - private async Task UpdateEpisode(PrivateEntity entity, object? newEpisodeValue) - { - if (int.TryParse(newEpisodeValue?.ToString(), out int newEpisode)) - { - entity.Episode = newEpisode; - await CouchLogDB.SaveChangesAsync(); + _userWatchStatuses = await CouchLogDB.UserWatchStatuses.OrderByDescending(entity => entity.Id).ToListAsync(); } } } \ No newline at end of file diff --git a/CouchLog/Components/Pages/PrivateList/PrivateList.razor.css b/CouchLog/Components/Pages/PrivateList/PrivateList.razor.css deleted file mode 100644 index 4fd9f29..0000000 --- a/CouchLog/Components/Pages/PrivateList/PrivateList.razor.css +++ /dev/null @@ -1,61 +0,0 @@ -/* PrivateList.razor.css */ - -.private-entity-card { - height: 220px; - background-color: #fff; - transition: transform 0.2s ease, box-shadow 0.2s ease; -} - - .private-entity-card:hover { - transform: translateY(-3px); - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } - -/* - NEU: Feste Breite für das Bild! - 150px Breite bei 220px Höhe passt perfekt für Poster. -*/ -.img-wrapper { - width: 150px; - background-color: #f0f2f5; - position: relative; -} - -/* Bild füllt den Wrapper komplett aus */ -.entity-img { - object-fit: cover; - width: 100%; - height: 100%; - /* Positioniert das Bild oben, falls das Format doch leicht abweicht (Köpfe/Titel sind meist oben) */ - object-position: top center; -} - -.text-truncate-multiline { - display: -webkit-box; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; - overflow: hidden; - line-height: 1.2; -} - -.meta-text { - font-size: 0.75rem; - white-space: nowrap; -} - -.menu-btn { - color: #212529; - text-decoration: none; - font-size: 1.2rem; - line-height: 1; - padding: 0 0.25rem; -} - - .menu-btn:hover { - color: #000; - } - -.btn-details { - font-size: 0.7rem; - padding: 0.2rem 0.6rem; -}