From 3cd3f44dea7d23f28550f0843c974f5007a6f9ab Mon Sep 17 00:00:00 2001 From: Chneemann Date: Tue, 29 Apr 2025 04:35:49 +0200 Subject: [PATCH] refactor: rename MoviesListComponent to VideoListComponent and update variables accordingly --- .../home/categories/categories.component.html | 51 +++++++++---------- .../home/categories/categories.component.ts | 40 +++++++-------- .../video-list.component.html} | 14 ++--- .../video-list.component.scss} | 6 +-- .../video-list.component.spec.ts} | 12 ++--- .../video-list.component.ts} | 32 ++++++------ .../app/components/home/home.component.html | 10 ++-- 7 files changed, 82 insertions(+), 83 deletions(-) rename frontend/src/app/components/home/categories/{movie-list/movie-list.component.html => video-list/video-list.component.html} (59%) rename frontend/src/app/components/home/categories/{movie-list/movie-list.component.scss => video-list/video-list.component.scss} (97%) rename frontend/src/app/components/home/categories/{movie-list/movie-list.component.spec.ts => video-list/video-list.component.spec.ts} (52%) rename frontend/src/app/components/home/categories/{movie-list/movie-list.component.ts => video-list/video-list.component.ts} (50%) diff --git a/frontend/src/app/components/home/categories/categories.component.html b/frontend/src/app/components/home/categories/categories.component.html index b587b4f..df27f50 100644 --- a/frontend/src/app/components/home/categories/categories.component.html +++ b/frontend/src/app/components/home/categories/categories.component.html @@ -1,43 +1,42 @@ -@if (movies.length > 0) { +@if (videos.length > 0) {
- - @if (recentMovies().length > 0) { + + @if (recentVideos().length > 0) {
-

New movies added this week

- +

New videos added this week

+
} - @if (favoriteMovies.length > 0) { + @if (favoriteVideos.length > 0) {

Favorites

- +
} @for (filmGenre of filmGenres; track filmGenre) { - - @if (getAllMovies(filmGenre.code).length > 0) { + + @if (getAllVideos(filmGenre.code).length > 0) {
-

{{ filmGenre.name }}

- +
} }
diff --git a/frontend/src/app/components/home/categories/categories.component.ts b/frontend/src/app/components/home/categories/categories.component.ts index 39ee272..3eafbf4 100644 --- a/frontend/src/app/components/home/categories/categories.component.ts +++ b/frontend/src/app/components/home/categories/categories.component.ts @@ -8,21 +8,21 @@ import { Output, } from '@angular/core'; import { environment } from '../../../../environments/environment'; -import { MoviesListComponent } from './movie-list/movie-list.component'; +import { VideoListComponent } from './video-list/video-list.component'; @Component({ selector: 'app-categories', standalone: true, - imports: [CommonModule, MoviesListComponent], + imports: [CommonModule, VideoListComponent], templateUrl: './categories.component.html', styleUrl: './categories.component.scss', }) export class CategoriesComponent implements AfterViewInit { - @Input() movies: any[] = []; - @Input() currentMovie: number = 0; - @Input() favoriteMovies: any[] = []; - @Input() watchedMovies: any[] = []; - @Output() currentMovieId = new EventEmitter(); + @Input() videos: any[] = []; + @Input() currentVideo: number = 0; + @Input() favoriteVideos: any[] = []; + @Input() watchedVideos: any[] = []; + @Output() currentVideoId = new EventEmitter(); environmentBaseUrl: string = environment.baseUrl; isScrollable: boolean = false; @@ -52,31 +52,31 @@ export class CategoriesComponent implements AfterViewInit { this.checkScroll(); } - openCurrentMovie(movieId: number) { - this.currentMovie = movieId; - this.currentMovieId.emit(movieId); + openCurrentVideo(videoId: number) { + this.currentVideo = videoId; + this.currentVideoId.emit(videoId); } - getAllMovies(filmGenre: string) { - return this.movies.filter((movie) => movie.film_genre === filmGenre); + getAllVideos(filmGenre: string) { + return this.videos.filter((video) => video.film_genre === filmGenre); } - getFavoriteMovies() { - return this.movies.filter((movie) => - this.favoriteMovies.includes(movie.id) + getFavoriteVideos() { + return this.videos.filter((video) => + this.favoriteVideos.includes(video.id) ); } - recentMovies() { + recentVideos() { const today = new Date(); const dayOfWeek = today.getDay(); const lastMonday = new Date(today); lastMonday.setDate(today.getDate() - ((dayOfWeek + 6) % 7)); - return this.movies.filter((movie) => { - const movieDate = new Date(movie.created_at); - return movieDate >= lastMonday && movieDate <= today; + return this.videos.filter((video) => { + const videoDate = new Date(video.created_at); + return videoDate >= lastMonday && videoDate <= today; }); } @@ -87,7 +87,7 @@ export class CategoriesComponent implements AfterViewInit { checkScroll() { const containers = document.querySelectorAll( - '.movies' + '.videos' ) as NodeListOf; containers.forEach((container) => { const scrollButtons = container.parentElement?.querySelector( diff --git a/frontend/src/app/components/home/categories/movie-list/movie-list.component.html b/frontend/src/app/components/home/categories/video-list/video-list.component.html similarity index 59% rename from frontend/src/app/components/home/categories/movie-list/movie-list.component.html rename to frontend/src/app/components/home/categories/video-list/video-list.component.html index 94fab90..c2aebe9 100644 --- a/frontend/src/app/components/home/categories/movie-list/movie-list.component.html +++ b/frontend/src/app/components/home/categories/video-list/video-list.component.html @@ -1,15 +1,15 @@ -
- - @for (movie of movies; track movie) { -
+
+ + @for (video of videos; track video) { +
-
+
diff --git a/frontend/src/app/components/home/categories/movie-list/movie-list.component.scss b/frontend/src/app/components/home/categories/video-list/video-list.component.scss similarity index 97% rename from frontend/src/app/components/home/categories/movie-list/movie-list.component.scss rename to frontend/src/app/components/home/categories/video-list/video-list.component.scss index b6b8f6b..04a138d 100644 --- a/frontend/src/app/components/home/categories/movie-list/movie-list.component.scss +++ b/frontend/src/app/components/home/categories/video-list/video-list.component.scss @@ -1,6 +1,6 @@ @use "./../../../../../assets/style/colors.scss" as *; -.movies { +.videos { display: flex; overflow-x: auto; overflow-y: hidden; @@ -9,11 +9,11 @@ padding-bottom: 24px; } -.movies::-webkit-scrollbar { +.videos::-webkit-scrollbar { display: none; } -.movie { +.video { position: relative; width: 213px; height: 120px; diff --git a/frontend/src/app/components/home/categories/movie-list/movie-list.component.spec.ts b/frontend/src/app/components/home/categories/video-list/video-list.component.spec.ts similarity index 52% rename from frontend/src/app/components/home/categories/movie-list/movie-list.component.spec.ts rename to frontend/src/app/components/home/categories/video-list/video-list.component.spec.ts index 8edebd7..847042a 100644 --- a/frontend/src/app/components/home/categories/movie-list/movie-list.component.spec.ts +++ b/frontend/src/app/components/home/categories/video-list/video-list.component.spec.ts @@ -1,17 +1,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MoviesListComponent } from './movie-list.component'; +import { VideoListComponent } from './video-list.component'; -describe('MoviesListComponent', () => { - let component: MoviesListComponent; - let fixture: ComponentFixture; +describe('VideoListComponent', () => { + let component: VideoListComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [MoviesListComponent], + imports: [VideoListComponent], }).compileComponents(); - fixture = TestBed.createComponent(MoviesListComponent); + fixture = TestBed.createComponent(VideoListComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/frontend/src/app/components/home/categories/movie-list/movie-list.component.ts b/frontend/src/app/components/home/categories/video-list/video-list.component.ts similarity index 50% rename from frontend/src/app/components/home/categories/movie-list/movie-list.component.ts rename to frontend/src/app/components/home/categories/video-list/video-list.component.ts index bc565c4..49442d3 100644 --- a/frontend/src/app/components/home/categories/movie-list/movie-list.component.ts +++ b/frontend/src/app/components/home/categories/video-list/video-list.component.ts @@ -3,33 +3,33 @@ import { environment } from '../../../../../environments/environment'; import { CommonModule } from '@angular/common'; @Component({ - selector: 'app-movie-list', + selector: 'app-video-list', standalone: true, imports: [CommonModule], - templateUrl: './movie-list.component.html', - styleUrls: ['./movie-list.component.scss'], + templateUrl: './video-list.component.html', + styleUrls: ['./video-list.component.scss'], }) -export class MoviesListComponent { - @Input() movies: any[] = []; - @Input() currentMovie: number = 0; - @Input() watchedMovies: any[] = []; - @Input() movieCategory: string = ''; - @Output() currentMovieId = new EventEmitter(); +export class VideoListComponent { + @Input() videos: any[] = []; + @Input() currentVideo: number = 0; + @Input() watchedVideos: any[] = []; + @Input() videoCategory: string = ''; + @Output() currentVideoId = new EventEmitter(); - getThumbnailUrl(movieId: number, fileName: string): string { - return `${environment.baseUrl}/media/thumbnails/${movieId}/${fileName}_480p.jpg`; + getThumbnailUrl(videoId: number, fileName: string): string { + return `${environment.baseUrl}/media/thumbnails/${videoId}/${fileName}_480p.jpg`; } - openCurrentMovie(movieId: number) { - this.currentMovie = movieId; - this.currentMovieId.emit(movieId); + openCurrentVideo(videoId: number) { + this.currentVideo = videoId; + this.currentVideoId.emit(videoId); } scrollLeft(event: MouseEvent) { const button = event.target as HTMLElement; const container = button .closest('.category') - ?.querySelector('.movies') as HTMLElement; + ?.querySelector('.videos') as HTMLElement; if (container) { container.scrollLeft -= 217; } @@ -39,7 +39,7 @@ export class MoviesListComponent { const button = event.target as HTMLElement; const container = button .closest('.category') - ?.querySelector('.movies') as HTMLElement; + ?.querySelector('.videos') as HTMLElement; if (container) { container.scrollLeft += 217; } diff --git a/frontend/src/app/components/home/home.component.html b/frontend/src/app/components/home/home.component.html index ca1be50..fe20928 100644 --- a/frontend/src/app/components/home/home.component.html +++ b/frontend/src/app/components/home/home.component.html @@ -30,11 +30,11 @@ *ngIf=" this.isWideScreen() || (!this.isWideScreen() && currentMovie.length === 0) " - [movies]="movies" - [currentMovie]="currentMovie[0]?.id" - [favoriteMovies]="favoriteMovies" - [watchedMovies]="watchedMovies" - (currentMovieId)="currentMovieId($event)" + [videos]="movies" + [currentVideo]="currentMovie[0]?.id" + [favoriteVideos]="favoriteMovies" + [watchedVideos]="watchedMovies" + (currentVideoId)="currentMovieId($event)" > } @else {