From 59f5d70f0918cd23cc4378331a8e96b8d573cd46 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 19 Feb 2025 14:31:39 +0100 Subject: [PATCH] F: season page, addd more episodes view modes + various fixes --- backend/services/configService.js | 16 +- .../app/core/services/episode-seen.service.ts | 12 +- .../entry/entry-page/entry-page.component.css | 9 + .../entry-page/entry-page.component.html | 2 +- .../season-main-card.component.css | 1 + .../season-main-card.component.html | 2 +- .../season-main-card.component.ts | 4 +- .../season-page/season-page.component.css | 265 ++++++++++++++---- .../season-page/season-page.component.html | 162 +++++++---- .../season-page/season-page.component.ts | 95 ++++++- .../modals/seen-modal/seen-modal.component.ts | 36 +-- .../src/app/shared/models/episode.models.ts | 9 +- .../src/app/shared/models/settings.model.ts | 1 + 13 files changed, 467 insertions(+), 147 deletions(-) diff --git a/backend/services/configService.js b/backend/services/configService.js index f82c44b..caf50f0 100644 --- a/backend/services/configService.js +++ b/backend/services/configService.js @@ -9,11 +9,12 @@ const defaultSettings = { backPort: '', portableMode: '', - libraryViewMode: '', - favoritViewMode: '', - watchlistViewMode: '', - CollectionsViewMode: '', - CollectionItemsViewMode: '', + libraryViewMode: 'grid', + favoritViewMode: 'grid', + watchlistViewMode: 'grid', + CollectionsViewMode: 'grid', + CollectionItemsViewMode: 'grid', + episodesViewMode: 'grid' }; class ConfigService { @@ -39,7 +40,8 @@ class ConfigService { try { const settingsData = fs.readFileSync(settingsFilePath); // console.log(`Loaded settings file.`); - return JSON.parse(settingsData); + const parsedSettings = JSON.parse(settingsData); + return { ...defaultSettings, ...parsedSettings }; } catch (err) { console.error('Error reading settings file:', err); console.log('Creating default settings file...'); @@ -96,7 +98,7 @@ class ConfigService { getTmdbApiKey() { return this.settings.tmdbApiKey; } - + } // const instance = new ConfigService(); diff --git a/frontend/src/app/core/services/episode-seen.service.ts b/frontend/src/app/core/services/episode-seen.service.ts index 1c979d6..2f56860 100644 --- a/frontend/src/app/core/services/episode-seen.service.ts +++ b/frontend/src/app/core/services/episode-seen.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EpisodeSeen } from '../../shared/models/episode-seen.model'; -import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto'; +import { EpisodeSeenCreateDto } from '../../shared/models/dtos/episode-seen.dto'; import { ConfigService } from './config.service'; @Injectable({ @@ -33,25 +33,25 @@ export class EpisodeSeenService { } getEpisodeSeenByEntryId(entryId: number) { - return this.http.get( + return this.http.get( `${this.backend_apiUrl}/${this.apiAction}/by-entry/${entryId}` ); } getEpisodeSeenBySeasonId(entryId: number) { - return this.http.get( + return this.http.get( `${this.backend_apiUrl}/${this.apiAction}/by-season/${entryId}` ); } - // get episode-seen by episode Id + // get episode-seen by Id getEpisodeSeenById(id: number) { - return this.http.get( + return this.http.get( `${this.backend_apiUrl}/${this.apiAction}/${id}` ); } - updateEpisodeSeen(episodeSeen: EpisodeSeenDto) { + updateEpisodeSeen(episodeSeen: EpisodeSeenCreateDto) { return this.http.put( `${this.backend_apiUrl}/${this.apiAction}/${episodeSeen.id}`, { diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.css b/frontend/src/app/features/entry/entry-page/entry-page.component.css index 61b9c15..54bc373 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.css +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.css @@ -39,6 +39,7 @@ h3 { color: var(--text-color); } + .content-wrapper { position: relative; margin-top: 2rem; @@ -90,6 +91,14 @@ h3 { margin-bottom: 0; } +.less-more { + cursor: pointer; +} + +.less-more:hover { + color: var(--shz-blue-default); +} + .entry-actions .btn-icon-only-success { width: 40px; height: 40px; diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.html b/frontend/src/app/features/entry/entry-page/entry-page.component.html index d2974bb..be8887e 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.html +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.html @@ -155,7 +155,7 @@ (episodeWatchedDeletedEvent)="triggerEpisodeWatchedDeletedEvent()"> -

{{ showAll ? 'Show Less' : 'Show All' }}

diff --git a/frontend/src/app/features/entry/season-main-card/season-main-card.component.css b/frontend/src/app/features/entry/season-main-card/season-main-card.component.css index a0b2cae..bab59b2 100644 --- a/frontend/src/app/features/entry/season-main-card/season-main-card.component.css +++ b/frontend/src/app/features/entry/season-main-card/season-main-card.component.css @@ -115,6 +115,7 @@ margin: 0 5px 3px 0; font-size: 1.5rem; } + .btn-icon-only:hover { color: #fc185a; } \ No newline at end of file diff --git a/frontend/src/app/features/entry/season-main-card/season-main-card.component.html b/frontend/src/app/features/entry/season-main-card/season-main-card.component.html index b47ae2f..32779bc 100644 --- a/frontend/src/app/features/entry/season-main-card/season-main-card.component.html +++ b/frontend/src/app/features/entry/season-main-card/season-main-card.component.html @@ -14,7 +14,7 @@ diff --git a/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts b/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts index 21bdfdc..8d11761 100644 --- a/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts +++ b/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts @@ -82,7 +82,9 @@ export class SeasonMainCardComponent implements OnInit { return count; } - async episodeMarkSeenClick() { + async episodeMarkSeenClick(event: Event) { + event.stopPropagation(); + if (this.lockActions) return; this.lockActions = true; diff --git a/frontend/src/app/features/entry/season-page/season-page.component.css b/frontend/src/app/features/entry/season-page/season-page.component.css index 6b7d973..49f85f2 100644 --- a/frontend/src/app/features/entry/season-page/season-page.component.css +++ b/frontend/src/app/features/entry/season-page/season-page.component.css @@ -98,17 +98,33 @@ border-color: #007bff; } +.episode-metadata .card-text { + margin-bottom: 0; + padding-top: 10; +} + +/* ! List View */ .episode-cards .card { border-radius: 10px; overflow: hidden; border: none; - box-shadow: 0 2px 4px var(--shadow-color); background: var(--card-bg); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); color: var(--text-color); } +.episode-cards .card-body { + display: flex; + flex-direction: column; + height: 100%; +} + +.episode-cards .episode-metadata { + border-top: 1px solid var(--border-color); + margin-top: auto; +} + .episode-cards .card-title { font-size: 1.1rem; font-weight: 600; @@ -116,10 +132,24 @@ color: var(--text-color); } +.card-title { + cursor: pointer; +} + .episode-image-container { height: 180px; overflow: hidden; padding: 0; + cursor: pointer; +} + + +.episode-image-container img { + transition: transform 0.3s ease; +} + +.episode-image-container img:hover { + transform: scale(1.2); } .episode-still { @@ -128,6 +158,107 @@ object-fit: cover; } +/* ! Grid View */ +.episode-cards-grid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 1rem; + padding: 1rem; +} + +.episode-cards-grid .card { + display: flex; + flex-direction: column; + /* height: 100%; */ + border-radius: 10px; + overflow: hidden; + border: none; + box-shadow: 0 2px 4px var(--shadow-color); + background: var(--card-bg); +} + +.episode-cards-grid .episode-image-container { + height: 200px; +} + +.episode-cards-grid .card-body { + display: flex; + flex-direction: column; + padding: 1rem; +} + +.episode-cards-grid .episode-metadata { + padding-top: 0.5rem; + margin-top: auto; + border-top: 1px solid var(--border-color); +} + +/* ! Grid-2 View */ +.episode-cards-grid-2 { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 1rem; + padding: 1rem; +} + +.episode-cards-grid-2 .card { + position: relative; + border-radius: 10px; + overflow: hidden; + border: none; + box-shadow: 0 2px 4px var(--shadow-color); + aspect-ratio: 16/9; +} + +.episode-cards-grid-2 .episode-image-container { + height: 100%; + width: 100%; +} + +.episode-cards-grid-2 .episode-still { + transition: transform 0.3s ease; +} + +.episode-cards-grid-2 .card-overlay { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: column; + padding: 1rem; + opacity: 0; + transition: opacity 0.3s ease; +} + +.episode-cards-grid-2 .card:hover .card-overlay { + opacity: 1; +} + +.episode-cards-grid-2 .card:hover .episode-still { + transform: scale(1.1); +} + +.episode-cards-grid-2 .card-title { + color: white; + font-size: 1rem; + margin-bottom: 0.5rem; +} + +.episode-cards-grid-2 .episode-metadata { + margin-top: auto; +} + +.episode-cards-grid-2 .episode-metadata small { + color: rgba(255, 255, 255, 0.7); + display: block; + font-size: 0.8rem; + line-height: 1.2; +} + +/* Common Elements */ .btn-icon-only-success { width: 40px; height: 40px; @@ -149,15 +280,6 @@ color: #007bff; } -.watch-history-section { - /* background: var(--card-bg); */ - /* backdrop-filter: blur(5px); */ - /* -webkit-backdrop-filter: blur(5px); */ - border-radius: 10px; - /* padding: 20px; */ - color: var(--text-color); -} - .material-symbols-outlined { font-size: 20px; line-height: 1; @@ -182,66 +304,93 @@ color: var(--text-muted) !important; } -.table { - margin-bottom: 0; - color: var(--text-color); - background-color: var(--bg-color-secondary); +.btn-mark { + background: var(--card-bg); + opacity: var(--bg-opacity-secondary); } -.table th { - border-top: none; - color: var(--text-color); - background-color: var(--bg-color-secondary); +/* View Mode Switcher */ +.view-mode-switcher { + display: flex; + gap: 0.5rem; } -.table td { +.view-mode-switcher .btn-icon-only { + padding: 0.5rem; + border: 1px solid var(--border-color); + border-radius: 5px; + background: transparent; color: var(--text-color); - border-color: var(--border-color); - background-color: var(--bg-color-secondary); + display: flex; align-items: center; - align-content: center; - padding: 5px; + justify-content: center; } -.btn-outline-primary { - color: var(--text-color); - border-color: var(--border-color); +.view-mode-switcher .btn-icon-only.active { + background: var(--primary-color); + color: white; + border-color: var(--primary-color); } -.btn-outline-primary:hover { - background-color: var(--hover-bg); - border-color: #007bff; +.view-mode-switcher .btn-icon-only:hover { + background: var(--primary-color); + color: white; + border-color: var(--primary-color); +} + +/* ! Description Toggle */ +.episode-description { + display: -webkit-box; + /* Treat the element as a block box */ + -webkit-box-orient: vertical; + /* Vertical layout for lines */ + -webkit-line-clamp: 3; + /* Limit to 2 lines */ + overflow: hidden; + /* Hide overflowing content */ + text-overflow: ellipsis; + /* Add ellipsis (...) */ + font-size: 14px; + /* Set your desired font size */ + line-height: 1.5; + /* Adjust line height as needed */ + max-height: calc(1.5 * 3 * 1em); + /* Ensure max-height matches two lines */ +} + +.episode-description.expanded { + max-height: none; +} + +.episode-description:not(.expanded)::after { + position: absolute; + bottom: 0; + right: 0; + width: 100%; + height: 1.5em; +} + +.show-more-less { color: #007bff; + text-decoration: none; + cursor: pointer; + display: inline; + margin-left: 0.25em; } -.btn-outline-secondary { - color: var(--text-color); - border-color: var(--border-color); -} - -.btn-outline-secondary:hover { - background-color: var(--hover-bg); - border-color: var(--text-muted); - color: var(--text-muted); -} - -.btn-link { - color: var(--text-color); -} - -.btn-link:hover { - color: #007bff; -} - -.btn-link.text-danger { - color: #dc3545 !important; -} - -.btn-link.text-danger:hover { - color: #bd2130 !important; +.show-more-less:hover { + text-decoration: underline; } @media (max-width: 768px) { + .episode-cards-grid { + grid-template-columns: repeat(2, 1fr); + } + + .episode-cards-grid-2 { + grid-template-columns: repeat(2, 1fr); + } + .episode-image-container { height: 200px; } @@ -250,4 +399,12 @@ margin-top: 1rem; padding: 15px; } +} + +@media (max-width: 576px) { + + .episode-cards-grid, + .episode-cards-grid-2 { + grid-template-columns: 1fr; + } } \ No newline at end of file diff --git a/frontend/src/app/features/entry/season-page/season-page.component.html b/frontend/src/app/features/entry/season-page/season-page.component.html index 30994ea..e09850b 100644 --- a/frontend/src/app/features/entry/season-page/season-page.component.html +++ b/frontend/src/app/features/entry/season-page/season-page.component.html @@ -1,6 +1,5 @@ -
+
@@ -53,7 +52,7 @@

{{selectedSeason.name}}

-
@@ -76,78 +75,137 @@
-

- Episodes ({{selectedSeason.episodes.length}}) +

+ + Episodes ({{selectedSeason.episodes.length}}) + +
+ + + +

-
+ + +
-
+
Episode Still
-
{{episode.episode_number}}. {{episode.name}}
+
{{episode.episode_number}}. + {{episode.name}}
- -
-

{{episode.overview}}

-

- - Air date: {{episode.air_date | date:'MMM dd, yyyy'}} - - • Runtime: {{episode.runtime | - betterMinutesFormat}} - - - • Seen: {{episode.date_first_seen | date:'MMM dd, yyyy'}} - +

+ {{episode.overview}}

+
-
- -
-

Watch History

-
- - - - - - - - - - - - - - - - - -
EpisodeDate WatchedWatched WithActions
Episode {{ep.episode.episode_number}}{{ep.date_seen | date:'MMM dd, yyyy'}}{{ep.seen_with}} - - -
+
+
+ +
+
- \ No newline at end of file + + + \ No newline at end of file diff --git a/frontend/src/app/features/entry/season-page/season-page.component.ts b/frontend/src/app/features/entry/season-page/season-page.component.ts index baa66b3..35367bb 100644 --- a/frontend/src/app/features/entry/season-page/season-page.component.ts +++ b/frontend/src/app/features/entry/season-page/season-page.component.ts @@ -7,6 +7,10 @@ import { MatDialog } from '@angular/material/dialog'; import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; import { Episode } from '../../../shared/models/episode.models'; import { EpisodeSeen } from '../../../shared/models/episode-seen.model'; +import { Entry } from '../../../shared/models/entry.model'; +import { ConfigService } from '../../../core/services/config.service'; +import { SettingsService } from '../../../core/services/settings.service'; +import { Settings } from '../../../shared/models/settings.model'; @Component({ selector: 'app-season-page', @@ -15,15 +19,21 @@ import { EpisodeSeen } from '../../../shared/models/episode-seen.model'; }) export class SeasonPageComponent implements OnInit { entryId!: number; + entry!: Entry; seasonNumber!: number; seasons: Season[] = []; selectedSeason!: Season; watchHistory: EpisodeSeen[] = []; + episodesViewMode: string = 'grid'; + selectedEpisode: Episode | undefined; + constructor( - private route: ActivatedRoute, - private entryService: EntryService, private episodeSeenService: EpisodeSeenService, + private settingsService: SettingsService, + private configService: ConfigService, + private entryService: EntryService, + private route: ActivatedRoute, private dialog: MatDialog ) {} @@ -32,6 +42,15 @@ export class SeasonPageComponent implements OnInit { this.entryId = Number(params.get('id')); this.seasonNumber = Number(params.get('seasonNumber')); + this.entryService.getEntryById(this.entryId).subscribe({ + next: (result) => { + this.entry = result; + }, + error: () => { + console.log(`Couldn't fetch entry.`); + }, + }); + // Fetch all seasons for the entryId this.entryService.getEntrySeasons(this.entryId).subscribe({ next: (result) => { @@ -51,6 +70,8 @@ export class SeasonPageComponent implements OnInit { console.log(this.watchHistory); }, }); + + this.getDefaultViewMode(); }); } @@ -62,7 +83,8 @@ export class SeasonPageComponent implements OnInit { return 'assets/images/default/default-poster.png'; } - async markEpisodeAsWatched(episode: Episode) { + async markEpisodeAsWatched(event: Event, episode: Episode) { + event.stopPropagation(); const dialogRef = this.dialog.open(SeenModalComponent, { width: '400px', }); @@ -101,8 +123,8 @@ export class SeasonPageComponent implements OnInit { width: '400px', data: { hideSeenWith: true, - title: 'Mark Season As Watched' - } + title: 'Mark Season As Watched', + }, }); await dialogRef.afterClosed().subscribe((result) => { @@ -136,4 +158,67 @@ export class SeasonPageComponent implements OnInit { }); }); } + + toggleDescription(episode: any) { + episode.showFullDescription = !episode.showFullDescription; + } + + showEpisodeDetails(event: Event, episode: Episode) { + event.stopPropagation(); + episode.episodeSeen = this.watchHistory.filter( + (w) => w.episode_id == episode.id + ); + this.selectedEpisode = episode; + } + + getBanner() { + // * Is in library: use a local backdrop + if (this.entry.medias) { + const selectedBackdrop = this.entry.medias.filter( + (m) => m.type == 'backdrop' && m.isSelected + ); + + if ( + selectedBackdrop.length && + selectedBackdrop[0] && + selectedBackdrop[0].path + ) { + return ( + this.configService.getBackendApiUrl() + + `/media/entries/backdrops/original/${selectedBackdrop[0].path}` + ); + } + } + + // * No local backdrop available, Use TMDB backdrop + if (this.entry.banner_path) + return `https://image.tmdb.org/t/p/w1280` + this.entry.banner_path; + + // * No backdrop found, use default backdrop image as a last stand + return 'assets/images/default/default-poster.png'; + } + + getDefaultViewMode() { + const obs = this.settingsService.getSettings().subscribe({ + next: (s) => { + this.episodesViewMode = s.episodesViewMode || 'grid'; + }, + complete: () => { + obs.unsubscribe(); + }, + }); + } + + setViewMode(mode: string) { + this.episodesViewMode = mode; + const newSettings = { episodesViewMode: this.episodesViewMode } as Settings; + const obs = this.settingsService.updateSettings(newSettings).subscribe({ + next: (s) => { + // ? view mode updated + }, + complete: () => { + obs.unsubscribe(); + }, + }); + } } diff --git a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts index 492b72d..31e85e1 100644 --- a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts +++ b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts @@ -45,27 +45,29 @@ export class SeenModalComponent implements OnInit { ) {} ngOnInit(): void { - if (this.data.title) { - this.title = this.data.title; - } + if (this.data) { + if (this.data.title) { + this.title = this.data.title; + } - if (this.data.watchedWith) - this.watchedWith = this.data.watchedWith.split(', ').join('\n'); + if (this.data.watchedWith) + this.watchedWith = this.data.watchedWith.split(', ').join('\n'); - if (this.data.hideSeenWith) { - this.hideSeenWith = this.data.hideSeenWith; - } + if (this.data.hideSeenWith) { + this.hideSeenWith = this.data.hideSeenWith; + } - // ? no initial data was passed: populate date field with current date - if (!this.data.watchDate) { - this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US'); + // ? no initial data was passed: populate date field with current date + if (this.data.watchDate) { + // ? if data is passed, populate fields + this.watchDate = formatDate( + new Date(this.data.watchDate), + 'yyyy-MM-dd', + 'en-US' + ); + } } else { - // ? if data is passed, populate fields - this.watchDate = formatDate( - new Date(this.data.watchDate), - 'yyyy-MM-dd', - 'en-US' - ); + this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US'); } } diff --git a/frontend/src/app/shared/models/episode.models.ts b/frontend/src/app/shared/models/episode.models.ts index 89a5122..1ea7380 100644 --- a/frontend/src/app/shared/models/episode.models.ts +++ b/frontend/src/app/shared/models/episode.models.ts @@ -1,5 +1,5 @@ -import { EpisodeSeen } from "./episode-seen.model"; -import { Season } from "./season.model"; +import { EpisodeSeen } from './episode-seen.model'; +import { Season } from './season.model'; export interface Episode { id: number; @@ -21,7 +21,7 @@ export interface Episode { user_rating: number; tmdb_rating: number; imdb_rating: number; - + // temp fields still_path: string; banner_path: string; @@ -29,6 +29,9 @@ export interface Episode { date_first_seen: Date; date_last_seen: Date; + // front fields + showFullDescription: boolean; + createdAt: Date; updatedAt: Date; } diff --git a/frontend/src/app/shared/models/settings.model.ts b/frontend/src/app/shared/models/settings.model.ts index b2439e3..330d782 100644 --- a/frontend/src/app/shared/models/settings.model.ts +++ b/frontend/src/app/shared/models/settings.model.ts @@ -11,4 +11,5 @@ export interface Settings { watchlistViewMode: string; CollectionsViewMode: string; CollectionItemsViewMode: string; + episodesViewMode: string; }