started working on discover page
This commit is contained in:
1 parent
58edac7259
commit
92aedb65d0
13 files changed
+233
-3
No files matched your search
@@ -0,0 +1,8 @@
|
||||
.title{
|
||||
color: white;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.tagline{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<!-- <app-two-lines-grid [entries]="popularEntries"></app-two-lines-grid> -->
|
||||
|
||||
<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div *ngFor="let entry of trendingEntries; let i = index;" class="carousel-item" [ngClass]="{active: i == 0}"
|
||||
data-bs-interval="10000">
|
||||
<img [src]="'https://image.tmdb.org/t/p/w780' + entry.banner_path" class="d-block w-100">
|
||||
<div class="carousel-caption d-none d-md-block text-white">
|
||||
<h5 class="title">{{entry.title}}</h5>
|
||||
<p class="tagline">{{entry.tagline}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-bs-slide="prev"> <span
|
||||
class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</a>
|
||||
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-bs-slide="next"> <span
|
||||
class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DiscoverPageComponent } from './discover-page.component';
|
||||
|
||||
describe('DiscoverPageComponent', () => {
|
||||
let component: DiscoverPageComponent;
|
||||
let fixture: ComponentFixture<DiscoverPageComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [DiscoverPageComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(DiscoverPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { TmdbService } from '../../../core/services/tmdb.service';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-discover-page',
|
||||
templateUrl: './discover-page.component.html',
|
||||
styleUrl: './discover-page.component.css',
|
||||
})
|
||||
export class DiscoverPageComponent implements OnInit {
|
||||
popularType: boolean = true;
|
||||
trendingType: boolean = true;
|
||||
|
||||
popularEntries: Entry[] = [] as Entry[];
|
||||
trendingEntries: Entry[] = [] as Entry[];
|
||||
|
||||
popularCurrentPage: number = 1;
|
||||
trendingCurrentPage: number = 1;
|
||||
|
||||
trendingPeriod: string = 'day';
|
||||
|
||||
constructor(private tmdbService: TmdbService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
let popularObs = this.tmdbService.getPopular(
|
||||
this.popularCurrentPage,
|
||||
this.popularType
|
||||
);
|
||||
let trendingObs = this.tmdbService.getTrending(
|
||||
this.popularCurrentPage,
|
||||
this.popularType,
|
||||
this.trendingPeriod
|
||||
);
|
||||
|
||||
const forkObs = forkJoin([popularObs, trendingObs]).subscribe({
|
||||
next: ([popular, trending]) => {
|
||||
this.popularEntries = popular;
|
||||
this.trendingEntries = trending;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
complete: () => {
|
||||
forkObs.unsubscribe();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { DiscoverPageComponent } from './discover-page/discover-page.component';
|
||||
|
||||
// ! /discover
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: DiscoverPageComponent,
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class DiscoverRoutingModule {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { DiscoverRoutingModule } from './discover-routing.module';
|
||||
import { DiscoverPageComponent } from './discover-page/discover-page.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
|
||||
DiscoverRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
DiscoverPageComponent
|
||||
],
|
||||
exports: [],
|
||||
})
|
||||
export class DiscoverModule {}
|
||||
@@ -81,7 +81,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter end -->
|
||||
|
||||
@@ -194,11 +194,13 @@ export class MainCardComponent implements OnInit {
|
||||
cardClick() {
|
||||
if (this.entry.isInLibrary)
|
||||
this.router.navigate([`/entries/${this.entry.id}`]);
|
||||
else
|
||||
else {
|
||||
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||
window.open(
|
||||
'https://www.themoviedb.org/movie/' + this.entry.entryId.tmdb_id,
|
||||
`https://www.themoviedb.org/${type}/` + this.entry.entryId.tmdb_id,
|
||||
'_blank'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getTmdbLink() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
.movies-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2,
|
||||
minmax(160px, 2fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="movies-container">
|
||||
<ng-container *ngFor="let entry of entries">
|
||||
<app-main-card [entry]="entry" (onEntryRemove)="entryRemoved($event)" (onEntryUpdate)="entryUpdated($event)"
|
||||
@animateDestroy></app-main-card>
|
||||
</ng-container>
|
||||
</div>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TwoLinesGridComponent } from './two-lines-grid.component';
|
||||
|
||||
describe('TwoLinesGridComponent', () => {
|
||||
let component: TwoLinesGridComponent;
|
||||
let fixture: ComponentFixture<TwoLinesGridComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TwoLinesGridComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TwoLinesGridComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { Event } from '@angular/router';
|
||||
import {
|
||||
animate,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-two-lines-grid',
|
||||
templateUrl: './two-lines-grid.component.html',
|
||||
styleUrl: './two-lines-grid.component.css',
|
||||
animations: [
|
||||
trigger('animateDestroy', [
|
||||
state('void', style({ opacity: '0' })),
|
||||
transition('* => void', animate('300ms ease')),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class TwoLinesGridComponent {
|
||||
@Output() onEntryRemove = new EventEmitter();
|
||||
@Output() onEntryUpdate = new EventEmitter();
|
||||
@Input() entries: Entry[] = [];
|
||||
|
||||
// ? EVENT CATCHER
|
||||
entryRemoved(event: Event) {
|
||||
// ? emit (entry removed) to library
|
||||
this.onEntryRemove.emit(event);
|
||||
}
|
||||
|
||||
entryUpdated(event: Event){
|
||||
this.onEntryUpdate
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { MainCardComponent } from './components/cards/main-card/main-card.compon
|
||||
import { DynamicEntryListComponent } from './components/lists/dynamic-entry-list/dynamic-entry-list.component';
|
||||
import { NotificationPopupComponent } from './components/notification-popup/notification-popup.component';
|
||||
import { MinutesFormatPipe } from './pipes/minutes-format/minutes-format.pipe';
|
||||
import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lines-grid.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -42,6 +43,7 @@ import { MinutesFormatPipe } from './pipes/minutes-format/minutes-format.pipe';
|
||||
|
||||
MainCardComponent,
|
||||
DynamicEntryListComponent,
|
||||
TwoLinesGridComponent,
|
||||
NotificationPopupComponent,
|
||||
],
|
||||
exports: [
|
||||
@@ -59,6 +61,7 @@ import { MinutesFormatPipe } from './pipes/minutes-format/minutes-format.pipe';
|
||||
|
||||
MainCardComponent,
|
||||
DynamicEntryListComponent,
|
||||
TwoLinesGridComponent,
|
||||
NotificationPopupComponent,
|
||||
],
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user