-
- search
-
-
+
diff --git a/frontend/src/app/features/library/library-page/library-page.component.ts b/frontend/src/app/features/library/library-page/library-page.component.ts
index b3dac04..7655f65 100644
--- a/frontend/src/app/features/library/library-page/library-page.component.ts
+++ b/frontend/src/app/features/library/library-page/library-page.component.ts
@@ -5,6 +5,7 @@ import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
import { SettingsService } from '../../../core/services/settings.service';
import { Settings } from '../../../shared/models/settings.model';
+import { ValueSetter } from 'date-fns/parse/_lib/Setter';
declare var $: any;
@Component({
@@ -25,41 +26,41 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
viewMode: string = 'grid';
// ? filter
- 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',
+ years: { label: string; value: string }[] = [];
+ genres = [
+ { label: 'Action & Adventure', value: 'Action & Adventure' },
+ { label: 'Animation', value: 'Animation' },
+ { label: 'Comedy', value: 'Comedy' },
+ { label: 'Crime', value: 'Crime' },
+ { label: 'Documentary', value: 'Documentary' },
+ { label: 'Drama', value: 'Drama' },
+ { label: 'Family', value: 'Family' },
+ { label: 'Kids', value: 'Kids' },
+ { label: 'Mystery', value: 'Mystery' },
+ { label: 'News', value: 'News' },
+ { label: 'Reality', value: 'Reality' },
+ { label: 'Sci-Fi & Fantasy', value: 'Sci-Fi & Fantasy' },
+ { label: 'Soap', value: 'Soap' },
+ { label: 'Talk', value: 'Talk' },
+ { label: 'War & Politics', value: 'War & Politics' },
+ { label: 'Western', value: 'Western' },
+ { label: 'Action', value: 'Action' },
+ { label: 'Adventure', value: 'Adventure' },
+ { label: 'Fantasy', value: 'Fantasy' },
+ { label: 'History', value: 'History' },
+ { label: 'Horror', value: 'Horror' },
+ { label: 'Music', value: 'Music' },
+ { label: 'Romance', value: 'Romance' },
+ { label: 'Science Fiction', value: 'Science Fiction' },
+ { label: 'TV Movie', value: 'TV Movie' },
+ { label: 'Thriller', value: 'Thriller' },
+ { label: 'War', value: 'War' },
];
filterCriteria: {
title?: string;
type: number;
- years?: number[];
+ years?: string[];
genres?: string[];
favorit: boolean;
watchlist: boolean;
@@ -94,29 +95,29 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
// this.getEntries(true);
// }
// });
- await this.populateYears();
}
ngAfterViewInit() {
- $('#year-select')
- .select2({
- placeholder: 'Year(s)...',
- allowClear: true,
- closeOnSelect: false,
- })
- .on('change', (event: { target: any }) => {
- this.onYearsChange(event);
- });
-
- $('#genre-select')
- .select2({
- placeholder: 'Genre(s)...',
- allowClear: true,
- closeOnSelect: false,
- })
- .on('change', (event: { target: any }) => {
- this.onGenresChange(event);
- });
+ // $('#year-select')
+ // .select2({
+ // placeholder: 'Year(s)...',
+ // allowClear: true,
+ // closeOnSelect: false,
+ // })
+ // .on('change', (event: { target: any }) => {
+ // this.onYearsChange(event);
+ // });
+ // $('#genre-select')
+ // .select2({
+ // placeholder: 'Genre(s)...',
+ // allowClear: true,
+ // closeOnSelect: false,
+ // })
+ // .on('change', (event: { target: any }) => {
+ // this.onGenresChange(event);
+ // });
+ // $('#year-select').val(this.filterCriteria.years)
+ // $('#genre-select').val(this.filterCriteria.genres)
}
// ? uses libraryService to get library all entries
@@ -124,6 +125,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
this.libraryService.getAllEntries(forceFetch).subscribe({
next: (entries) => {
this.entries = entries.filter((e) => !e.watchlist);
+ this.populateYears();
this.getQueryParameters();
this.filterEntries();
},
@@ -158,7 +160,6 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
});
}
-
// ! FILTER
getQueryParameters() {
this.route.queryParams.subscribe((params) => {
@@ -182,6 +183,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
this.filterCriteria.matchAll = params.hasOwnProperty('matchAll')
? params['matchAll']
: true;
+
+ // this.filterCriteria();
+ // this.setQueryParameters(); // * update url query
+ console.log(this.filterCriteria);
});
}
@@ -221,6 +226,8 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
if (this.filterCriteria.matchAll != true) {
params.matchAll = this.filterCriteria.matchAll;
}
+ // $('#year-select').val([])
+ // console.log( $('#year-select').val());
this.router.navigate([], {
relativeTo: this.route,
@@ -229,24 +236,14 @@ export class LibraryPageComponent 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--) {
- this.years.push(year);
- }
- }
-
- initializeSelect2() {
- setTimeout(() => {
- // Ensure that the DOM is fully loaded
- $('.select2').select2({
- placeholder: 'Select an option',
- allowClear: true,
- });
- }, 500);
+ this.years = [
+ ...new Set(
+ this.entries.map((entry) => new Date(entry.release_date).getFullYear())
+ ),
+ ]
+ .sort((a, b) => b - a)
+ .map((year) => ({ label: year.toString(), value: year.toString() }));
}
clearFilter() {
@@ -283,7 +280,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
return false;
}
- const year = new Date(entry.release_date).getFullYear();
+ const entryYear = new Date(entry.release_date).getFullYear().toString();
// ! Match all criteria logic
if (this.filterCriteria.matchAll) {
return (
@@ -297,7 +294,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
)
: true) &&
(this.filterCriteria.years?.length
- ? this.filterCriteria.years.includes(year)
+ ? this.filterCriteria.years.includes(entryYear)
: true) &&
(this.filterCriteria.favorit ? entry.favorit : true) &&
(this.filterCriteria.watchlist ? entry.watchlist : true) &&
@@ -316,7 +313,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
entry.genres.includes(genre)
)) ||
(this.filterCriteria.years?.length &&
- this.filterCriteria.years.includes(year)) ||
+ this.filterCriteria.years.includes(entryYear)) ||
(this.filterCriteria.favorit && entry.favorit) ||
(this.filterCriteria.watchlist && entry.watchlist)
);
@@ -375,10 +372,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
onYearsChange(event: any) {
this.currentPage = 1;
- const selected = $(event.target).val();
- this.filterCriteria.years = Array.isArray(selected)
- ? selected.map(Number)
- : [Number(selected)];
+ // const selected = $(event.target).val();
+ // this.filterCriteria.years = Array.isArray(selected)
+ // ? selected.map(Number)
+ // : [Number(selected)];
this.filterEntries();
this.setQueryParameters(); // * update url query
@@ -387,8 +384,8 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
onGenresChange(event: any) {
this.currentPage = 1;
- const selected = $(event.target).val();
- this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
+ // const selected = $(event.target).val();
+ // this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
this.filterEntries();
this.setQueryParameters(); // * update url query
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
index e69de29..7a87ac0 100644
--- 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
@@ -0,0 +1,3 @@
+.product-box img {
+ filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.5));
+}
\ No newline at end of file
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
index 339d14a..d9f5368 100644
--- 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
@@ -12,7 +12,7 @@ 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';
-
+import { environment } from '../../../../environments/environment.prod';
@Component({
selector: 'tr [app-library-table-line]',
@@ -88,7 +88,7 @@ export class LibraryTableLineComponent {
// console.log(`Entry added to library`, entry);
entry.isInLibrary = true;
this.entry = entry;
- this.libraryService.refrechEntries().subscribe();
+ this.libraryService.refreshEntries().subscribe();
this.onEntryUpdate.emit(this.entry.id);
this.lockActions = false;
obs.unsubscribe();
@@ -126,7 +126,7 @@ export class LibraryTableLineComponent {
this.entry.id = 0;
this.entry.isInLibrary = false;
this.onEntryRemove.emit(this.entry.id);
- this.libraryService.refrechEntries().subscribe();
+ this.libraryService.refreshEntries().subscribe();
// todo entry removed notification
},
error: (error) => {
@@ -189,7 +189,7 @@ export class LibraryTableLineComponent {
// * Is in library: use a local poster
if (this.entry.medias) {
const selectedPosters = this.entry.medias.filter(
- (m) => m.type == 'poster' && m.is_selected
+ (m) => m.type == 'poster' && m.isSelected
);
if (
@@ -197,9 +197,8 @@ export class LibraryTableLineComponent {
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}`;
+ const name = selectedPosters[0].path;
+ return environment.API_URL + `/media/entries/posters/preview/${name}`;
}
}
@@ -215,22 +214,17 @@ export class LibraryTableLineComponent {
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
+ (m) => m.type == 'logo' && m.isSelected
);
- 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}`;
+ if (selectedLogos.length && selectedLogos[0] && selectedLogos[0].path) {
+ const name = selectedLogos[0].path;
+ return environment.API_URL + `/media/entries/logos/original/${name}`;
}
}
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
index e69de29..c5817e5 100644
--- a/frontend/src/app/features/library/library-table/library-table.component.css
+++ b/frontend/src/app/features/library/library-table/library-table.component.css
@@ -0,0 +1,4 @@
+tr {
+ min-height: 25px;
+ max-height: 20px;
+}
\ No newline at end of file
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
index 0cfade5..2d4232e 100644
--- a/frontend/src/app/features/library/library-table/library-table.component.html
+++ b/frontend/src/app/features/library/library-table/library-table.component.html
@@ -3,7 +3,7 @@
-
+
|
@@ -22,7 +22,7 @@
|
-
+
diff --git a/frontend/src/app/features/library/library.module.ts b/frontend/src/app/features/library/library.module.ts
index e512b18..be3c327 100644
--- a/frontend/src/app/features/library/library.module.ts
+++ b/frontend/src/app/features/library/library.module.ts
@@ -12,6 +12,7 @@ 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';
+import { MultiSelectModule } from 'primeng/multiselect';
@NgModule({
imports: [
@@ -23,6 +24,7 @@ import { FavoritComponent } from './favorit-page/favorit.component';
LibraryRoutingModule,
+ MultiSelectModule,
DragDropModule,
],
declarations: [
diff --git a/frontend/src/app/shared/directives/stop-scroll.directive.ts b/frontend/src/app/shared/directives/stop-scroll.directive.ts
new file mode 100644
index 0000000..dd25abe
--- /dev/null
+++ b/frontend/src/app/shared/directives/stop-scroll.directive.ts
@@ -0,0 +1,24 @@
+import { Directive, ElementRef, HostListener } from '@angular/core';
+
+@Directive({
+ selector: '[appStopScroll]',
+})
+export class StopScrollDirective {
+ constructor(private el: ElementRef) {}
+
+ @HostListener('wheel', ['$event'])
+ onWheel(event: WheelEvent) {
+ const element = this.el.nativeElement;
+
+ // Check if scrolling is at the top or bottom of the element
+ const atTop = element.scrollTop === 0;
+ const atBottom =
+ element.scrollHeight - element.scrollTop === element.clientHeight;
+
+ // Prevent scrolling the page if scrolling is within the dropdown
+ if ((atTop && event.deltaY < 0) || (atBottom && event.deltaY > 0)) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
+ }
+}
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index c85b81f..f367d63 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -19,6 +19,7 @@ import { DynamicEntryListComponent } from './components/lists/dynamic-entry-list
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';
+import { StopScrollDirective } from './directives/stop-scroll.directive';
@NgModule({
imports: [
@@ -35,6 +36,9 @@ import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lin
FloatFormatPipe,
MinutesFormatPipe,
+ // * directives
+ StopScrollDirective,
+
// ? modals
SeenModalComponent,
CollectionEditModalComponent,
@@ -52,6 +56,9 @@ import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lin
FloatFormatPipe,
MinutesFormatPipe,
+ // * directives
+ StopScrollDirective,
+
FormsModule,
ReactiveFormsModule,