diff --git a/backend/routes/entry.routes.js b/backend/routes/entry.routes.js
index 65f609e..ce0a8ff 100644
--- a/backend/routes/entry.routes.js
+++ b/backend/routes/entry.routes.js
@@ -25,6 +25,7 @@ entryRouter.get('/', async (req, res) => {
{ model: EntryId, as: 'entryId' },
{ model: EntryRating, as: 'entryRating' },
{ model: Media, as: 'medias' },
+ { model: Season, as: 'seasons' },
{
model: Genre,
as: 'genres',
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index f8b6c53..00448a4 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -4,7 +4,7 @@ import { HomeComponent } from './features/home/home.component';
import { SearchPageComponent } from './features/discover/search-page/search-page.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 { LibraryPageComponent } from './features/library/library-page/library-page.component';
import { FavoritComponent } from './features/favorit/favorit.component';
import { WatchlistComponent } from './features/watchlist/watchlist.component';
@@ -15,7 +15,7 @@ const routes: Routes = [
{ path: 'popular', component: PopularComponent },
{ path: 'trending', component: TrendingComponent },
- { path: 'library', component: LibraryComponent },
+ { path: 'library', component: LibraryPageComponent },
{ path: 'favorit', component: FavoritComponent },
{ path: 'watchlist', component: WatchlistComponent },
{
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index 2efae5e..ae1b107 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -15,7 +15,7 @@ import { HomeComponent } from './features/home/home.component';
import { PopularComponent } from './features/discover/popular/popular.component';
import { TrendingComponent } from './features/discover/trending/trending.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 { 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 { SharedModule } from './shared/shared.module';
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({
imports: [
@@ -53,7 +55,9 @@ import { ToastrModule } from 'ngx-toastr';
PopularComponent,
TrendingComponent,
SearchPageComponent,
- LibraryComponent,
+ LibraryPageComponent,
+ LibraryTableComponent,
+ LibraryTableLineComponent,
FavoritComponent,
WatchlistComponent,
diff --git a/frontend/src/app/features/collections/user-collection-info/collection-entry-table/collection-entry-table.component.ts b/frontend/src/app/features/collections/user-collection-info/collection-entry-table/collection-entry-table.component.ts
index 4fe8814..35d32b0 100644
--- a/frontend/src/app/features/collections/user-collection-info/collection-entry-table/collection-entry-table.component.ts
+++ b/frontend/src/app/features/collections/user-collection-info/collection-entry-table/collection-entry-table.component.ts
@@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core';
import { Entry } from '../../../../shared/models/entry.model';
+import { UserCollectionService } from '../../../../core/services/userCollection.service';
import {
CdkDragDrop,
CdkDragEnd,
@@ -13,7 +14,6 @@ import {
transition,
trigger,
} from '@angular/animations';
-import { UserCollectionService } from '../../../../core/services/userCollection.service';
@Component({
selector: 'app-collection-entry-table',
diff --git a/frontend/src/app/features/library/library.component.css b/frontend/src/app/features/library/library-page/library-page.component.css
similarity index 100%
rename from frontend/src/app/features/library/library.component.css
rename to frontend/src/app/features/library/library-page/library-page.component.css
diff --git a/frontend/src/app/features/library/library.component.html b/frontend/src/app/features/library/library-page/library-page.component.html
similarity index 87%
rename from frontend/src/app/features/library/library.component.html
rename to frontend/src/app/features/library/library-page/library-page.component.html
index 6c8bae7..83c45c0 100644
--- a/frontend/src/app/features/library/library.component.html
+++ b/frontend/src/app/features/library/library-page/library-page.component.html
@@ -50,12 +50,24 @@
+ [(ngModel)]="filterCriteria.matchAll" (click)="onFilterChange()">
Clear Filter
+
+
+
+
+
@@ -121,7 +133,11 @@
-
+
+
+
diff --git a/frontend/src/app/features/library/library-page/library-page.component.spec.ts b/frontend/src/app/features/library/library-page/library-page.component.spec.ts
new file mode 100644
index 0000000..5720338
--- /dev/null
+++ b/frontend/src/app/features/library/library-page/library-page.component.spec.ts
@@ -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;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ declarations: [LibraryPageComponent]
+ });
+ fixture = TestBed.createComponent(LibraryPageComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/features/library/library.component.ts b/frontend/src/app/features/library/library-page/library-page.component.ts
similarity index 94%
rename from frontend/src/app/features/library/library.component.ts
rename to frontend/src/app/features/library/library-page/library-page.component.ts
index 27d8a46..22efc7b 100644
--- a/frontend/src/app/features/library/library.component.ts
+++ b/frontend/src/app/features/library/library-page/library-page.component.ts
@@ -1,16 +1,16 @@
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
-import { Entry } from '../../shared/models/entry.model';
-import { LibraryService } from '../../core/services/library.service';
+import { Entry } from '../../../shared/models/entry.model';
+import { LibraryService } from '../../../core/services/library.service';
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
-import { LibraryQueryParams } from '../../shared/models/LibraryQueryParams';
+import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
declare var $: any;
@Component({
- selector: 'app-library',
- templateUrl: './library.component.html',
- styleUrls: ['./library.component.css'],
+ selector: 'app-library-page',
+ templateUrl: './library-page.component.html',
+ styleUrls: ['./library-page.component.css'],
})
-export class LibraryComponent implements OnInit, AfterViewInit {
+export class LibraryPageComponent implements OnInit, AfterViewInit {
entries: Entry[] = [];
entriesToShow: Entry[] = [];
@@ -20,6 +20,8 @@ export class LibraryComponent implements OnInit, AfterViewInit {
currentPage: number = 1;
pageSize: number = 10;
+ viewMode: string = 'grid';
+
// ? filter
years: number[] = [];
genres: string[] = [
@@ -79,6 +81,8 @@ export class LibraryComponent implements OnInit, AfterViewInit {
) {}
async ngOnInit() {
+ this.getDefaultViewMode();
+
this.pageSize = await this.getDefaultPageSize();
await this.getEntries(true);
// 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
getQueryParameters() {
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() {
const currentYear = new Date().getFullYear();
for (let year = currentYear; year >= 1950; year--) {
diff --git a/frontend/src/app/features/library/library-table-line/library-table-line.component.css b/frontend/src/app/features/library/library-table-line/library-table-line.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/features/library/library-table-line/library-table-line.component.html b/frontend/src/app/features/library/library-table-line/library-table-line.component.html
new file mode 100644
index 0000000..26ef445
--- /dev/null
+++ b/frontend/src/app/features/library/library-table-line/library-table-line.component.html
@@ -0,0 +1,45 @@
+
+
+ |
+
+
+
+ ![]()
+
+
+ {{entry.title}}
+ {{entry.seasons.length}}
+ Season{{entry.seasons.length
+ > 1 ? 's' : ''}}
+
+
+ |
+{{entry.is_tvseries ? 'Series' : 'Movie'}} |
+
+
+ |
+
+
+ {{entry.entryRating.tmdb_rating |
+ floatFormat:1}}
+
+ |
+
+{{entry.release_date | dateFormat:'MMM dd, yyyy '}} |
+{{entry.date_first_seen | dateFormat:'MMM dd, yyyy '}} |
+
+
+
+
+
+ |
\ No newline at end of file
diff --git a/frontend/src/app/features/library/library-table-line/library-table-line.component.spec.ts b/frontend/src/app/features/library/library-table-line/library-table-line.component.spec.ts
new file mode 100644
index 0000000..bc9c97f
--- /dev/null
+++ b/frontend/src/app/features/library/library-table-line/library-table-line.component.spec.ts
@@ -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;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [LibraryTableLineComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(LibraryTableLineComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/features/library/library-table-line/library-table-line.component.ts b/frontend/src/app/features/library/library-table-line/library-table-line.component.ts
new file mode 100644
index 0000000..339d14a
--- /dev/null
+++ b/frontend/src/app/features/library/library-table-line/library-table-line.component.ts
@@ -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';
+ }
+}
diff --git a/frontend/src/app/features/library/library-table/library-table.component.css b/frontend/src/app/features/library/library-table/library-table.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/features/library/library-table/library-table.component.html b/frontend/src/app/features/library/library-table/library-table.component.html
new file mode 100644
index 0000000..0cfade5
--- /dev/null
+++ b/frontend/src/app/features/library/library-table/library-table.component.html
@@ -0,0 +1,33 @@
+
\ No newline at end of file
diff --git a/frontend/src/app/features/library/library-table/library-table.component.spec.ts b/frontend/src/app/features/library/library-table/library-table.component.spec.ts
new file mode 100644
index 0000000..aa622d6
--- /dev/null
+++ b/frontend/src/app/features/library/library-table/library-table.component.spec.ts
@@ -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;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [LibraryTableComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(LibraryTableComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/features/library/library-table/library-table.component.ts b/frontend/src/app/features/library/library-table/library-table.component.ts
new file mode 100644
index 0000000..5916c28
--- /dev/null
+++ b/frontend/src/app/features/library/library-table/library-table.component.ts
@@ -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;
+ }
+}
diff --git a/frontend/src/app/features/library/library.component.spec.ts b/frontend/src/app/features/library/library.component.spec.ts
deleted file mode 100644
index 23e4b04..0000000
--- a/frontend/src/app/features/library/library.component.spec.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { LibraryComponent } from './library.component';
-
-describe('LibraryComponent', () => {
- let component: LibraryComponent;
- let fixture: ComponentFixture;
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- declarations: [LibraryComponent]
- });
- fixture = TestBed.createComponent(LibraryComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index 6ea2d31..ad4e6f7 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -29,7 +29,7 @@ import { EpisodeSeenModalComponent } from './components/modals/episode-seen-moda
DateFormatPipe,
FloatFormatPipe,
- // ? components
+ // ? modals
SeenModalComponent,
CollectionEditModalComponent,
ConfirmModalComponent,