From e1223171b04da1f87c07746826213d33de293985 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Tue, 16 Apr 2024 19:18:24 +0100 Subject: [PATCH] add entry page feature --- frontend/src/app/app-routing.module.ts | 17 +- frontend/src/app/app.module.ts | 36 ++- frontend/src/app/core/core.module.ts | 2 + .../features/entry/entries-routing.module.ts | 20 ++ .../src/app/features/entry/entries.module.ts | 20 ++ .../entry/entry-page/entry-page.component.css | 136 +++++++--- .../entry-page/entry-page.component.html | 126 +++++++-- .../entry/entry-page/entry-page.component.ts | 241 +++++++++++++++++- 8 files changed, 525 insertions(+), 73 deletions(-) create mode 100644 frontend/src/app/features/entry/entries-routing.module.ts create mode 100644 frontend/src/app/features/entry/entries.module.ts diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index d3c44b7..17a3ae9 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -5,7 +5,6 @@ import { SearchComponent } from './features/discover/search/search.component'; import { TrendingComponent } from './features/discover/trending/trending.component'; import { PopularComponent } from './features/discover/popular/popular.component'; import { LibraryComponent } from './features/library/library.component'; -import { EntryPageComponent } from './features/entry/entry-page/entry-page.component'; const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, @@ -15,7 +14,21 @@ const routes: Routes = [ { path: 'trending', component: TrendingComponent }, { path: 'library', component: LibraryComponent }, - { path: 'entry', component: EntryPageComponent }, + { path: 'entry', component: LibraryComponent }, + // { + // path: 'entry/:id', + // component: EntryPageComponent, + // resolve: { + // entry: EntryResolverService, + // }, + // }, + { + path: 'entry', + loadChildren: () => + import('./features/entry/entries.module').then( + (m) => m.EntriesModule + ), + }, { path: 'user-collections', loadChildren: () => diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index e0580ab..12fe7f3 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -5,62 +5,58 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { DragDropModule } from '@angular/cdk/drag-drop'; + import { CoreModule } from './core/core.module'; -import { SharedModule } from './shared/shared.module'; +import { CommonModule, DatePipe } from '@angular/common'; + +import { ModalModule } from 'ngx-bootstrap/modal'; +import { AccordionModule } from 'ngx-bootstrap/accordion'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatInputModule } from '@angular/material/input'; -import { MatButtonModule } from '@angular/material/button'; -import { MatCheckboxModule } from '@angular/material/checkbox'; -import { MatListModule } from '@angular/material/list'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { DatePipe } from '@angular/common'; -import { DragDropModule } from '@angular/cdk/drag-drop'; import { HomeComponent } from './features/home/home.component'; import { PopularComponent } from './features/discover/popular/popular.component'; import { TrendingComponent } from './features/discover/trending/trending.component'; import { SearchComponent } from './features/discover/search/search.component'; import { LibraryComponent } from './features/library/library.component'; + import { DynamicEntryListComponent } from './shared/components/lists/dynamic-entry-list/dynamic-entry-list.component'; import { NotificationPopupComponent } from './shared/components/notification-popup/notification-popup.component'; import { MainCardComponent } from './shared/components/cards/main-card/main-card.component'; import { UserCollectionsModalComponent } from './shared/components/modals/list-selection-modal/user-collections-modal.component'; -import { EntryPageComponent } from './features/entry/entry-page/entry-page.component'; @NgModule({ declarations: [ AppComponent, + + // pages HomeComponent, PopularComponent, TrendingComponent, SearchComponent, LibraryComponent, + // EntryPageComponent, - // ? components - NotificationPopupComponent, + // ? temp shared components MainCardComponent, DynamicEntryListComponent, NotificationPopupComponent, UserCollectionsModalComponent, - EntryPageComponent, ], imports: [ CoreModule, + CommonModule, + + AppRoutingModule, BrowserModule, - AppRoutingModule, + BrowserAnimationsModule, HttpClientModule, ReactiveFormsModule, FormsModule, - // MatDialogModule, - // MatInputModule, - // MatButtonModule, - // MatCheckboxModule, - // MatListModule, - BrowserAnimationsModule, DragDropModule, ], diff --git a/frontend/src/app/core/core.module.ts b/frontend/src/app/core/core.module.ts index 7a6d765..4d0d0a6 100644 --- a/frontend/src/app/core/core.module.ts +++ b/frontend/src/app/core/core.module.ts @@ -9,6 +9,7 @@ import { ToggleService } from './services/toggle.service'; import { SidebarComponent } from './components/sidebar/sidebar.component'; import { NavbarComponent } from './components/navbar/navbar.component'; import { RouterModule } from '@angular/router'; +import { EntrySeenService } from './services/entry-seen.service'; @NgModule({ declarations: [SidebarComponent, NavbarComponent], @@ -17,6 +18,7 @@ import { RouterModule } from '@angular/router'; TmdbService, LibraryService, EntryService, + EntrySeenService, UserCollectionService, ToggleService, ], diff --git a/frontend/src/app/features/entry/entries-routing.module.ts b/frontend/src/app/features/entry/entries-routing.module.ts new file mode 100644 index 0000000..fbc9de5 --- /dev/null +++ b/frontend/src/app/features/entry/entries-routing.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { EntryPageComponent } from './entry-page/entry-page.component'; +import { EntryResolverService } from '../../core/resolvers/entry-resolver.service'; + +const routes: Routes = [ + { + path: ':id', + component: EntryPageComponent, + resolve: { + entry: EntryResolverService, + }, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class EntriesRoutingModule {} diff --git a/frontend/src/app/features/entry/entries.module.ts b/frontend/src/app/features/entry/entries.module.ts new file mode 100644 index 0000000..4fedc00 --- /dev/null +++ b/frontend/src/app/features/entry/entries.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { SharedModule } from '../../shared/shared.module'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { EntryPageComponent } from './entry-page/entry-page.component'; +import { EntriesRoutingModule } from './entries-routing.module'; +import { CommonModule } from '@angular/common'; + +@NgModule({ + declarations: [EntryPageComponent], + imports: [ + CommonModule, + SharedModule, + + FormsModule, + ReactiveFormsModule, + EntriesRoutingModule, + ], + exports: [], +}) +export class EntriesModule {} 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 b2bc21b..ed3c96e 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 @@ -1,40 +1,66 @@ -.background-image { - position: fixed; /* Keep the background fixed */ +.background-wrapper { + position: absolute; top: 0; left: 0; - width: 100%; /* Cover the full view width */ - height: 100%; /* Cover the full view height */ - z-index: -1; /* Place it behind the content */ + width: 100%; + height: 80vh; + /* Use 100vh to ensure it covers the viewport height */ + z-index: -1; + overflow: hidden; +} + +.background-wrapper img { + width: 100%; + height: 100%; + object-fit: fill; +} + +.background-wrapper::after { + content: ''; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #eff1f3 100%); + z-index: 2; +} + +[data-bs-theme=dark] .background-wrapper::after { + background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #181c1f 100%); } .content-wrapper { color: #212529; - background-color: rgba( - 255, - 255, - 255, - 0.461 - ); /* Light semi-transparent background */ - backdrop-filter: blur(10px); /* Blur effect */ - padding: 20px; /* Padding for content */ - border-radius: 8px; /* Rounded corners */ - border: 1px solid rgba(255, 255, 255, 0.2); /* Optional: subtle border */ - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Soft shadow for depth */ + background: linear-gradient(to bottom, rgba(255, 255, 255, 0.461) 10%, #eff1f3 100%); + + backdrop-filter: blur(10px); + /* Blur effect */ + padding: 20px; + /* Padding for content */ + border-radius: 8px; + /* Rounded corners */ + border: 1px solid #eff1f3; + /* Optional: subtle border */ + /* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */ } -.content-wrapper-dark { +[data-bs-theme=dark] .content-wrapper { color: #a7acb1; - background-color: rgba( - 33, - 37, - 41, - 0.7 - ); /* Dark semi-transparent background */ - backdrop-filter: blur(10px); /* Blur effect */ - padding: 20px; /* Padding for content */ - border-radius: 8px; /* Rounded corners */ - border: 1px solid #212529; /* Subtle light border for contrast */ - box-shadow: 0 4px 6px rgba(255, 255, 255, 0.1); /* Lighter shadow for a glow effect */ + background: linear-gradient(to bottom, rgba(33, + 37, + 41, + 0.7) 50%, #181c1f 100%); + + background-color: rgba(33, + 37, + 41, + 0.7); + /* Dark semi-transparent background */ + border: 1px solid #181c1f; + /* Subtle light border for contrast */ + /* box-shadow: 0 4px 6px rgba(255, 255, 255, 0.1); */ + /* Lighter shadow for a glow effect */ } .main-container { @@ -42,14 +68,24 @@ } .poster { - padding: 10px 10px 0 10px; + padding: px 10px 0 10px; } .poster img { border-radius: 5px; + margin-bottom: 0 !important; } -.side-info { + +.rating { + color: var(--shz-gold-1); + font-size: 25px; + margin: 10px 0; +} + + +.side-info .list-group-item { background-color: rgba(255, 255, 255, 0.461) !important; + background-color: transparent !important; } /* ! DESCRIPTION */ @@ -58,3 +94,43 @@ font-weight: bolder; font-size: 2.9rem !important; } + + +[data-bs-theme=dark] .title { + color: white; +} + + +.side-info strong { + color: #008cff; + +} + +.btn-icon-only { + background-color: transparent; + border: none; + color: inherit; + margin: 0 5px 3px 0; +} + +.btn-icon-only:hover { + color: #fc185a; +} + +.btn-icon-only-success:hover { + color: #008cff; +} + +.interaction-btns { + position: absolute; + top: 10px; + right: 15px; + background-color: aquamarine; +} + +.interaction-btns button { + display: block; + padding-top: 0; + padding-bottom: 0; + width: 50px; +} \ No newline at end of file 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 a23a4f4..9ea0cb7 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 @@ -1,33 +1,123 @@ -Banner Image - +
+ Banner Image +
-
+
- Movie Poster - + Movie Poster
- +
+ + +
+
    -
  • Next Episode: 2023-05-11
  • -
  • Status: Released
  • -
  • Genre: Action, Adventure
  • -
  • Rating: 8.5/10
  • -
  • Rating: 8.5/10
  • +
  • Rating: {{tmdbRating}}/10
  • +
  • Premiere: {{releaseDate}}
  • +
  • Next Episode: {{nextEpisode}}
  • +
  • Status: {{status}}
  • +
  • Genre: {{genres}}
+ +
+ +
+
+
Watch History
+
+
+ +
+

+ +

+
+
Seen With:
Person1, person 2
+
+ +
+
+
+ + +
+
+
+ +
+
-

Movie Title

+
+

{{this.entry.title}}

+ + +
+ + + + + +
+ +
-

Release Date: January 1, 2024

+

{{year}} • {{genres}}

+ -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque habitant morbi tristique senectus et - netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit - amet, ante.

+

{{this.entry.tagline}}

+

{{this.entry.storyline}}

+ + +
+

Seasons

+
+
+
+ + +
+ +

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

+
+
+
+ +
+

Cast

+
+ +
\ No newline at end of file diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.ts b/frontend/src/app/features/entry/entry-page/entry-page.component.ts index 405d666..8986a9f 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.ts +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.ts @@ -1,10 +1,245 @@ -import { Component } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { trigger, state, style, transition, animate } from '@angular/animations'; + +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialog } from '@angular/material/dialog'; + +import { Entry } from '../../../shared/models/entry.model'; + +import { DatePipe } from '@angular/common'; + +import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component'; +import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; + +import { EntrySeenService } from '../../../core/services/entry-seen.service'; +import { EntryRatingsService } from '../../../core/services/entry-ratings.service'; +import { TmdbService } from '../../../core/services/tmdb.service'; +import { LibraryService } from '../../../core/services/library.service'; +import { EntryService } from '../../../core/services/entry.service'; @Component({ selector: 'app-entry-page', templateUrl: './entry-page.component.html', - styleUrls: ['./entry-page.component.css'] + styleUrls: ['./entry-page.component.css'], + encapsulation: ViewEncapsulation.None, + animations: [ + trigger('fadeInOut', [ + transition(':enter', [ // void => * + style({ opacity: 0 }), + animate('0.5s ease-in', style({ opacity: 1 })) + ]), + transition(':leave', [ // * => void + animate('0.5s ease-out', style({ opacity: 0 })) + ]) + ]) + ], }) -export class EntryPageComponent { +export class EntryPageComponent implements OnInit { + entry: Entry = {} as Entry; + public showAll = false; + public initialCount = 2; + constructor( + private route: ActivatedRoute, + private router: Router, + public dialog: MatDialog, + private tmdbService: TmdbService, + private libraryService: LibraryService, + private entryService: EntryService, + private entrySeenService: EntrySeenService, + private entryRatingsService: EntryRatingsService, + private datePipe: DatePipe + ) {} + + ngOnInit(): void { + this.route.data.subscribe( + (data) => { + this.entry = data['entry'] as Entry; + this.entry.seasons = this.entry.seasons.sort((a, b) => a.name.localeCompare(b.name)); + console.log(this.entry); + if (!this.entry) { + this.router.navigate(['/error'], { + queryParams: { error: 'Entry not found' }, + }); + } + }, + (error) => { + console.error('Error when trying to access route data', error); + this.router.navigate(['/error'], { + queryParams: { error: 'Error fetching data' }, + }); + } + ); + } + + openDialog() { + if (!this.entry) return; + + const dialogRef = this.dialog.open(SeenModalComponent, { + width: '400px', + }); + + console.log('Seen dialog opened'); + + dialogRef.afterClosed().subscribe((result) => { + if (result) { + console.log('Seen dialog closed with:', result); + + if (result.watchDate == '') { + // TODO show no was passed date notification + return; + } + + let watchedWith = result.watchedWith.split('\n').join(', '); + + this.entrySeenService + .createEntrySeen( + this.entry.id.toString(), + result.watchDate, + watchedWith + ) + .subscribe({ + next: (entrySeen) => { + if (entrySeen) { + // TODO show confirm notification + console.log(`EntrySeen Added`, entrySeen); + this.entry.entrySeen.push(entrySeen); + } + }, + error: (error) => { + console.error('Error adding entrySeen:', error); + }, + }); + + // TODO show notification + } else { + console.log('Seen dialog was cancelled'); + } + }); + } + + onRatingChange(event: Event) { + this.entryRatingsService + .updateEntryRatings(this.entry.entryRating) + .subscribe({ + next: (entryRatings) => { + if (entryRatings) { + // TODO show notification + this.entry.entryRating = entryRatings; + } + }, + error: (error) => { + // TODO show notification + console.error('Error updating entryRatings:', error); + }, + }); + } + + removeEntrySeen(id: number) { + // TODO add confirm modal + this.entrySeenService.removeEntrySeen(id).subscribe({ + next: () => { + this.entry.entrySeen = this.entry.entrySeen.filter( + (item) => item.id !== id + ); + }, + error: (error) => { + // TODO show notification + console.error('Error deleting entrySeen:', error); + }, + }); + } + + showAddToListModal() { + if (this.entry) { + const dialogRef = this.dialog.open(UserCollectionsModalComponent, { + width: '400px', + height: '55%', + data: { + entryId: this.entry.id, + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + console.log('Modal Closed: ', result); + }); + } + } + + refrechEntry() { + this.entryService.refrechEntryById(this.entry.id).subscribe({ + next: (entry) => { + this.entry = entry; + console.log(`Entry refreched: `, entry); + // TODO show updated notification + }, + error: (error) => { + // TODO show error notification + console.error('Error refreching movie info:', error); + }, + }); + } + + toggleShowAllSeasons() { + this.showAll = !this.showAll; + } + + // * getters + get status() { + return this.entry.status; + } + + get createdDate() { + return this.datePipe.transform(this.entry.createdAt, 'dd MMMM, yyyy'); + } + + get releaseDate() { + return this.datePipe.transform(this.entry.release_date, 'MMM dd, yyyy'); + } + + get year() { + return this.datePipe.transform(this.entry.release_date, 'yyyy'); + } + + get runtime() { + return this.entry.runtime; + } + + get genres(): string { + return this.entry.genres.join(', '); + } + + get userRating(): string { + if (!this.entry.entryRating.user_rating) return '0'; + return this.entry.entryRating.user_rating.toFixed(1); + } + + get tmdbRating(): string { + if (!this.entry.entryRating.tmdb_rating) return '0'; + return this.entry.entryRating.tmdb_rating.toFixed(1); + } + + get imdbRating(): string { + if (!this.entry.entryRating.imdb_rating) return '0'; + return this.entry.entryRating.imdb_rating.toFixed(1); + } + + get poster(): string { + if (this.entry.poster_path == null) + return 'assets/images/default/default-poster.png'; + + return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path; + } + + get banner(): string { + if (this.entry.banner_path == null) + return 'assets/images/default/default-poster.png'; + + return `https://image.tmdb.org/t/p/w1280` + this.entry.banner_path; + } + + get nextEpisode() { + if (!this.entry.is_tvseries) return 'This is a movie'; + return 'sooon'; + } }