diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index 00448a4..ff27e1f 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -4,9 +4,8 @@ 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 { LibraryPageComponent } from './features/library/library-page/library-page.component';
-import { FavoritComponent } from './features/favorit/favorit.component';
-import { WatchlistComponent } from './features/watchlist/watchlist.component';
+import { FavoritComponent } from './features/library/favorit-page/favorit.component';
+import { WatchlistComponent } from './features/library/watchlist-page/watchlist.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
@@ -15,7 +14,13 @@ const routes: Routes = [
{ path: 'popular', component: PopularComponent },
{ path: 'trending', component: TrendingComponent },
- { path: 'library', component: LibraryPageComponent },
+ {
+ path: 'library',
+ loadChildren: () =>
+ import('./features/library/library.module').then(
+ (m) => m.LibraryModule
+ ),
+ },
{ 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 ae1b107..33e8486 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -15,17 +15,9 @@ 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 { 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';
-import { MainCardComponent } from './shared/components/cards/main-card/main-card.component';
-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: [
@@ -55,16 +47,7 @@ import { LibraryTableLineComponent } from './features/library/library-table-line
PopularComponent,
TrendingComponent,
SearchPageComponent,
- LibraryPageComponent,
- LibraryTableComponent,
- LibraryTableLineComponent,
- FavoritComponent,
- WatchlistComponent,
- // ? temp shared components
- MainCardComponent,
- DynamicEntryListComponent,
- NotificationPopupComponent,
],
providers: [DatePipe],
bootstrap: [AppComponent],
diff --git a/frontend/src/app/features/favorit/favorit.component.html b/frontend/src/app/features/favorit/favorit.component.html
deleted file mode 100644
index 21a52f2..0000000
--- a/frontend/src/app/features/favorit/favorit.component.html
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
Favorit
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/src/app/features/watchlist/watchlist.component.css b/frontend/src/app/features/library/entries-display/entries-display.component.css
similarity index 71%
rename from frontend/src/app/features/watchlist/watchlist.component.css
rename to frontend/src/app/features/library/entries-display/entries-display.component.css
index 2709cf5..e436a64 100644
--- a/frontend/src/app/features/watchlist/watchlist.component.css
+++ b/frontend/src/app/features/library/entries-display/entries-display.component.css
@@ -1,3 +1,4 @@
+/* ! buttons style */
.custom-group .form-select {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
@@ -33,4 +34,22 @@
#single-select-field {
max-width: 120px;
-}
\ No newline at end of file
+}
+
+.align-items-baseline {
+ align-items: baseline;
+}
+
+/* ! filter switches style */
+.form-check-label {
+ margin-bottom: 0;
+}
+
+a.clear-filter-link {
+ display: inline-block;
+ padding: 0.375rem 0;
+}
+
+.filter-switches {
+ margin-left: auto;
+}
diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.html b/frontend/src/app/features/library/entries-display/entries-display.component.html
new file mode 100644
index 0000000..b502e4a
--- /dev/null
+++ b/frontend/src/app/features/library/entries-display/entries-display.component.html
@@ -0,0 +1,127 @@
+
+
+
Library
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.spec.ts b/frontend/src/app/features/library/entries-display/entries-display.component.spec.ts
new file mode 100644
index 0000000..280a322
--- /dev/null
+++ b/frontend/src/app/features/library/entries-display/entries-display.component.spec.ts
@@ -0,0 +1,28 @@
+/* tslint:disable:no-unused-variable */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { DebugElement } from '@angular/core';
+
+import { EntriesDisplayComponent } from './entries-display.component';
+
+describe('EntriesDisplayComponent', () => {
+ let component: EntriesDisplayComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ EntriesDisplayComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(EntriesDisplayComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.ts b/frontend/src/app/features/library/entries-display/entries-display.component.ts
new file mode 100644
index 0000000..3d2e552
--- /dev/null
+++ b/frontend/src/app/features/library/entries-display/entries-display.component.ts
@@ -0,0 +1,431 @@
+import {
+ AfterViewInit,
+ Component,
+ Input,
+ OnDestroy,
+ OnInit,
+} from '@angular/core';
+import { Entry } from '../../../shared/models/entry.model';
+import { LibraryService } from '../../../core/services/library.service';
+import { ToastrService } from 'ngx-toastr';
+import { SettingsService } from '../../../core/services/settings.service';
+import { Settings } from '../../../shared/models/settings.model';
+import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
+import { ActivatedRoute, Router } from '@angular/router';
+
+declare var $: any;
+
+@Component({
+ selector: 'app-entries-display',
+ templateUrl: './entries-display.component.html',
+ styleUrls: ['./entries-display.component.css'],
+})
+export class EntriesDisplayComponent
+ implements OnInit, AfterViewInit, OnDestroy
+{
+ @Input() displayType: string = 'favorit';
+
+ entryType: number = 0;
+
+ entries: Entry[] = [];
+ entriesToShow: Entry[] = [];
+
+ entriesCount: number = 0;
+ maxPage: number = 10;
+ currentPage: number = 1;
+ pageSize: number = 10;
+
+ viewMode: string = 'grid';
+
+ // ? filter
+ select2Visible: boolean = false; // temp fix to select flashing
+ years: number[] = [];
+ genres: string[] = [
+ 'Action & Adventure',
+ 'Animation',
+ 'Comedy',
+ 'Crime',
+ 'Documentary',
+ 'Drama',
+ 'Family',
+ 'Kids',
+ 'Mystery',
+ 'News',
+ 'Reality',
+ 'Sci-Fi & Fantasy',
+ 'Soap',
+ 'Talk',
+ 'War & Politics',
+ 'Western',
+ 'Action',
+ 'Adventure',
+ 'Fantasy',
+ 'History',
+ 'Horror',
+ 'Music',
+ 'Romance',
+ 'Science Fiction',
+ 'TV Movie',
+ 'Thriller',
+ 'War',
+ ];
+
+ filterCriteria: {
+ title?: string;
+ type: number;
+ years?: number[];
+ genres?: string[];
+ matchAll: boolean;
+ } = {
+ title: '',
+ type: 0,
+ years: [],
+ genres: [],
+ matchAll: true,
+ };
+
+ constructor(
+ private router: Router,
+ private route: ActivatedRoute,
+ private libraryService: LibraryService,
+ private settingsService: SettingsService,
+ private toastr: ToastrService
+ ) {}
+
+ async ngOnInit() {
+ this.getDefaultViewMode();
+
+ this.pageSize = this.getDefaultPageSize();
+ this.getEntries();
+ await this.populateYears();
+ }
+
+ ngAfterViewInit() {
+ setTimeout(() => {
+ $('#year-select2')
+ .select2({
+ placeholder: 'Year(s)...',
+ allowClear: true,
+ closeOnSelect: false,
+ })
+ .on('change', (event: { target: any }) => {
+ this.onYearsChange(event);
+ });
+
+ $('#genre-select2')
+ .select2({
+ placeholder: 'Genre(s)...',
+ allowClear: true,
+ closeOnSelect: false,
+ })
+ .on('change', (event: { target: any }) => {
+ this.onGenresChange(event);
+ });
+ this.select2Visible = true;
+ }, 0);
+ }
+
+ ngOnDestroy() {
+ if ($('#year-select2').data('select2')) {
+ $('#year-select2').select2('destroy');
+ }
+ if ($('#genre-select2').data('select2')) {
+ $('#genre-select2').select2('destroy');
+ }
+ }
+
+ // uses libraryService to get library all content
+ getEntries(forceFetch: boolean = false) {
+ this.libraryService.getAllEntries(forceFetch).subscribe({
+ next: (entries) => {
+ if (this.displayType == 'favorit') {
+ this.entries = entries.filter((e) => e.favorit);
+ } else if (this.displayType == 'watchlist') {
+ this.entries = entries.filter((e) => e.watchlist);
+ }
+ this.getQueryParameters();
+ this.filterEntries();
+ },
+ error: (error) => {
+ console.log(`Couldn't get entries.`, error);
+ this.toastr.success(
+ 'Error',
+ `Couldn't get ${this.displayType} items.`,
+ {
+ tapToDismiss: true,
+ progressBar: true,
+ progressAnimation: 'increasing',
+ }
+ );
+ },
+ });
+ }
+
+ // ! FILTER
+ async filterEntries() {
+ var temp = [] as Entry[];
+
+ const formattedTitle =
+ this.filterCriteria.title?.toLowerCase().trim() || '';
+ temp = await this.entries.filter((entry) => {
+ // * Type check
+ let filterType = this.filterCriteria.type - 1 == 0 ? false : true;
+ if (this.filterCriteria.type != 0 && filterType != entry.is_tvseries) {
+ return false; // Skip entry if the type does not match, unless type is 'all' (0)
+ }
+
+ const year = new Date(entry.release_date).getFullYear();
+ // ! Match all criteria logic
+ if (this.filterCriteria.matchAll) {
+ return (
+ (formattedTitle
+ ? entry.title.toLowerCase().includes(formattedTitle) ||
+ entry.original_title.toLowerCase().includes(formattedTitle)
+ : true) &&
+ (this.filterCriteria.genres?.length
+ ? this.filterCriteria.genres.every((genre) =>
+ entry.genres.includes(genre)
+ )
+ : true) &&
+ (this.filterCriteria.years?.length
+ ? this.filterCriteria.years.includes(year)
+ : true)
+ );
+ }
+
+ // ! Match at least one criteria logic
+ return (
+ (formattedTitle
+ ? entry.title.toLowerCase().includes(formattedTitle) ||
+ entry.original_title.toLowerCase().includes(formattedTitle)
+ : true) ||
+ (this.filterCriteria.genres?.length &&
+ this.filterCriteria.genres.some((genre) =>
+ entry.genres.includes(genre)
+ )) ||
+ (this.filterCriteria.years?.length &&
+ this.filterCriteria.years.includes(year))
+ );
+ });
+
+ // ? sort filter
+ temp = await this.sortEntries(temp);
+
+ this.entriesCount = temp.length;
+ this.maxPage = Math.ceil(this.entriesCount / this.pageSize);
+ if (this.currentPage > this.maxPage) this.currentPage = this.maxPage; // fix for when 1 entry in the last page is removed
+
+ const startIndex = (this.currentPage - 1) * this.pageSize;
+ const endIndex = startIndex + this.pageSize;
+
+ this.entriesToShow = temp.slice(startIndex, endIndex);
+ }
+
+ clearFilter() {
+ this.filterCriteria = {
+ title: '',
+ type: 0,
+ years: [],
+ genres: [],
+ matchAll: true,
+ };
+
+ this.setQueryParameters();
+ this.filterEntries();
+ }
+
+ sortEntries(entries: Entry[]) {
+ return entries.sort(
+ (a, b) =>
+ new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
+ );
+ }
+
+ getQueryParameters() {
+ this.route.queryParams.subscribe((params) => {
+ this.currentPage = params['page'] ? parseInt(params['page'], 10) : 1;
+ this.filterCriteria.title = params['title'] || '';
+ this.filterCriteria.years = params['years']
+ ? params['years'].split(',')
+ : [];
+ this.filterCriteria.genres = params['genres']
+ ? params['genres'].split(',')
+ : [];
+ this.filterCriteria.type = params.hasOwnProperty('type')
+ ? params['type']
+ : 0;
+ });
+ }
+
+ setQueryParameters() {
+ let params = { page: this.currentPage } as LibraryQueryParams;
+
+ // ? title
+ if (this.filterCriteria.title?.trim() != '') {
+ params.title = this.filterCriteria.title?.trim();
+ }
+
+ // ? years
+ if (this.filterCriteria.years?.length) {
+ params.years = this.filterCriteria.years.join(',');
+ }
+ // ? genres
+ if (this.filterCriteria.genres?.length) {
+ params.genres = this.filterCriteria.genres.join(',');
+ }
+
+ // ? type
+ if (this.filterCriteria.type != 0) {
+ params.type = this.filterCriteria.type;
+ }
+
+ this.router.navigate([], {
+ relativeTo: this.route,
+ queryParams: params,
+ queryParamsHandling: '',
+ });
+ }
+
+ populateYears() {
+ const currentYear = new Date().getFullYear();
+ for (let year = currentYear; year >= 1950; year--) {
+ this.years.push(year);
+ }
+ }
+
+ // + FILTER END
+
+ getDefaultViewMode() {
+ this.settingsService.getSettings().subscribe({
+ next: (s) => {
+ if (this.displayType == 'favorit') {
+ this.viewMode = s.favoritViewMode || 'grid';
+ } else if (this.displayType == 'watchlist') {
+ this.viewMode = s.watchlistViewMode || 'grid';
+ }
+ },
+ error: (error) => {
+ console.log(`Couldn't get settings information, `, error);
+ },
+ });
+ }
+
+ setViewMode(mode: string) {
+ this.viewMode = mode;
+ let newSettings = {} as Settings;
+ if (this.displayType == 'favorit') {
+ newSettings = { favoritViewMode: this.viewMode } as Settings;
+ } else if (this.displayType == 'watchlist') {
+ newSettings = { watchlistViewMode: this.viewMode } as Settings;
+ }
+ this.settingsService.updateSettings(newSettings).subscribe({
+ next: (s) => {
+ // ? view mode updated
+ },
+ error: (error) => {
+ // error updating view mode
+ },
+ });
+ }
+
+ // ! calculated fields
+ moviesCount() {
+ return this.entries.filter((e) => !e.is_tvseries).length;
+ }
+
+ seriesCount() {
+ return this.entries.filter((e) => e.is_tvseries).length;
+ }
+
+ hiddenCount() {
+ return this.entries.filter((e) => e.hidden).length;
+ }
+
+ // ! events
+ entryRemoved(event: Event) {
+ this.entries = this.entries.filter(
+ (e) => e.id.toString() != event.toString()
+ );
+ this.pageSize = this.getDefaultPageSize();
+ this.filterEntries();
+ }
+
+ // * filter events
+ onYearsChange(event: any) {
+ this.currentPage = 1;
+
+ const selected = $(event.target).val();
+ this.filterCriteria.years = Array.isArray(selected)
+ ? selected.map(Number)
+ : [Number(selected)];
+
+ this.filterEntries();
+ this.setQueryParameters(); // * update url query
+ }
+
+ onGenresChange(event: any) {
+ this.currentPage = 1;
+
+ const selected = $(event.target).val();
+ this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
+
+ this.filterEntries();
+ this.setQueryParameters(); // * update url query
+ }
+
+ onFilterChange() {
+ this.currentPage = 1;
+ this.filterEntries();
+ this.setQueryParameters(); // * update url query
+ }
+
+ onEntryTypeChange(entryType: number) {
+ this.filterCriteria.type = entryType;
+
+ this.currentPage = 1;
+ this.filterEntries();
+ this.setQueryParameters(); // * update url query
+ }
+ // + FILTER EVENTS END
+ // + EVENTS END
+
+ // ! pagination
+ setPageSize(event: any) {
+ this.pageSize = event.target.value;
+ this.filterEntries();
+ }
+
+ getDefaultPageSize() {
+ // TODO get default page size from settings service
+ return 54;
+ }
+
+ goToPage(page: number) {
+ this.currentPage = page;
+ this.filterEntries();
+ }
+
+ get pageNumbers(): number[] {
+ let pagesToShow = 5; // Total pages to show at any time
+ let startPage: number, endPage: number;
+
+ if (this.maxPage <= pagesToShow) {
+ startPage = 1;
+ endPage = this.maxPage;
+ } else {
+ startPage = Math.max(this.currentPage - Math.floor(pagesToShow / 2), 1);
+ endPage = startPage + pagesToShow - 1;
+
+ if (endPage >= this.maxPage) {
+ endPage = this.maxPage;
+ startPage = endPage - pagesToShow + 1;
+ }
+ }
+
+ // Generate the page numbers array.
+ return Array.from(
+ { length: endPage - startPage + 1 },
+ (_, i) => startPage + i
+ );
+ }
+}
diff --git a/frontend/src/app/features/favorit/favorit.component.css b/frontend/src/app/features/library/favorit-page/favorit.component.css
similarity index 100%
rename from frontend/src/app/features/favorit/favorit.component.css
rename to frontend/src/app/features/library/favorit-page/favorit.component.css
diff --git a/frontend/src/app/features/library/favorit-page/favorit.component.html b/frontend/src/app/features/library/favorit-page/favorit.component.html
new file mode 100644
index 0000000..89017cd
--- /dev/null
+++ b/frontend/src/app/features/library/favorit-page/favorit.component.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/app/features/favorit/favorit.component.spec.ts b/frontend/src/app/features/library/favorit-page/favorit.component.spec.ts
similarity index 100%
rename from frontend/src/app/features/favorit/favorit.component.spec.ts
rename to frontend/src/app/features/library/favorit-page/favorit.component.spec.ts
diff --git a/frontend/src/app/features/favorit/favorit.component.ts b/frontend/src/app/features/library/favorit-page/favorit.component.ts
similarity index 95%
rename from frontend/src/app/features/favorit/favorit.component.ts
rename to frontend/src/app/features/library/favorit-page/favorit.component.ts
index 6a7f05e..44227eb 100644
--- a/frontend/src/app/features/favorit/favorit.component.ts
+++ b/frontend/src/app/features/library/favorit-page/favorit.component.ts
@@ -1,6 +1,6 @@
import { Component } 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';
@Component({
selector: 'app-favorit',
diff --git a/frontend/src/app/features/library/library-routing.module.ts b/frontend/src/app/features/library/library-routing.module.ts
new file mode 100644
index 0000000..b42e800
--- /dev/null
+++ b/frontend/src/app/features/library/library-routing.module.ts
@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+import { LibraryPageComponent } from './library-page/library-page.component';
+
+// ! /library
+const routes: Routes = [
+ {
+ path: '',
+ component: LibraryPageComponent,
+ },
+];
+
+@NgModule({
+ imports: [RouterModule.forChild(routes)],
+ exports: [RouterModule],
+})
+export class LibraryRoutingModule {}
diff --git a/frontend/src/app/features/library/library.module.ts b/frontend/src/app/features/library/library.module.ts
new file mode 100644
index 0000000..e512b18
--- /dev/null
+++ b/frontend/src/app/features/library/library.module.ts
@@ -0,0 +1,39 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { SharedModule } from '../../shared/shared.module';
+
+import { DragDropModule } from '@angular/cdk/drag-drop';
+
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { LibraryPageComponent } from './library-page/library-page.component';
+import { LibraryTableComponent } from './library-table/library-table.component';
+import { LibraryTableLineComponent } from './library-table-line/library-table-line.component';
+import { LibraryRoutingModule } from './library-routing.module';
+import { WatchlistComponent } from './watchlist-page/watchlist.component';
+import { EntriesDisplayComponent } from './entries-display/entries-display.component';
+import { FavoritComponent } from './favorit-page/favorit.component';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ SharedModule,
+
+ FormsModule,
+ ReactiveFormsModule,
+
+ LibraryRoutingModule,
+
+ DragDropModule,
+ ],
+ declarations: [
+ EntriesDisplayComponent,
+ LibraryPageComponent,
+ WatchlistComponent,
+ FavoritComponent,
+
+ LibraryTableComponent,
+ LibraryTableLineComponent,
+ ],
+ exports: [],
+})
+export class LibraryModule {}
diff --git a/frontend/src/app/features/library/watchlist-page/watchlist.component.css b/frontend/src/app/features/library/watchlist-page/watchlist.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/features/library/watchlist-page/watchlist.component.html b/frontend/src/app/features/library/watchlist-page/watchlist.component.html
new file mode 100644
index 0000000..7535d39
--- /dev/null
+++ b/frontend/src/app/features/library/watchlist-page/watchlist.component.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/app/features/watchlist/watchlist.component.spec.ts b/frontend/src/app/features/library/watchlist-page/watchlist.component.spec.ts
similarity index 100%
rename from frontend/src/app/features/watchlist/watchlist.component.spec.ts
rename to frontend/src/app/features/library/watchlist-page/watchlist.component.spec.ts
diff --git a/frontend/src/app/features/library/watchlist-page/watchlist.component.ts b/frontend/src/app/features/library/watchlist-page/watchlist.component.ts
new file mode 100644
index 0000000..10d6ba5
--- /dev/null
+++ b/frontend/src/app/features/library/watchlist-page/watchlist.component.ts
@@ -0,0 +1,17 @@
+import { Component, OnInit } from '@angular/core';
+
+
+@Component({
+ selector: 'app-watchlist',
+ templateUrl: './watchlist.component.html',
+ styleUrl: './watchlist.component.css',
+})
+export class WatchlistComponent implements OnInit{
+
+ constructor(
+ ) {}
+
+ async ngOnInit() {
+ }
+
+}
\ No newline at end of file
diff --git a/frontend/src/app/features/watchlist/watchlist.component.html b/frontend/src/app/features/watchlist/watchlist.component.html
deleted file mode 100644
index c02a055..0000000
--- a/frontend/src/app/features/watchlist/watchlist.component.html
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
Library
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/src/app/features/watchlist/watchlist.component.ts b/frontend/src/app/features/watchlist/watchlist.component.ts
deleted file mode 100644
index af0149c..0000000
--- a/frontend/src/app/features/watchlist/watchlist.component.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import { Component } from '@angular/core';
-import { Entry } from '../../shared/models/entry.model';
-import { LibraryService } from '../../core/services/library.service';
-import { ToastrService } from 'ngx-toastr';
-
-@Component({
- selector: 'app-watchlist',
- templateUrl: './watchlist.component.html',
- styleUrl: './watchlist.component.css',
-})
-export class WatchlistComponent {
- entryType: number = 0;
-
- entries: Entry[] = [];
- entriesToShow: Entry[] = [];
-
- entriesCount: number = 0;
- maxPage: number = 10;
- currentPage: number = 1;
- pageSize: number = 10;
-
- constructor(
- private libraryService: LibraryService,
- private toastr: ToastrService
- ) {}
-
- ngOnInit() {
- this.pageSize = this.getDefaultPageSize();
- this.getEntries();
- }
-
- // uses libraryService to get library all content
- getEntries(forceFetch: boolean = false) {
- this.libraryService.getAllEntries(forceFetch).subscribe({
- next: (entries) => {
- this.entries = entries.filter((e) => e.watchlist);
-
- this.filterEntries();
- },
- error: (error) => {
- console.log(`Couldn't get entries.`, error);
- this.toastr.success('Error', "Couldn't get watchlist items.", {
- tapToDismiss: true,
- progressBar: true,
- progressAnimation: 'increasing',
- });
- },
- });
- }
-
- async filterEntries() {
- var temp = [] as Entry[];
-
- // ? type filter
- if (this.entryType != 0) {
- await this.entries.forEach((entry) => {
- if (this.entryType == 1 && !entry.is_tvseries) temp.push(entry);
- else if (this.entryType == 2 && entry.is_tvseries) temp.push(entry);
- });
- } else {
- temp = this.entries;
- }
-
- temp = await this.sortEntries(temp);
-
- this.entriesCount = temp.length;
- this.maxPage = Math.ceil(this.entriesCount / this.pageSize);
- if (this.currentPage > this.maxPage) this.currentPage = this.maxPage; // fix for when 1 entry in the last page is removed
-
- const startIndex = (this.currentPage - 1) * this.pageSize;
- const endIndex = startIndex + this.pageSize;
-
- this.entriesToShow = temp.slice(startIndex, endIndex);
- }
-
- sortEntries(entries: Entry[]) {
- return entries.sort(
- (a, b) =>
- new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
- );
- }
-
- // ! calculated fields
- moviesCount() {
- return this.entries.filter((e) => !e.is_tvseries).length;
- }
-
- seriesCount() {
- return this.entries.filter((e) => e.is_tvseries).length;
- }
-
- hiddenCount() {
- return this.entries.filter((e) => e.hidden).length;
- }
-
- // ! events
- entryRemoved(event: Event) {
- this.entries = this.entries.filter(
- (e) => e.id.toString() != event.toString()
- );
- this.pageSize = this.getDefaultPageSize();
- this.filterEntries();
- }
-
- onEntryTypeChange(entryType: number) {
- this.entryType = entryType;
-
- this.currentPage = 1;
- this.filterEntries();
- }
-
- // ! pagination
- setPageSize(event: any) {
- this.pageSize = event.target.value;
- this.filterEntries();
- }
-
- getDefaultPageSize() {
- // TODO get default page size from settings service
- return 54;
- }
-
- goToPage(page: number) {
- this.currentPage = page;
- this.filterEntries();
- }
-
- get pageNumbers(): number[] {
- let pagesToShow = 5; // Total pages to show at any time
- let startPage: number, endPage: number;
-
- if (this.maxPage <= pagesToShow) {
- startPage = 1;
- endPage = this.maxPage;
- } else {
- startPage = Math.max(this.currentPage - Math.floor(pagesToShow / 2), 1);
- endPage = startPage + pagesToShow - 1;
-
- if (endPage >= this.maxPage) {
- endPage = this.maxPage;
- startPage = endPage - pagesToShow + 1;
- }
- }
-
- // Generate the page numbers array.
- return Array.from(
- { length: endPage - startPage + 1 },
- (_, i) => startPage + i
- );
- }
-}
diff --git a/frontend/src/app/shared/models/settings.model.ts b/frontend/src/app/shared/models/settings.model.ts
index 4fbe058..b2439e3 100644
--- a/frontend/src/app/shared/models/settings.model.ts
+++ b/frontend/src/app/shared/models/settings.model.ts
@@ -5,4 +5,10 @@ export interface Settings {
frontPort: number;
backPort: number;
portableMode: string;
+
+ libraryViewMode: string;
+ favoritViewMode: string;
+ watchlistViewMode: string;
+ CollectionsViewMode: string;
+ CollectionItemsViewMode: string;
}
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index ad4e6f7..04a7dab 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -14,6 +14,9 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CollectionEditModalComponent } from '../features/collections/user-collection-info/collection-edit-modal/collection-edit-modal.component';
import { FloatFormatPipe } from './pipes/float-format/float-format.pipe';
import { EpisodeSeenModalComponent } from './components/modals/episode-seen-modal/episode-seen-modal.component';
+import { MainCardComponent } from './components/cards/main-card/main-card.component';
+import { DynamicEntryListComponent } from './components/lists/dynamic-entry-list/dynamic-entry-list.component';
+import { NotificationPopupComponent } from './components/notification-popup/notification-popup.component';
@NgModule({
imports: [
@@ -34,6 +37,10 @@ import { EpisodeSeenModalComponent } from './components/modals/episode-seen-moda
CollectionEditModalComponent,
ConfirmModalComponent,
EpisodeSeenModalComponent,
+
+ MainCardComponent,
+ DynamicEntryListComponent,
+ NotificationPopupComponent,
],
exports: [
// * pipes
@@ -46,6 +53,10 @@ import { EpisodeSeenModalComponent } from './components/modals/episode-seen-moda
SeenModalComponent,
ConfirmModalComponent,
RatingModule,
+
+ MainCardComponent,
+ DynamicEntryListComponent,
+ NotificationPopupComponent,
],
})
export class SharedModule {}