From d7a737daace299b839da0c444e2b0a5279224883 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 8 Dec 2025 02:26:42 +0100 Subject: [PATCH] Fixed some Issues and made PrivateList Ready for basic uses --- CouchLog/Components/Pages/GlobalList.razor | 1 + CouchLog/Components/Pages/PrivateList.razor | 279 +++++++++++++----- .../Components/Pages/PrivateList.razor.css | 61 ++++ CouchLog/CouchLog.csproj | 6 +- CouchLog/Data/ApplicationUser.cs | 3 +- CouchLog/Data/CouchLog.db | Bin 278528 -> 282624 bytes .../DatabaseModels/Private/UserWatchStatus.cs | 3 + CouchLog/OnStartUp.cs | 83 +++--- CouchLog/Program.cs | 5 +- ...d_f1e1a307-f81b-4404-b583-d64eb743a49f.jpg | Bin 0 -> 115857 bytes 10 files changed, 310 insertions(+), 131 deletions(-) create mode 100644 CouchLog/Components/Pages/PrivateList.razor.css create mode 100644 CouchLog/wwwroot/Pictures/Robin_Hood_f1e1a307-f81b-4404-b583-d64eb743a49f.jpg diff --git a/CouchLog/Components/Pages/GlobalList.razor b/CouchLog/Components/Pages/GlobalList.razor index 8d16ac8..050de7b 100644 --- a/CouchLog/Components/Pages/GlobalList.razor +++ b/CouchLog/Components/Pages/GlobalList.razor @@ -249,6 +249,7 @@ UserId = AppUser.Id, CreationTime = DateTime.Now, GlobalEntityId = GlobalEntity.Id, + UserWatchStatusId = 1, }; CouchLogDB.PrivateEntities.Add(PrivateEntity); diff --git a/CouchLog/Components/Pages/PrivateList.razor b/CouchLog/Components/Pages/PrivateList.razor index 4db2150..f18087e 100644 --- a/CouchLog/Components/Pages/PrivateList.razor +++ b/CouchLog/Components/Pages/PrivateList.razor @@ -1,99 +1,216 @@ @page "/PrivateList" +@rendermode InteractiveServer @using Microsoft.AspNetCore.Authorization +@using CouchLog.Data +@using Microsoft.AspNetCore.Identity +@using Microsoft.EntityFrameworkCore + +@inject ApplicationDbContext CouchLogDB +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager @attribute [Authorize] -PrivateList +Private List - +
+ @foreach (var Entity in PrivateEntities) + { + /* + Hier bleiben wir bei col-lg-6 (halbe Bildschirmbreite), + wie du es im roten Kasten wolltest. + */ +
+ +
+
+ + +
+ @if (!string.IsNullOrEmpty(Entity.GlobalEntity?.PicturePath)) { -
- - -
+ @Entity.GlobalEntity.Title } else { - Keine Tags verfügbar +
+ Kein Bild +
} -
" -
-
Status:
-
- - + + @foreach (var status in userWatchStatuses) + { + } -
+ + @if (Entity.GlobalEntity?.MediaType.Name == "Series") + { + + + + } + + + + +
+ +
+
+
+
+
+ + + - - Favorisieren - - - Bearbeiten -
- --> \ No newline at end of file + } + + + +@code +{ + private List PrivateEntities = new List(); + private List userWatchStatuses = new List(); + ApplicationUser? AppUser = new(); + + protected override async Task OnInitializedAsync() + { + var AuthState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + AppUser = await UserManager.GetUserAsync(AuthState.User); + + if (AppUser != null) + { + 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) + .ToListAsync(); + + userWatchStatuses = await CouchLogDB.UserWatchStatuses.OrderByDescending(Entity => Entity.Id).ToListAsync(); + } + } + + private async Task UpdateWatchStatus(PrivateEntity entity, object? newValue) + { + // Wir holen uns die gewählte ID aus dem Dropdown + if (int.TryParse(newValue?.ToString(), out int newId)) + { + // 1. ID im Objekt aktualisieren + entity.UserWatchStatusId = newId; + + // 2. Navigation Property aktualisieren (damit die UI nicht flackert) + // Wir suchen das passende Objekt aus der geladenen Liste + entity.UserWatchStatus = userWatchStatuses.FirstOrDefault(s => s.Id == newId); + + // 3. Ab in die Datenbank + await CouchLogDB.SaveChangesAsync(); + } + } + + private async Task UpdateSeason(PrivateEntity entity, object? newSeasonValue) + { + if(int.TryParse(newSeasonValue?.ToString(), out int newSeason)) + { + entity.Season = newSeason; + + 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(); + } + } +} \ No newline at end of file diff --git a/CouchLog/Components/Pages/PrivateList.razor.css b/CouchLog/Components/Pages/PrivateList.razor.css new file mode 100644 index 0000000..4fd9f29 --- /dev/null +++ b/CouchLog/Components/Pages/PrivateList.razor.css @@ -0,0 +1,61 @@ +/* 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; +} diff --git a/CouchLog/CouchLog.csproj b/CouchLog/CouchLog.csproj index c077a66..b7c7edc 100644 --- a/CouchLog/CouchLog.csproj +++ b/CouchLog/CouchLog.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -14,7 +14,10 @@ + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -25,7 +28,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - diff --git a/CouchLog/Data/ApplicationUser.cs b/CouchLog/Data/ApplicationUser.cs index b3b6180..7e603a9 100644 --- a/CouchLog/Data/ApplicationUser.cs +++ b/CouchLog/Data/ApplicationUser.cs @@ -12,7 +12,8 @@ namespace CouchLog.Data public virtual ICollection