add table view to library page
This commit is contained in:
1 parent
34766ba8e9
commit
7a21c6ebd8
18 files changed
+472
-35
No files matched your search
@@ -25,6 +25,7 @@ entryRouter.get('/', async (req, res) => {
|
|||||||
{ model: EntryId, as: 'entryId' },
|
{ model: EntryId, as: 'entryId' },
|
||||||
{ model: EntryRating, as: 'entryRating' },
|
{ model: EntryRating, as: 'entryRating' },
|
||||||
{ model: Media, as: 'medias' },
|
{ model: Media, as: 'medias' },
|
||||||
|
{ model: Season, as: 'seasons' },
|
||||||
{
|
{
|
||||||
model: Genre,
|
model: Genre,
|
||||||
as: 'genres',
|
as: 'genres',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { HomeComponent } from './features/home/home.component';
|
|||||||
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
|
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
|
||||||
import { TrendingComponent } from './features/discover/trending/trending.component';
|
import { TrendingComponent } from './features/discover/trending/trending.component';
|
||||||
import { PopularComponent } from './features/discover/popular/popular.component';
|
import { PopularComponent } from './features/discover/popular/popular.component';
|
||||||
import { LibraryComponent } from './features/library/library.component';
|
import { LibraryPageComponent } from './features/library/library-page/library-page.component';
|
||||||
import { FavoritComponent } from './features/favorit/favorit.component';
|
import { FavoritComponent } from './features/favorit/favorit.component';
|
||||||
import { WatchlistComponent } from './features/watchlist/watchlist.component';
|
import { WatchlistComponent } from './features/watchlist/watchlist.component';
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const routes: Routes = [
|
|||||||
{ path: 'popular', component: PopularComponent },
|
{ path: 'popular', component: PopularComponent },
|
||||||
{ path: 'trending', component: TrendingComponent },
|
{ path: 'trending', component: TrendingComponent },
|
||||||
|
|
||||||
{ path: 'library', component: LibraryComponent },
|
{ path: 'library', component: LibraryPageComponent },
|
||||||
{ path: 'favorit', component: FavoritComponent },
|
{ path: 'favorit', component: FavoritComponent },
|
||||||
{ path: 'watchlist', component: WatchlistComponent },
|
{ path: 'watchlist', component: WatchlistComponent },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { HomeComponent } from './features/home/home.component';
|
|||||||
import { PopularComponent } from './features/discover/popular/popular.component';
|
import { PopularComponent } from './features/discover/popular/popular.component';
|
||||||
import { TrendingComponent } from './features/discover/trending/trending.component';
|
import { TrendingComponent } from './features/discover/trending/trending.component';
|
||||||
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
|
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
|
||||||
import { LibraryComponent } from './features/library/library.component';
|
import { LibraryPageComponent } from './features/library/library-page/library-page.component';
|
||||||
|
|
||||||
import { DynamicEntryListComponent } from './shared/components/lists/dynamic-entry-list/dynamic-entry-list.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 { NotificationPopupComponent } from './shared/components/notification-popup/notification-popup.component';
|
||||||
@@ -24,6 +24,8 @@ import { FavoritComponent } from './features/favorit/favorit.component';
|
|||||||
import { WatchlistComponent } from './features/watchlist/watchlist.component';
|
import { WatchlistComponent } from './features/watchlist/watchlist.component';
|
||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
import { ToastrModule } from 'ngx-toastr';
|
import { ToastrModule } from 'ngx-toastr';
|
||||||
|
import { LibraryTableComponent } from './features/library/library-table/library-table.component';
|
||||||
|
import { LibraryTableLineComponent } from './features/library/library-table-line/library-table-line.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -53,7 +55,9 @@ import { ToastrModule } from 'ngx-toastr';
|
|||||||
PopularComponent,
|
PopularComponent,
|
||||||
TrendingComponent,
|
TrendingComponent,
|
||||||
SearchPageComponent,
|
SearchPageComponent,
|
||||||
LibraryComponent,
|
LibraryPageComponent,
|
||||||
|
LibraryTableComponent,
|
||||||
|
LibraryTableLineComponent,
|
||||||
FavoritComponent,
|
FavoritComponent,
|
||||||
WatchlistComponent,
|
WatchlistComponent,
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Entry } from '../../../../shared/models/entry.model';
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
|
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||||
import {
|
import {
|
||||||
CdkDragDrop,
|
CdkDragDrop,
|
||||||
CdkDragEnd,
|
CdkDragEnd,
|
||||||
@@ -13,7 +14,6 @@ import {
|
|||||||
transition,
|
transition,
|
||||||
trigger,
|
trigger,
|
||||||
} from '@angular/animations';
|
} from '@angular/animations';
|
||||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-collection-entry-table',
|
selector: 'app-collection-entry-table',
|
||||||
|
|||||||
File renamed without changes.
+17
-1
@@ -56,6 +56,18 @@
|
|||||||
|
|
||||||
<!-- Clear Filter Link -->
|
<!-- Clear Filter Link -->
|
||||||
<a href="javascript:;" class="clear-filter-link" (click)="clearFilter()">Clear Filter</a>
|
<a href="javascript:;" class="clear-filter-link" (click)="clearFilter()">Clear Filter</a>
|
||||||
|
|
||||||
|
<div class="col-1 justify-content-end" role="status" aria-live="polite">
|
||||||
|
<button class="btn btn-outline-primary" *ngIf="viewMode == 'grid'" (click)="setViewMode('table')">
|
||||||
|
<span class="material-symbols-outlined">
|
||||||
|
table_rows_narrow
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-outline-primary align-content-center align-items-center" *ngIf="viewMode == 'table'" (click)="setViewMode('grid')">
|
||||||
|
<span class="material-symbols-outlined">
|
||||||
|
grid_on</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- filter switches END -->
|
<!-- filter switches END -->
|
||||||
|
|
||||||
@@ -121,7 +133,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<app-dynamic-entry-list [entries]="entriesToShow" (onEntryRemove)="entryRemoved($event)"></app-dynamic-entry-list>
|
<app-library-table *ngIf="viewMode == 'table'" [entries]="entriesToShow"
|
||||||
|
(onEntryRemove)="entryRemoved($event)"></app-library-table>
|
||||||
|
|
||||||
|
<app-dynamic-entry-list *ngIf="viewMode == 'grid'" [entries]="entriesToShow"
|
||||||
|
(onEntryRemove)="entryRemoved($event)"></app-dynamic-entry-list>
|
||||||
|
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LibraryPageComponent } from './library-page.component';
|
||||||
|
|
||||||
|
describe('LibraryPageComponent', () => {
|
||||||
|
let component: LibraryPageComponent;
|
||||||
|
let fixture: ComponentFixture<LibraryPageComponent>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [LibraryPageComponent]
|
||||||
|
});
|
||||||
|
fixture = TestBed.createComponent(LibraryPageComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
+22
-7
@@ -1,16 +1,16 @@
|
|||||||
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
|
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../../shared/models/entry.model';
|
||||||
import { LibraryService } from '../../core/services/library.service';
|
import { LibraryService } from '../../../core/services/library.service';
|
||||||
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
|
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
|
||||||
import { LibraryQueryParams } from '../../shared/models/LibraryQueryParams';
|
import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
|
||||||
|
|
||||||
declare var $: any;
|
declare var $: any;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-library',
|
selector: 'app-library-page',
|
||||||
templateUrl: './library.component.html',
|
templateUrl: './library-page.component.html',
|
||||||
styleUrls: ['./library.component.css'],
|
styleUrls: ['./library-page.component.css'],
|
||||||
})
|
})
|
||||||
export class LibraryComponent implements OnInit, AfterViewInit {
|
export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||||
entries: Entry[] = [];
|
entries: Entry[] = [];
|
||||||
entriesToShow: Entry[] = [];
|
entriesToShow: Entry[] = [];
|
||||||
|
|
||||||
@@ -20,6 +20,8 @@ export class LibraryComponent implements OnInit, AfterViewInit {
|
|||||||
currentPage: number = 1;
|
currentPage: number = 1;
|
||||||
pageSize: number = 10;
|
pageSize: number = 10;
|
||||||
|
|
||||||
|
viewMode: string = 'grid';
|
||||||
|
|
||||||
// ? filter
|
// ? filter
|
||||||
years: number[] = [];
|
years: number[] = [];
|
||||||
genres: string[] = [
|
genres: string[] = [
|
||||||
@@ -79,6 +81,8 @@ export class LibraryComponent implements OnInit, AfterViewInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
this.getDefaultViewMode();
|
||||||
|
|
||||||
this.pageSize = await this.getDefaultPageSize();
|
this.pageSize = await this.getDefaultPageSize();
|
||||||
await this.getEntries(true);
|
await this.getEntries(true);
|
||||||
// this.router.events.subscribe((event) => {
|
// this.router.events.subscribe((event) => {
|
||||||
@@ -105,6 +109,14 @@ export class LibraryComponent implements OnInit, AfterViewInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDefaultViewMode() {
|
||||||
|
return 'grid';
|
||||||
|
}
|
||||||
|
|
||||||
|
setViewMode(mode: string) {
|
||||||
|
this.viewMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
// ! FILTER
|
// ! FILTER
|
||||||
getQueryParameters() {
|
getQueryParameters() {
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.route.queryParams.subscribe((params) => {
|
||||||
@@ -197,6 +209,9 @@ export class LibraryComponent implements OnInit, AfterViewInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function will generate a bunch of years starting from 1950 to the current year
|
||||||
|
*/
|
||||||
populateYears() {
|
populateYears() {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
for (let year = currentYear; year >= 1950; year--) {
|
for (let year = currentYear; year >= 1950; year--) {
|
||||||
Whitespace-only changes.
+45
@@ -0,0 +1,45 @@
|
|||||||
|
<td>
|
||||||
|
<input class="form-check-input" type="checkbox">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="d-flex align-items-center gap-3">
|
||||||
|
<div class="product-box">
|
||||||
|
<img [src]="getLogoPath()" width="80" class="rounded-3" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="product-info">
|
||||||
|
<a href="javascript:;" class="product-title">{{entry.title}}</a>
|
||||||
|
<p class="mb-0 product-category" *ngIf="entry.is_tvseries">{{entry.seasons.length}}
|
||||||
|
Season{{entry.seasons.length
|
||||||
|
> 1 ? 's' : ''}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>{{entry.is_tvseries ? 'Series' : 'Movie'}}</td>
|
||||||
|
<td>
|
||||||
|
<div class="product-tags">
|
||||||
|
<a href="javascript:;" class="btn-tags" *ngFor="let genre of entry.genres">{{genre}}</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="product-rating">
|
||||||
|
<i class="bi bi-star-fill text-warning me-2"></i><span>{{entry.entryRating.tmdb_rating |
|
||||||
|
floatFormat:1}}</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<!-- <td>
|
||||||
|
<a href="javascript:;">Michle Shoes England</a>
|
||||||
|
</td> -->
|
||||||
|
<td>{{entry.release_date | dateFormat:'MMM dd, yyyy '}}</td>
|
||||||
|
<td>{{entry.date_first_seen | dateFormat:'MMM dd, yyyy '}}</td>
|
||||||
|
<td>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret" type="button"
|
||||||
|
data-bs-toggle="dropdown">
|
||||||
|
<i class="bi bi-three-dots"></i>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li (click)="removeEntry(entry.id)"><a class="dropdown-item">Delete</a></li>
|
||||||
|
<li (click)="showAddToListModal()"><a class="dropdown-item">Add to collection</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LibraryTableLineComponent } from './library-table-line.component';
|
||||||
|
|
||||||
|
describe('LibraryTableLineComponent', () => {
|
||||||
|
let component: LibraryTableLineComponent;
|
||||||
|
let fixture: ComponentFixture<LibraryTableLineComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [LibraryTableLineComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(LibraryTableLineComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
import {
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
Input,
|
||||||
|
Output,
|
||||||
|
ViewEncapsulation,
|
||||||
|
} from '@angular/core';
|
||||||
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { Entry } from '../../../shared/models/entry.model';
|
||||||
|
import { LibraryService } from '../../../core/services/library.service';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ConfirmModalComponent } from '../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
|
import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'tr [app-library-table-line]',
|
||||||
|
templateUrl: './library-table-line.component.html',
|
||||||
|
styleUrl: './library-table-line.component.css',
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
animations: [
|
||||||
|
trigger('fadeInOut', [
|
||||||
|
transition(':enter', [
|
||||||
|
style({ opacity: 0 }),
|
||||||
|
animate('0.5s ease-out', style({ opacity: 1 })),
|
||||||
|
]),
|
||||||
|
transition(':leave', [animate('0.5s ease-in', style({ opacity: 0 }))]),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class LibraryTableLineComponent {
|
||||||
|
@Output() onEntryRemove = new EventEmitter();
|
||||||
|
@Output() onEntryUpdate = new EventEmitter();
|
||||||
|
@Input() entry!: Entry;
|
||||||
|
|
||||||
|
lockActions: boolean = false;
|
||||||
|
|
||||||
|
animationDirection = 'topToBottom';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private libraryService: LibraryService,
|
||||||
|
public dialog: MatDialog,
|
||||||
|
private router: Router
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
if (!this.entry.isInLibrary) {
|
||||||
|
this.libraryService.isInLibrary(this.entry.entryId.tmdb_id).subscribe({
|
||||||
|
next: (e) => {
|
||||||
|
if (e != null) {
|
||||||
|
e.isInLibrary = true;
|
||||||
|
this.entry = e;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.setRandomDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
setRandomDirection() {
|
||||||
|
const directions = [
|
||||||
|
'topToBottom',
|
||||||
|
'bottomToTop',
|
||||||
|
'leftToRight',
|
||||||
|
'rightToLeft',
|
||||||
|
];
|
||||||
|
this.animationDirection =
|
||||||
|
directions[Math.floor(Math.random() * directions.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
get releaseYear(): number {
|
||||||
|
return new Date(this.entry.release_date).getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
get formattedRate(): string {
|
||||||
|
return this.entry.entryRating.tmdb_rating.toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
addEntry(tmdb_id: string, is_tvserie: boolean) {
|
||||||
|
// console.log('Adding Entry To Library.');
|
||||||
|
this.lockActions = true;
|
||||||
|
let obs = this.libraryService.addEntry(tmdb_id, is_tvserie).subscribe({
|
||||||
|
next: (entry) => {
|
||||||
|
if (entry != null) {
|
||||||
|
// TODO success notification
|
||||||
|
// console.log(`Entry added to library`, entry);
|
||||||
|
entry.isInLibrary = true;
|
||||||
|
this.entry = entry;
|
||||||
|
this.libraryService.refrechEntries().subscribe();
|
||||||
|
this.onEntryUpdate.emit(this.entry.id);
|
||||||
|
this.lockActions = false;
|
||||||
|
obs.unsubscribe();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
// TODO error notification
|
||||||
|
console.error('Error adding entry:', error);
|
||||||
|
this.lockActions = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEntry(id: number) {
|
||||||
|
this.lockActions = true;
|
||||||
|
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||||
|
width: '400px',
|
||||||
|
data: {
|
||||||
|
title: 'Confirmation',
|
||||||
|
message: `Are you sure you want to remove ${this.entry.title} from the library?`,
|
||||||
|
type: 'danger',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((result) => {
|
||||||
|
if (!result || result.confirmed != true) {
|
||||||
|
this.lockActions = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.libraryService.deleteEntry(id).subscribe({
|
||||||
|
next: (response) => {
|
||||||
|
console.log('Entry successfully deleted.', response);
|
||||||
|
// ? emit to dynamic entry list
|
||||||
|
this.entry.id = 0;
|
||||||
|
this.entry.isInLibrary = false;
|
||||||
|
this.onEntryRemove.emit(this.entry.id);
|
||||||
|
this.libraryService.refrechEntries().subscribe();
|
||||||
|
// todo entry removed notification
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
// TODO show notification
|
||||||
|
console.error('Error deleting entry:', error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.lockActions = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
showAddToListModal() {
|
||||||
|
if (!this.entry) return;
|
||||||
|
|
||||||
|
this.lockActions = true;
|
||||||
|
const dialogRef = this.dialog.open(UserCollectionsModalComponent, {
|
||||||
|
width: '400px',
|
||||||
|
height: '55%',
|
||||||
|
data: {
|
||||||
|
entryId: this.entry.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((result) => {
|
||||||
|
this.lockActions = false;
|
||||||
|
// console.log('Modal Closed: ', result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cardClick() {
|
||||||
|
if (this.entry.isInLibrary)
|
||||||
|
this.router.navigate([`/entries/${this.entry.id}`]);
|
||||||
|
else
|
||||||
|
window.open(
|
||||||
|
'https://www.themoviedb.org/movie/' + this.entry.entryId.tmdb_id,
|
||||||
|
'_blank'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTmdbLink() {
|
||||||
|
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||||
|
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
isCertainRoute(): boolean {
|
||||||
|
return (
|
||||||
|
this.router.isActive('/search', true) ||
|
||||||
|
this.router.isActive('/popular', true) ||
|
||||||
|
this.router.isActive('/trending', true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get posterPath() {
|
||||||
|
// * Not in library, use TMDB poster
|
||||||
|
if (!this.entry.isInLibrary)
|
||||||
|
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||||
|
|
||||||
|
// * Is in library: use a local poster
|
||||||
|
if (this.entry.medias) {
|
||||||
|
const selectedPosters = this.entry.medias.filter(
|
||||||
|
(m) => m.type == 'poster' && m.is_selected
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
selectedPosters.length &&
|
||||||
|
selectedPosters[0] &&
|
||||||
|
selectedPosters[0].path
|
||||||
|
) {
|
||||||
|
const name = selectedPosters[0].path.split('.')[0];
|
||||||
|
const extention = selectedPosters[0].path.split('.')[1];
|
||||||
|
return `http://localhost:4000/api/v1/media/entries/posters/${name}_preview.${extention}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * No local poster available, Use TMDB poster
|
||||||
|
if (this.entry.poster_path)
|
||||||
|
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||||
|
|
||||||
|
// * No poster found, use default poster image as a last stand
|
||||||
|
return 'assets/images/default/default-poster.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
get runtime() {
|
||||||
|
if (this.entry.runtime == null) return '';
|
||||||
|
return this.entry.runtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogoPath() {
|
||||||
|
// * Is in library: use a local logo
|
||||||
|
if (this.entry.medias) {
|
||||||
|
const selectedLogos = this.entry.medias.filter(
|
||||||
|
(m) => m.type == 'logo' && m.is_selected
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
selectedLogos.length &&
|
||||||
|
selectedLogos[0] &&
|
||||||
|
selectedLogos[0].path
|
||||||
|
) {
|
||||||
|
const name = selectedLogos[0].path.split('.')[0];
|
||||||
|
const extention = selectedLogos[0].path.split('.')[1];
|
||||||
|
return `http://localhost:4000/api/v1/media/entries/logos/${name}.${extention}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * No poster found, use default poster image as a last stand
|
||||||
|
return 'assets/images/default/default-logo.png';
|
||||||
|
}
|
||||||
|
}
|
||||||
Whitespace-only changes.
@@ -0,0 +1,33 @@
|
|||||||
|
<div class="card mt-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="product-table">
|
||||||
|
<div class="table-responsive white-space-nowrap">
|
||||||
|
<table class="table align-middle">
|
||||||
|
<thead class="table-light">
|
||||||
|
<!-- * table head start -->
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<input class="form-check-input" type="checkbox">
|
||||||
|
</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Genres</th>
|
||||||
|
<th>Rating</th>
|
||||||
|
<th>Released</th>
|
||||||
|
<th>Date Seen</th>
|
||||||
|
<th class="align-self-center">Action</th>
|
||||||
|
</tr>
|
||||||
|
<!-- + table head end -->
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- * table body start -->
|
||||||
|
<ng-container *ngFor="let entry of entries">
|
||||||
|
<tr app-library-table-line [entry]="entry"></tr>
|
||||||
|
</ng-container>
|
||||||
|
<!-- + table body end -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LibraryTableComponent } from './library-table.component';
|
||||||
|
|
||||||
|
describe('LibraryTableComponent', () => {
|
||||||
|
let component: LibraryTableComponent;
|
||||||
|
let fixture: ComponentFixture<LibraryTableComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [LibraryTableComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(LibraryTableComponent);
|
||||||
|
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-library-table',
|
||||||
|
templateUrl: './library-table.component.html',
|
||||||
|
styleUrl: './library-table.component.css',
|
||||||
|
animations: [
|
||||||
|
trigger('animateDestroy', [
|
||||||
|
state('void', style({ opacity: '0' })),
|
||||||
|
transition('* => void', animate('300ms ease')),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class LibraryTableComponent {
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { LibraryComponent } from './library.component';
|
|
||||||
|
|
||||||
describe('LibraryComponent', () => {
|
|
||||||
let component: LibraryComponent;
|
|
||||||
let fixture: ComponentFixture<LibraryComponent>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [LibraryComponent]
|
|
||||||
});
|
|
||||||
fixture = TestBed.createComponent(LibraryComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -29,7 +29,7 @@ import { EpisodeSeenModalComponent } from './components/modals/episode-seen-moda
|
|||||||
DateFormatPipe,
|
DateFormatPipe,
|
||||||
FloatFormatPipe,
|
FloatFormatPipe,
|
||||||
|
|
||||||
// ? components
|
// ? modals
|
||||||
SeenModalComponent,
|
SeenModalComponent,
|
||||||
CollectionEditModalComponent,
|
CollectionEditModalComponent,
|
||||||
ConfirmModalComponent,
|
ConfirmModalComponent,
|
||||||
|
|||||||
Reference in new issue
Block a user