switched to using ngprime multiselect in library and watchlist pages

This commit is contained in:
X4Lo committed 2024-09-10 19:00:49 +01:00
1 parent 4fbbc4b113
commit c5883cf6f5
14 files changed
+284 -232

No files matched your search

-3
View File
@@ -22,9 +22,6 @@
"styles": [ "styles": [
"frontend/src/styles.css", "frontend/src/styles.css",
"frontend/src/assets/plugins/select2/css/select2.min.css",
"frontend/src/assets/plugins/select2/css/select2-bootstrap4.css",
"frontend/src/assets/css/bootstrap.min.css", "frontend/src/assets/css/bootstrap.min.css",
"frontend/src/assets/css/bootstrap-extended.css", "frontend/src/assets/css/bootstrap-extended.css",
@@ -53,3 +53,21 @@ a.clear-filter-link {
.filter-switches { .filter-switches {
margin-left: auto; margin-left: auto;
} }
/* ! ng multi select */
::ng-deep .p-multiselect {
width: 100% !important;
}
::ng-deep .p-multiselect-items-wrapper{
width: 100% !important;
}
.p-multiselect-label-container {
padding: 8px 12px !important; /* Adjust for better fit */
}
::ng-deep ol,
::ng-deep ul {
padding-left: 0 !important;
}
@@ -53,35 +53,28 @@
</div> </div>
</div> </div>
<div class="containder"> <div class="row">
<div class="row"> <!-- Search Input for Title -->
<!-- Search Input for Title --> <div class="col-sm-4">
<div class="col-sm-4"> <div class="input-group">
<div class="input-group"> <span class="input-group-text material-icons-outlined">search</span>
<span class="input-group-text material-icons-outlined">search</span> <input class="form-control" type="search" placeholder="Title..." [(ngModel)]="filterCriteria.title"
<input class="form-control" type="search" placeholder="Title..." [(ngModel)]="filterCriteria.title" (ngModelChange)="onFilterChange()">
(ngModelChange)="onFilterChange()">
</div>
</div> </div>
</div>
<!-- Year Selector --> <!-- Year Selector -->
<div class="col-sm-4" [class.visible]="select2Visible" [class.invisible]="!select2Visible"> <div class="col-sm-4">
<div class="d-flex justify-content-start align-items-center"> <p-multiSelect class="w-100" [options]="years" [(ngModel)]="filterCriteria.years" (onChange)="onYearsChange($event)"
<select class="form-control select2" id="year-select2" multiple (change)="onYearsChange($event)"> placeholder="Year(s)..." display="chip" appStopScroll>
<option *ngFor="let year of years" [value]="year">{{ year }}</option> </p-multiSelect>
</select> </div>
</div>
</div>
<!-- Genre Selector -->
<div class="col-sm-4" [class.visible]="select2Visible" [class.invisible]="!select2Visible">
<div class="d-flex justify-content-start align-items-center">
<select class="form-control select2" id="genre-select2" multiple (change)="onGenresChange($event)">
<option *ngFor="let genre of genres" [value]="genre">{{ genre }}</option>
</select>
</div>
</div>
<!-- Genre Selector -->
<div class="col-sm-4">
<p-multiSelect class="w-100" [options]="genres" [(ngModel)]="filterCriteria.genres"
(onChange)="onGenresChange($event)" placeholder="Genre(s)..." display="chip" appStopScroll>
</p-multiSelect>
</div> </div>
</div> </div>
<!-- filter end --> <!-- filter end -->
@@ -38,42 +38,41 @@ export class EntriesDisplayComponent
viewMode: string = 'grid'; viewMode: string = 'grid';
// ? filter // ? filter
select2Visible: boolean = false; // temp fix to select flashing years: { label: string; value: string }[] = [];
years: number[] = []; genres = [
genres: string[] = [ { label: 'Action & Adventure', value: 'Action & Adventure' },
'Action & Adventure', { label: 'Animation', value: 'Animation' },
'Animation', { label: 'Comedy', value: 'Comedy' },
'Comedy', { label: 'Crime', value: 'Crime' },
'Crime', { label: 'Documentary', value: 'Documentary' },
'Documentary', { label: 'Drama', value: 'Drama' },
'Drama', { label: 'Family', value: 'Family' },
'Family', { label: 'Kids', value: 'Kids' },
'Kids', { label: 'Mystery', value: 'Mystery' },
'Mystery', { label: 'News', value: 'News' },
'News', { label: 'Reality', value: 'Reality' },
'Reality', { label: 'Sci-Fi & Fantasy', value: 'Sci-Fi & Fantasy' },
'Sci-Fi & Fantasy', { label: 'Soap', value: 'Soap' },
'Soap', { label: 'Talk', value: 'Talk' },
'Talk', { label: 'War & Politics', value: 'War & Politics' },
'War & Politics', { label: 'Western', value: 'Western' },
'Western', { label: 'Action', value: 'Action' },
'Action', { label: 'Adventure', value: 'Adventure' },
'Adventure', { label: 'Fantasy', value: 'Fantasy' },
'Fantasy', { label: 'History', value: 'History' },
'History', { label: 'Horror', value: 'Horror' },
'Horror', { label: 'Music', value: 'Music' },
'Music', { label: 'Romance', value: 'Romance' },
'Romance', { label: 'Science Fiction', value: 'Science Fiction' },
'Science Fiction', { label: 'TV Movie', value: 'TV Movie' },
'TV Movie', { label: 'Thriller', value: 'Thriller' },
'Thriller', { label: 'War', value: 'War' },
'War',
]; ];
filterCriteria: { filterCriteria: {
title?: string; title?: string;
type: number; type: number;
years?: number[]; years?: string[];
genres?: string[]; genres?: string[];
matchAll: boolean; matchAll: boolean;
} = { } = {
@@ -97,41 +96,39 @@ export class EntriesDisplayComponent
this.pageSize = this.getDefaultPageSize(); this.pageSize = this.getDefaultPageSize();
this.getEntries(); this.getEntries();
await this.populateYears(); // await this.populateYears();
} }
ngAfterViewInit() { ngAfterViewInit() {
setTimeout(() => { // setTimeout(() => {
$('#year-select2') // $('#year-select2')
.select2({ // .select2({
placeholder: 'Year(s)...', // placeholder: 'Year(s)...',
allowClear: true, // allowClear: true,
closeOnSelect: false, // closeOnSelect: false,
}) // })
.on('change', (event: { target: any }) => { // .on('change', (event: { target: any }) => {
this.onYearsChange(event); // this.onYearsChange(event);
}); // });
// $('#genre-select2')
$('#genre-select2') // .select2({
.select2({ // placeholder: 'Genre(s)...',
placeholder: 'Genre(s)...', // allowClear: true,
allowClear: true, // closeOnSelect: false,
closeOnSelect: false, // })
}) // .on('change', (event: { target: any }) => {
.on('change', (event: { target: any }) => { // this.onGenresChange(event);
this.onGenresChange(event); // });
}); // }, 0);
this.select2Visible = true;
}, 0);
} }
ngOnDestroy() { ngOnDestroy() {
if ($('#year-select2').data('select2')) { // if ($('#year-select2').data('select2')) {
$('#year-select2').select2('destroy'); // $('#year-select2').select2('destroy');
} // }
if ($('#genre-select2').data('select2')) { // if ($('#genre-select2').data('select2')) {
$('#genre-select2').select2('destroy'); // $('#genre-select2').select2('destroy');
} // }
} }
// uses libraryService to get library all content // uses libraryService to get library all content
@@ -143,20 +140,22 @@ export class EntriesDisplayComponent
} else if (this.displayType == 'watchlist') { } else if (this.displayType == 'watchlist') {
this.entries = entries.filter((e) => e.watchlist); this.entries = entries.filter((e) => e.watchlist);
} }
this.populateYears();
this.getQueryParameters(); this.getQueryParameters();
this.filterEntries(); this.filterEntries();
}, },
error: (error) => { error: (error) => {
console.log(`Couldn't get entries.`, error); console.log(`Couldn't get entries.`, error);
this.toastr.success( // this.toastr.success(
'Error', // 'Error',
`Couldn't get ${this.displayType} items.`, // `Couldn't get ${this.displayType} items.`,
{ // {
tapToDismiss: true, // tapToDismiss: true,
progressBar: true, // progressBar: true,
progressAnimation: 'increasing', // progressAnimation: 'increasing',
} // }
); // );
}, },
}); });
} }
@@ -174,7 +173,7 @@ export class EntriesDisplayComponent
return false; // Skip entry if the type does not match, unless type is 'all' (0) return false; // Skip entry if the type does not match, unless type is 'all' (0)
} }
const year = new Date(entry.release_date).getFullYear(); const entryYear = new Date(entry.release_date).getFullYear().toString();
// ! Match all criteria logic // ! Match all criteria logic
if (this.filterCriteria.matchAll) { if (this.filterCriteria.matchAll) {
return ( return (
@@ -188,7 +187,7 @@ export class EntriesDisplayComponent
) )
: true) && : true) &&
(this.filterCriteria.years?.length (this.filterCriteria.years?.length
? this.filterCriteria.years.includes(year) ? this.filterCriteria.years.includes(entryYear)
: true) : true)
); );
} }
@@ -204,7 +203,7 @@ export class EntriesDisplayComponent
entry.genres.includes(genre) entry.genres.includes(genre)
)) || )) ||
(this.filterCriteria.years?.length && (this.filterCriteria.years?.length &&
this.filterCriteria.years.includes(year)) this.filterCriteria.years.includes(entryYear))
); );
}); });
@@ -287,10 +286,13 @@ export class EntriesDisplayComponent
} }
populateYears() { populateYears() {
const currentYear = new Date().getFullYear(); this.years = [
for (let year = currentYear; year >= 1950; year--) { ...new Set(
this.years.push(year); this.entries.map((entry) => new Date(entry.release_date).getFullYear())
} ),
]
.sort((a, b) => b - a)
.map((year) => ({ label: year.toString(), value: year.toString() }));
} }
// + FILTER END // + FILTER END
@@ -354,10 +356,10 @@ export class EntriesDisplayComponent
onYearsChange(event: any) { onYearsChange(event: any) {
this.currentPage = 1; this.currentPage = 1;
const selected = $(event.target).val(); // const selected = $(event.target).val();
this.filterCriteria.years = Array.isArray(selected) // this.filterCriteria.years = Array.isArray(selected)
? selected.map(Number) // ? selected.map(Number)
: [Number(selected)]; // : [Number(selected)];
this.filterEntries(); this.filterEntries();
this.setQueryParameters(); // * update url query this.setQueryParameters(); // * update url query
@@ -366,8 +368,8 @@ export class EntriesDisplayComponent
onGenresChange(event: any) { onGenresChange(event: any) {
this.currentPage = 1; this.currentPage = 1;
const selected = $(event.target).val(); // const selected = $(event.target).val();
this.filterCriteria.genres = Array.isArray(selected) ? selected : []; // this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
this.filterEntries(); this.filterEntries();
this.setQueryParameters(); // * update url query this.setQueryParameters(); // * update url query
@@ -62,3 +62,21 @@ a.clear-filter-link {
.select2 .select2-container .select2-container--default .selection span .select2-selection .select2-selection--multiple { .select2 .select2-container .select2-container--default .selection span .select2-selection .select2-selection--multiple {
padding: 0 !important; padding: 0 !important;
} }
/* ! ng multi select */
::ng-deep .p-multiselect {
width: 100% !important;
}
::ng-deep .p-multiselect-items-wrapper{
width: 100% !important;
}
.p-multiselect-label-container {
padding: 8px 12px !important; /* Adjust for better fit */
}
::ng-deep ol,
::ng-deep ul {
padding-left: 0 !important;
}
@@ -74,35 +74,28 @@
<!-- filter switches END --> <!-- filter switches END -->
</div> </div>
<div class="containder"> <div class="row">
<div class="row"> <!-- Search Input for Title -->
<!-- Search Input for Title --> <div class="col-sm-4">
<div class="col-sm-4"> <div class="input-group">
<div class="input-group"> <span class="input-group-text material-icons-outlined">search</span>
<span class="input-group-text material-icons-outlined">search</span> <input class="form-control" type="search" placeholder="Title..." [(ngModel)]="filterCriteria.title"
<input class="form-control" type="search" placeholder="Title..." [(ngModel)]="filterCriteria.title" (ngModelChange)="onFilterChange()">
(ngModelChange)="onFilterChange()">
</div>
</div> </div>
</div>
<!-- Year Selector --> <!-- Year Selector -->
<div class="col-sm-4"> <div class="col-sm-4">
<div class="d-flex justify-content-start align-items-center"> <p-multiSelect class="w-100" [options]="years" [(ngModel)]="filterCriteria.years" (onChange)="onYearsChange($event)"
<select class="form-control select2" id="year-select" multiple (change)="onYearsChange($event)"> placeholder="Year(s)..." display="chip" appStopScroll>
<option *ngFor="let year of years" [value]="year">{{ year }}</option> </p-multiSelect>
</select> </div>
</div>
</div>
<!-- Genre Selector -->
<div class="col-sm-4">
<div class="d-flex justify-content-start align-items-center">
<select class="form-control select2" id="genre-select" multiple (change)="onGenresChange($event)">
<option *ngFor="let genre of genres" [value]="genre">{{ genre }}</option>
</select>
</div>
</div>
<!-- Genre Selector -->
<div class="col-sm-4">
<p-multiSelect class="w-100" [options]="genres" [(ngModel)]="filterCriteria.genres"
(onChange)="onGenresChange($event)" placeholder="Genre(s)..." display="chip" appStopScroll>
</p-multiSelect>
</div> </div>
</div> </div>
<!-- filter end --> <!-- filter end -->
@@ -5,6 +5,7 @@ import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams'; import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
import { SettingsService } from '../../../core/services/settings.service'; import { SettingsService } from '../../../core/services/settings.service';
import { Settings } from '../../../shared/models/settings.model'; import { Settings } from '../../../shared/models/settings.model';
import { ValueSetter } from 'date-fns/parse/_lib/Setter';
declare var $: any; declare var $: any;
@Component({ @Component({
@@ -25,41 +26,41 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
viewMode: string = 'grid'; viewMode: string = 'grid';
// ? filter // ? filter
years: number[] = []; years: { label: string; value: string }[] = [];
genres: string[] = [ genres = [
'Action & Adventure', { label: 'Action & Adventure', value: 'Action & Adventure' },
'Animation', { label: 'Animation', value: 'Animation' },
'Comedy', { label: 'Comedy', value: 'Comedy' },
'Crime', { label: 'Crime', value: 'Crime' },
'Documentary', { label: 'Documentary', value: 'Documentary' },
'Drama', { label: 'Drama', value: 'Drama' },
'Family', { label: 'Family', value: 'Family' },
'Kids', { label: 'Kids', value: 'Kids' },
'Mystery', { label: 'Mystery', value: 'Mystery' },
'News', { label: 'News', value: 'News' },
'Reality', { label: 'Reality', value: 'Reality' },
'Sci-Fi & Fantasy', { label: 'Sci-Fi & Fantasy', value: 'Sci-Fi & Fantasy' },
'Soap', { label: 'Soap', value: 'Soap' },
'Talk', { label: 'Talk', value: 'Talk' },
'War & Politics', { label: 'War & Politics', value: 'War & Politics' },
'Western', { label: 'Western', value: 'Western' },
'Action', { label: 'Action', value: 'Action' },
'Adventure', { label: 'Adventure', value: 'Adventure' },
'Fantasy', { label: 'Fantasy', value: 'Fantasy' },
'History', { label: 'History', value: 'History' },
'Horror', { label: 'Horror', value: 'Horror' },
'Music', { label: 'Music', value: 'Music' },
'Romance', { label: 'Romance', value: 'Romance' },
'Science Fiction', { label: 'Science Fiction', value: 'Science Fiction' },
'TV Movie', { label: 'TV Movie', value: 'TV Movie' },
'Thriller', { label: 'Thriller', value: 'Thriller' },
'War', { label: 'War', value: 'War' },
]; ];
filterCriteria: { filterCriteria: {
title?: string; title?: string;
type: number; type: number;
years?: number[]; years?: string[];
genres?: string[]; genres?: string[];
favorit: boolean; favorit: boolean;
watchlist: boolean; watchlist: boolean;
@@ -94,29 +95,29 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
// this.getEntries(true); // this.getEntries(true);
// } // }
// }); // });
await this.populateYears();
} }
ngAfterViewInit() { ngAfterViewInit() {
$('#year-select') // $('#year-select')
.select2({ // .select2({
placeholder: 'Year(s)...', // placeholder: 'Year(s)...',
allowClear: true, // allowClear: true,
closeOnSelect: false, // closeOnSelect: false,
}) // })
.on('change', (event: { target: any }) => { // .on('change', (event: { target: any }) => {
this.onYearsChange(event); // this.onYearsChange(event);
}); // });
// $('#genre-select')
$('#genre-select') // .select2({
.select2({ // placeholder: 'Genre(s)...',
placeholder: 'Genre(s)...', // allowClear: true,
allowClear: true, // closeOnSelect: false,
closeOnSelect: false, // })
}) // .on('change', (event: { target: any }) => {
.on('change', (event: { target: any }) => { // this.onGenresChange(event);
this.onGenresChange(event); // });
}); // $('#year-select').val(this.filterCriteria.years)
// $('#genre-select').val(this.filterCriteria.genres)
} }
// ? uses libraryService to get library all entries // ? uses libraryService to get library all entries
@@ -124,6 +125,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
this.libraryService.getAllEntries(forceFetch).subscribe({ this.libraryService.getAllEntries(forceFetch).subscribe({
next: (entries) => { next: (entries) => {
this.entries = entries.filter((e) => !e.watchlist); this.entries = entries.filter((e) => !e.watchlist);
this.populateYears();
this.getQueryParameters(); this.getQueryParameters();
this.filterEntries(); this.filterEntries();
}, },
@@ -158,7 +160,6 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
}); });
} }
// ! FILTER // ! FILTER
getQueryParameters() { getQueryParameters() {
this.route.queryParams.subscribe((params) => { this.route.queryParams.subscribe((params) => {
@@ -182,6 +183,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
this.filterCriteria.matchAll = params.hasOwnProperty('matchAll') this.filterCriteria.matchAll = params.hasOwnProperty('matchAll')
? params['matchAll'] ? params['matchAll']
: true; : 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) { if (this.filterCriteria.matchAll != true) {
params.matchAll = this.filterCriteria.matchAll; params.matchAll = this.filterCriteria.matchAll;
} }
// $('#year-select').val([])
// console.log( $('#year-select').val());
this.router.navigate([], { this.router.navigate([], {
relativeTo: this.route, 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() { populateYears() {
const currentYear = new Date().getFullYear(); this.years = [
for (let year = currentYear; year >= 1950; year--) { ...new Set(
this.years.push(year); this.entries.map((entry) => new Date(entry.release_date).getFullYear())
} ),
} ]
.sort((a, b) => b - a)
initializeSelect2() { .map((year) => ({ label: year.toString(), value: year.toString() }));
setTimeout(() => {
// Ensure that the DOM is fully loaded
$('.select2').select2({
placeholder: 'Select an option',
allowClear: true,
});
}, 500);
} }
clearFilter() { clearFilter() {
@@ -283,7 +280,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
return false; return false;
} }
const year = new Date(entry.release_date).getFullYear(); const entryYear = new Date(entry.release_date).getFullYear().toString();
// ! Match all criteria logic // ! Match all criteria logic
if (this.filterCriteria.matchAll) { if (this.filterCriteria.matchAll) {
return ( return (
@@ -297,7 +294,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
) )
: true) && : true) &&
(this.filterCriteria.years?.length (this.filterCriteria.years?.length
? this.filterCriteria.years.includes(year) ? this.filterCriteria.years.includes(entryYear)
: true) && : true) &&
(this.filterCriteria.favorit ? entry.favorit : true) && (this.filterCriteria.favorit ? entry.favorit : true) &&
(this.filterCriteria.watchlist ? entry.watchlist : true) && (this.filterCriteria.watchlist ? entry.watchlist : true) &&
@@ -316,7 +313,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
entry.genres.includes(genre) entry.genres.includes(genre)
)) || )) ||
(this.filterCriteria.years?.length && (this.filterCriteria.years?.length &&
this.filterCriteria.years.includes(year)) || this.filterCriteria.years.includes(entryYear)) ||
(this.filterCriteria.favorit && entry.favorit) || (this.filterCriteria.favorit && entry.favorit) ||
(this.filterCriteria.watchlist && entry.watchlist) (this.filterCriteria.watchlist && entry.watchlist)
); );
@@ -375,10 +372,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
onYearsChange(event: any) { onYearsChange(event: any) {
this.currentPage = 1; this.currentPage = 1;
const selected = $(event.target).val(); // const selected = $(event.target).val();
this.filterCriteria.years = Array.isArray(selected) // this.filterCriteria.years = Array.isArray(selected)
? selected.map(Number) // ? selected.map(Number)
: [Number(selected)]; // : [Number(selected)];
this.filterEntries(); this.filterEntries();
this.setQueryParameters(); // * update url query this.setQueryParameters(); // * update url query
@@ -387,8 +384,8 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
onGenresChange(event: any) { onGenresChange(event: any) {
this.currentPage = 1; this.currentPage = 1;
const selected = $(event.target).val(); // const selected = $(event.target).val();
this.filterCriteria.genres = Array.isArray(selected) ? selected : []; // this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
this.filterEntries(); this.filterEntries();
this.setQueryParameters(); // * update url query this.setQueryParameters(); // * update url query
@@ -0,0 +1,3 @@
.product-box img {
filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.5));
}
@@ -12,7 +12,7 @@ import { LibraryService } from '../../../core/services/library.service';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ConfirmModalComponent } from '../../../shared/components/modals/confirm-modal/confirm-modal.component'; 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 { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component';
import { environment } from '../../../../environments/environment.prod';
@Component({ @Component({
selector: 'tr [app-library-table-line]', selector: 'tr [app-library-table-line]',
@@ -88,7 +88,7 @@ export class LibraryTableLineComponent {
// console.log(`Entry added to library`, entry); // console.log(`Entry added to library`, entry);
entry.isInLibrary = true; entry.isInLibrary = true;
this.entry = entry; this.entry = entry;
this.libraryService.refrechEntries().subscribe(); this.libraryService.refreshEntries().subscribe();
this.onEntryUpdate.emit(this.entry.id); this.onEntryUpdate.emit(this.entry.id);
this.lockActions = false; this.lockActions = false;
obs.unsubscribe(); obs.unsubscribe();
@@ -126,7 +126,7 @@ export class LibraryTableLineComponent {
this.entry.id = 0; this.entry.id = 0;
this.entry.isInLibrary = false; this.entry.isInLibrary = false;
this.onEntryRemove.emit(this.entry.id); this.onEntryRemove.emit(this.entry.id);
this.libraryService.refrechEntries().subscribe(); this.libraryService.refreshEntries().subscribe();
// todo entry removed notification // todo entry removed notification
}, },
error: (error) => { error: (error) => {
@@ -189,7 +189,7 @@ export class LibraryTableLineComponent {
// * Is in library: use a local poster // * Is in library: use a local poster
if (this.entry.medias) { if (this.entry.medias) {
const selectedPosters = this.entry.medias.filter( const selectedPosters = this.entry.medias.filter(
(m) => m.type == 'poster' && m.is_selected (m) => m.type == 'poster' && m.isSelected
); );
if ( if (
@@ -197,9 +197,8 @@ export class LibraryTableLineComponent {
selectedPosters[0] && selectedPosters[0] &&
selectedPosters[0].path selectedPosters[0].path
) { ) {
const name = selectedPosters[0].path.split('.')[0]; const name = selectedPosters[0].path;
const extention = selectedPosters[0].path.split('.')[1]; return environment.API_URL + `/media/entries/posters/preview/${name}`;
return `http://localhost:4000/api/v1/media/entries/posters/${name}_preview.${extention}`;
} }
} }
@@ -220,17 +219,12 @@ export class LibraryTableLineComponent {
// * Is in library: use a local logo // * Is in library: use a local logo
if (this.entry.medias) { if (this.entry.medias) {
const selectedLogos = this.entry.medias.filter( const selectedLogos = this.entry.medias.filter(
(m) => m.type == 'logo' && m.is_selected (m) => m.type == 'logo' && m.isSelected
); );
if ( if (selectedLogos.length && selectedLogos[0] && selectedLogos[0].path) {
selectedLogos.length && const name = selectedLogos[0].path;
selectedLogos[0] && return environment.API_URL + `/media/entries/logos/original/${name}`;
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}`;
} }
} }
@@ -0,0 +1,4 @@
tr {
min-height: 25px;
max-height: 20px;
}
@@ -3,7 +3,7 @@
<div class="product-table"> <div class="product-table">
<div class="table-responsive white-space-nowrap"> <div class="table-responsive white-space-nowrap">
<table class="table align-middle"> <table class="table align-middle">
<thead class="table-light"> <thead class="table">
<!-- * table head start --> <!-- * table head start -->
<tr> <tr>
<th> <th>
@@ -22,7 +22,7 @@
<tbody> <tbody>
<!-- * table body start --> <!-- * table body start -->
<ng-container *ngFor="let entry of entries"> <ng-container *ngFor="let entry of entries">
<tr app-library-table-line [entry]="entry"></tr> <tr class="table-line-tr" app-library-table-line [entry]="entry"></tr>
</ng-container> </ng-container>
<!-- + table body end --> <!-- + table body end -->
</tbody> </tbody>
@@ -12,6 +12,7 @@ import { LibraryRoutingModule } from './library-routing.module';
import { WatchlistComponent } from './watchlist-page/watchlist.component'; import { WatchlistComponent } from './watchlist-page/watchlist.component';
import { EntriesDisplayComponent } from './entries-display/entries-display.component'; import { EntriesDisplayComponent } from './entries-display/entries-display.component';
import { FavoritComponent } from './favorit-page/favorit.component'; import { FavoritComponent } from './favorit-page/favorit.component';
import { MultiSelectModule } from 'primeng/multiselect';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -23,6 +24,7 @@ import { FavoritComponent } from './favorit-page/favorit.component';
LibraryRoutingModule, LibraryRoutingModule,
MultiSelectModule,
DragDropModule, DragDropModule,
], ],
declarations: [ declarations: [
@@ -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();
}
}
}
+7
View File
@@ -19,6 +19,7 @@ import { DynamicEntryListComponent } from './components/lists/dynamic-entry-list
import { NotificationPopupComponent } from './components/notification-popup/notification-popup.component'; import { NotificationPopupComponent } from './components/notification-popup/notification-popup.component';
import { MinutesFormatPipe } from './pipes/minutes-format/minutes-format.pipe'; import { MinutesFormatPipe } from './pipes/minutes-format/minutes-format.pipe';
import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lines-grid.component'; import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lines-grid.component';
import { StopScrollDirective } from './directives/stop-scroll.directive';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -35,6 +36,9 @@ import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lin
FloatFormatPipe, FloatFormatPipe,
MinutesFormatPipe, MinutesFormatPipe,
// * directives
StopScrollDirective,
// ? modals // ? modals
SeenModalComponent, SeenModalComponent,
CollectionEditModalComponent, CollectionEditModalComponent,
@@ -52,6 +56,9 @@ import { TwoLinesGridComponent } from './components/lists/two-lines-grid/two-lin
FloatFormatPipe, FloatFormatPipe,
MinutesFormatPipe, MinutesFormatPipe,
// * directives
StopScrollDirective,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,