diff --git a/frontend/src/app/features/lists/entry-list/entry-list.component.ts b/frontend/src/app/features/lists/entry-list/entry-list.component.ts index 4d8b8d8..c9a89a9 100644 --- a/frontend/src/app/features/lists/entry-list/entry-list.component.ts +++ b/frontend/src/app/features/lists/entry-list/entry-list.component.ts @@ -36,7 +36,7 @@ export class EntryListComponent implements OnInit { } } else if (this.type == 'trending') { this.tmdbService - .getTrending(this.currentPage, this.isMovies) + .getTrending(this.currentPage, this.isMovies, 'day') .subscribe((myEntries) => (this.entries = myEntries)); } } diff --git a/frontend/src/app/features/pages/trending/trending.component.css b/frontend/src/app/features/pages/trending/trending.component.css index e69de29..bd4a4d6 100644 --- a/frontend/src/app/features/pages/trending/trending.component.css +++ b/frontend/src/app/features/pages/trending/trending.component.css @@ -0,0 +1,28 @@ +/* Custom CSS to visually connect the elements */ +.custom-group .form-select { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +.custom-group .btn-group .btn { + border-radius: 0; /* Remove rounding from buttons inside the group */ +} + +.custom-group .btn-group .left-btn { + border-top-left-radius: 0.25rem; /* Reapply rounding to the left-most button */ + border-bottom-left-radius: 0.25rem; +} + +.custom-group .btn-group .right-btn { + border-top-right-radius: 0.25rem; /* Reapply rounding to the right-most button */ + border-bottom-right-radius: 0.25rem; +} + +.custom-group .form-select, .custom-group .btn-outline-dark { + margin-right: -1px; /* Overlap borders */ +} + +/* Adjust the select width as needed */ +#single-select-field { + max-width: 120px; +} \ No newline at end of file diff --git a/frontend/src/app/features/pages/trending/trending.component.html b/frontend/src/app/features/pages/trending/trending.component.html index e2d969c..4407d5b 100644 --- a/frontend/src/app/features/pages/trending/trending.component.html +++ b/frontend/src/app/features/pages/trending/trending.component.html @@ -1,5 +1,5 @@ - + + \ No newline at end of file diff --git a/frontend/src/app/features/pages/trending/trending.component.ts b/frontend/src/app/features/pages/trending/trending.component.ts index 73a1fae..6b5e77b 100644 --- a/frontend/src/app/features/pages/trending/trending.component.ts +++ b/frontend/src/app/features/pages/trending/trending.component.ts @@ -12,11 +12,15 @@ export class TrendingComponent { entries: Entry[] = []; pages: Record> = { - true: {}, - false: {}, + movieday: {}, + dayweek: {}, + tvday: {}, + tvweek: {}, }; currentPage: number = 1; + period: string = 'day'; + constructor(private tmdbService: TmdbService) {} ngOnInit() { @@ -28,25 +32,35 @@ export class TrendingComponent { this.fetchEntries(); } + updatePeriod(event: any) { + this.period = event.target.value; + this.fetchEntries(); + } + fetchEntries() { - if (this.pages[this.entryType.toString()][this.currentPage]) { + const cachKey = (this.entryType ? 'movie' : 'tv') + this.period; // ex: movieday, movieweek, tvday, tvweek + + if (this.pages[cachKey][this.currentPage]) { // ? not in cash > fetch entries from TMDB - this.entries = this.pages[this.entryType.toString()][this.currentPage]; + this.entries = this.pages[cachKey][this.currentPage]; } else { // ? in cash > use cash entries this.tmdbService - .getTrending(this.currentPage, this.entryType) + .getTrending(this.currentPage, this.entryType, this.period) .subscribe((myEntries) => { // * add fetched entries to the cash - this.pages[this.entryType.toString()][this.currentPage] = myEntries; + this.pages[cachKey][this.currentPage] = myEntries; // * add fetched entries to the display list - this.entries = - this.pages[this.entryType.toString()][this.currentPage]; + this.entries = this.pages[cachKey][this.currentPage]; }); } } + setRange(period: string) { + this.period = period; + } + goToPage(page: number) { this.currentPage = page; this.fetchEntries();