Major rework of media handelling, and collections
This commit is contained in:
1 parent
b42e055691
commit
f7cb2bed53
37 files changed
+1120
-411
No files matched your search
+14
-2
@@ -4,7 +4,7 @@
|
||||
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="card-body p-4 pt-1">
|
||||
<form class="row g-3" [formGroup]="form">
|
||||
<form class="row g-3" [formGroup]="form" >
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Name</label>
|
||||
<input type="text" class="form-control rounded-0" formControlName="name">
|
||||
@@ -32,7 +32,19 @@
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Poster</label>
|
||||
<input type="file" class="form-control" id="image" (change)="onFileChange($event)">
|
||||
<input type="file" class="form-control" id="image" (change)="onFileChange($event, 'poster')" multiple>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Backdrop</label>
|
||||
<input type="file" class="form-control" id="image" (change)="onFileChange($event, 'backdrop')">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<img [src]="getCollectionPoster()" *ngIf="posterPreview == ''" style="max-height: 250px !important;"
|
||||
alt="Banner" class="img-fluid img-thumbnail banner-img" >
|
||||
<img [src]="posterPreview" *ngIf="posterPreview != ''" style="max-height: 250px !important;" alt="Banner"
|
||||
class="img-fluid img-thumbnail banner-img">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+37
-10
@@ -35,6 +35,12 @@ import {
|
||||
export class CollectionEditModalComponent implements OnInit {
|
||||
form!: FormGroup;
|
||||
|
||||
posterFile: File | null = null;
|
||||
backdropFile: File | null = null;
|
||||
|
||||
posterPreview: string | ArrayBuffer | null = '';
|
||||
backdropPreview: string | ArrayBuffer | null = '';
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<CollectionEditModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
@@ -48,20 +54,43 @@ export class CollectionEditModalComponent implements OnInit {
|
||||
description: [this.data.description],
|
||||
userRating: [this.data.userRating],
|
||||
poster: [null],
|
||||
backdrop: [null],
|
||||
});
|
||||
}
|
||||
|
||||
onFileChange(event: any) {
|
||||
const file = event.target.files[0];
|
||||
this.form.patchValue({ poster: file });
|
||||
this.form.get('poster')?.updateValueAndValidity();
|
||||
onFileChange(event: Event, type: string) {
|
||||
const file = (event.target as HTMLInputElement).files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (type == 'poster') {
|
||||
this.posterFile = file;
|
||||
// this.form.patchValue({ poster: file });
|
||||
// this.form.get('poster')?.updateValueAndValidity();
|
||||
this.posterPreview = reader.result;
|
||||
} else if (type == 'backdrop') {
|
||||
this.backdropFile = file;
|
||||
// this.form.patchValue({ backdrop: file });
|
||||
// this.form.get('backdrop')?.updateValueAndValidity();
|
||||
this.backdropPreview = reader.result;
|
||||
}
|
||||
console.log(this.form);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
getCollectionPoster() {}
|
||||
|
||||
onConfirm(): void {
|
||||
if (this.form.invalid) return this.form.markAllAsTouched();
|
||||
|
||||
let formData = new FormData();
|
||||
|
||||
if (this.posterFile) formData.append('poster', this.posterFile);
|
||||
if (this.backdropFile) formData.append('backdrop', this.backdropFile);
|
||||
|
||||
formData.append('name', this.form.get('name')?.value.toString().trim());
|
||||
formData.append('description', this.form.get('description')?.value || '');
|
||||
formData.append(
|
||||
@@ -70,12 +99,10 @@ export class CollectionEditModalComponent implements OnInit {
|
||||
);
|
||||
|
||||
// Check and append file if it exists
|
||||
const posterFile = this.form.get('poster')?.value;
|
||||
if (posterFile) {
|
||||
formData.append('poster', posterFile);
|
||||
}
|
||||
|
||||
formData.append('is_poster_link', 'false');
|
||||
// const posterFile = this.form.get('poster')?.value;
|
||||
// if (posterFile) {
|
||||
// formData.append('poster', posterFile);
|
||||
// }
|
||||
|
||||
this.dialogRef.close({ formData: formData });
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
@@ -30,7 +30,7 @@ export class CollectionEntryTableComponent {
|
||||
@Input() entries: Entry[] = [];
|
||||
@Input() collectionId: string = '';
|
||||
|
||||
constructor(private userCollectionService: UserCollectionService) {}
|
||||
constructor(private userCollectionService: CollectionService) {}
|
||||
|
||||
refrechEventReceiver() {
|
||||
console.log('event recieved');
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { LibraryService } from '../../../../core/services/library.service';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||
import { environment } from '../../../../../environments/environment.prod';
|
||||
@@ -37,7 +37,7 @@ export class CollectionTableLineComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private userCollectionService: UserCollectionService,
|
||||
private userCollectionService: CollectionService,
|
||||
public dialog: MatDialog,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||
import { environment } from '../../../../../environments/environment.prod';
|
||||
@@ -27,7 +27,7 @@ export class UserCollectionGridCardComponent implements OnInit {
|
||||
@Output() refrechEvent = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
private userCollectionService: UserCollectionService,
|
||||
private userCollectionService: CollectionService,
|
||||
public dialog: MatDialog,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
+15
-1
@@ -29,7 +29,21 @@
|
||||
<li><a class="dropdown-item" (click)="switchViewMode()">Switch View</a></li>
|
||||
<li><a class="dropdown-item" (click)="deleteCollection()">Delete</a></li>
|
||||
<li><a class="dropdown-item" (click)="shareScreenshot()">Share (as image)</a></li>
|
||||
<li><a class="dropdown-item" *ngIf="!this.collection.isUserCollection" (click)="redirectToTMDB()">View in TMDB</a></li>
|
||||
<li>
|
||||
<a class="dropdown-item" *ngIf="!collection.isUserCollection" (click)="refreshCollection()">Refresh
|
||||
Information
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" *ngIf="!collection.isUserCollection" (click)="getCollectionParts()">Get All
|
||||
Parts
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" *ngIf="!collection.isUserCollection" (click)="redirectToTMDB()">View in
|
||||
TMDB
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+49
-7
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { CollectionEntry } from '../../../../shared/models/dtos/collection-entry.dto';
|
||||
@@ -25,7 +25,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private userCollectionService: UserCollectionService,
|
||||
private userCollectionService: CollectionService,
|
||||
private screenshotService: ScreenshotService,
|
||||
private datePipe: DatePipe,
|
||||
public dialog: MatDialog,
|
||||
@@ -36,8 +36,8 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
const id = this.route.snapshot.paramMap.get('id');
|
||||
if (id == null) return; // todo redirect if no id is provided
|
||||
|
||||
this.userCollectionService.getCollection(id.toString()).subscribe(
|
||||
(data) => {
|
||||
this.userCollectionService.getCollection(id.toString()).subscribe({
|
||||
next: (data) => {
|
||||
this.collection = data as unknown as UserCollection;
|
||||
this.collection.entries = this.collection.entries as CollectionEntry[];
|
||||
|
||||
@@ -48,10 +48,10 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
// this.collection
|
||||
// );
|
||||
},
|
||||
(error) => {
|
||||
error: (error) => {
|
||||
console.error('Error occurred:', error);
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getListId() {
|
||||
@@ -111,6 +111,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
description: this.collection.description,
|
||||
userRating: this.collection.userRating || 0,
|
||||
poster: this.collection.posterPath,
|
||||
backdrop: this.collection.backdropPath,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -208,6 +209,47 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
refreshCollection() {
|
||||
this.userCollectionService.refreshCollection(this.collection.id).subscribe({
|
||||
next: (data) => {
|
||||
this.collection = data as unknown as UserCollection;
|
||||
this.collection.entries = this.collection.entries as CollectionEntry[];
|
||||
|
||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||
// console.log(
|
||||
// `Collection "${this.collection.name}" received:`,
|
||||
// this.collection
|
||||
// );
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error occurred:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getCollectionParts() {
|
||||
this.userCollectionService
|
||||
.getCollectionParts(this.collection.id)
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.collection = data as unknown as UserCollection;
|
||||
this.collection.entries = this.collection
|
||||
.entries as CollectionEntry[];
|
||||
|
||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||
// console.log(
|
||||
// `Collection "${this.collection.name}" received:`,
|
||||
// this.collection
|
||||
// );
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error occurred:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
redirectToTMDB() {
|
||||
window.open(
|
||||
`https://www.themoviedb.org/collection/${this.collection.tmdbId}`,
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
<div class="card-coat">
|
||||
<div class="d-flex flex-column align-items-center collection-card" @fadeInOut>
|
||||
<img id="poster" [src]="getCollectionPosterPath()" width="150" class="" alt="List poster" (click)="redirectTo()">
|
||||
<img id="poster" [src]="collection.selectedPoster" width="150" class="" alt="Collection poster"
|
||||
(click)="redirectTo()">
|
||||
<div class="list-item-1 mt-2 text-center">
|
||||
<h6 class="mb-0 list-title" (click)="redirectTo()">{{list.name}}</h6>
|
||||
<h6 class="mb-0 list-title" (click)="redirectTo()">{{collection.name}}</h6>
|
||||
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
|
||||
<!-- <p class="mb-0">Contains: {{list.userCollectionEntries.length}} title(s)</p> -->
|
||||
</div>
|
||||
|
||||
+79
-73
@@ -1,6 +1,6 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { environment } from '../../../../../environments/environment.prod';
|
||||
@@ -25,97 +25,103 @@ import { Entry } from '../../../../shared/models/entry.model';
|
||||
],
|
||||
})
|
||||
export class UserCollectionsListItemComponent {
|
||||
@Input() list!: UserCollection;
|
||||
@Input() collection!: UserCollection;
|
||||
|
||||
constructor(
|
||||
private listService: UserCollectionService,
|
||||
private router: Router
|
||||
) {}
|
||||
constructor(private listService: CollectionService, private router: Router) {}
|
||||
|
||||
getCollectionPosterPath() {
|
||||
if (this.list.isLocal) {
|
||||
if (this.list.posterPath == null)
|
||||
return 'assets/images/default/default-poster.png';
|
||||
// getCollectionPosterPath() {
|
||||
// console.log(this.collection.medias);
|
||||
// if (this.collection.medias.length != 0) {
|
||||
// const selectedPosters = this.collection.medias.filter(
|
||||
// (m) => m.type == 'poster' && m.isSelected
|
||||
// );
|
||||
// let selectedPoster;
|
||||
// if (selectedPosters.length != 0) {
|
||||
// selectedPoster = selectedPosters[0].path;
|
||||
// } else {
|
||||
// selectedPoster = this.collection.medias[0].path;
|
||||
// }
|
||||
|
||||
// * use the collection custom poster
|
||||
return (
|
||||
environment.API_URL +
|
||||
`/media/collections/posters/preview/` +
|
||||
this.list.posterPath
|
||||
);
|
||||
} else {
|
||||
// * use the poster of the first entry in the collection if its no empty
|
||||
if (this.list.entries.length != 0) {
|
||||
return this.getEntryPosterPath(this.list.entries[0]);
|
||||
}
|
||||
// return (
|
||||
// environment.API_URL +
|
||||
// `/media/collections/posters/preview/${selectedPoster}`
|
||||
// );
|
||||
// } else if (this.collection.entries.length != 0) {
|
||||
// // * use the poster of the first entry in the collection
|
||||
// // * if the collection is empty
|
||||
// return this.getEntryPosterPath(this.collection.entries[0]);
|
||||
// } else if (this.collection.posterPath) {
|
||||
// // * use first remote tmdb poster
|
||||
// // * if collection has none and has no entry
|
||||
// return `https://www.themoviedb.org/w1280/${this.collection.posterPath}`;
|
||||
// } else {
|
||||
// // * use default poster
|
||||
// // * if collection has totaly no poster
|
||||
// return 'assets/images/default/default-poster.png';
|
||||
// }
|
||||
// }
|
||||
|
||||
return `https://www.themoviedb.org/w1280/${this.list.posterPath}`;
|
||||
// * if the collection is empty
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
}
|
||||
// getCollectionBakcgroundPath() {
|
||||
// return `https://www.themoviedb.org/w1280/${this.collection.backdropPath}`;
|
||||
|
||||
getCollectionBakcgroundPath() {
|
||||
return `https://www.themoviedb.org/w1280/${this.list.backdropPath}`;
|
||||
// // if (this.list.isLocal) {
|
||||
// // if (this.list.backdropPath == null)
|
||||
// // return 'assets/images/default/default-poster.png';
|
||||
|
||||
// if (this.list.isLocal) {
|
||||
// if (this.list.backdropPath == null)
|
||||
// return 'assets/images/default/default-poster.png';
|
||||
// // // * use the collection custom poster
|
||||
// // return (
|
||||
// // environment.API_URL +
|
||||
// // `/media/collections/posters/preview/` +
|
||||
// // this.list.posterPath
|
||||
// // );
|
||||
// // } else {
|
||||
// // // * use the poster of the first entry in the collection if its no empty
|
||||
// // if (this.list.entries.length != 0) {
|
||||
// // return this.getEntryPosterPath(this.list.entries[0]);
|
||||
// // }
|
||||
|
||||
// // * use the collection custom poster
|
||||
// return (
|
||||
// environment.API_URL +
|
||||
// `/media/collections/posters/preview/` +
|
||||
// this.list.posterPath
|
||||
// );
|
||||
// } else {
|
||||
// // * use the poster of the first entry in the collection if its no empty
|
||||
// if (this.list.entries.length != 0) {
|
||||
// return this.getEntryPosterPath(this.list.entries[0]);
|
||||
// }
|
||||
// // return `https://www.themoviedb.org/w1280/${this.list.backdropPath}`;
|
||||
// // // * if the collection is empty
|
||||
// // return 'assets/images/default/default-poster.png';
|
||||
// // }
|
||||
// }
|
||||
|
||||
// return `https://www.themoviedb.org/w1280/${this.list.backdropPath}`;
|
||||
// // * if the collection is empty
|
||||
// return 'assets/images/default/default-poster.png';
|
||||
// }
|
||||
}
|
||||
// getEntryPosterPath(entry: Entry) {
|
||||
// // * Is in library: use a local poster
|
||||
// if (entry.medias) {
|
||||
// const selectedPosters = entry.medias.filter(
|
||||
// (m) => m.type == 'poster' && m.isSelected
|
||||
// );
|
||||
|
||||
getEntryPosterPath(entry: Entry) {
|
||||
// * Is in library: use a local poster
|
||||
if (entry.medias) {
|
||||
const selectedPosters = entry.medias.filter(
|
||||
(m) => m.type == 'poster' && m.isSelected
|
||||
);
|
||||
// if (
|
||||
// selectedPosters.length &&
|
||||
// selectedPosters[0] &&
|
||||
// selectedPosters[0].path
|
||||
// ) {
|
||||
// const name = selectedPosters[0].path;
|
||||
// return environment.API_URL + `/media/entries/posters/preview/${name}`;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (
|
||||
selectedPosters.length &&
|
||||
selectedPosters[0] &&
|
||||
selectedPosters[0].path
|
||||
) {
|
||||
const name = selectedPosters[0].path;
|
||||
return environment.API_URL + `/media/entries/posters/preview/${name}`;
|
||||
}
|
||||
}
|
||||
// // * No local poster available, Use TMDB poster
|
||||
// if (entry.poster_path)
|
||||
// return `https://image.tmdb.org/t/p/w300` + entry.poster_path;
|
||||
|
||||
// * No local poster available, Use TMDB poster
|
||||
if (entry.poster_path)
|
||||
return `https://image.tmdb.org/t/p/w300` + entry.poster_path;
|
||||
|
||||
// * No poster found, use default poster image as a last stand
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
// // * No poster found, use default poster image as a last stand
|
||||
// return 'assets/images/default/default-poster.png';
|
||||
// }
|
||||
|
||||
getCreatedDate(): string {
|
||||
if (this.list.createdAt == null) return '';
|
||||
if (this.collection.createdAt == null) return '';
|
||||
|
||||
return this.list.createdAt.toString();
|
||||
return this.collection.createdAt.toString();
|
||||
}
|
||||
|
||||
redirectTo(): void {
|
||||
this.router.navigate([`/collections/${this.list.id}`]);
|
||||
this.router.navigate([`/collections/${this.collection.id}`]);
|
||||
}
|
||||
|
||||
deleteList() {
|
||||
this.listService.deleteCollection(this.list.id);
|
||||
this.listService.deleteCollection(this.collection.id);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@
|
||||
<div class="card-body p-0">
|
||||
|
||||
<div class="collections-container">
|
||||
<app-userCollections-list-item *ngFor="let list of collectionsToShow" [list]="list"
|
||||
<app-userCollections-list-item *ngFor="let collection of collectionsToShow" [collection]="collection"
|
||||
@animateDestroy></app-userCollections-list-item>
|
||||
</div>
|
||||
|
||||
|
||||
+80
-5
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import {
|
||||
animate,
|
||||
state,
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { environment } from '../../../../../environments/environment.prod';
|
||||
|
||||
@Component({
|
||||
selector: 'app-userCollections-page',
|
||||
@@ -32,7 +34,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
||||
|
||||
lockActions: boolean = false;
|
||||
|
||||
constructor(private collectionsService: UserCollectionService) {}
|
||||
constructor(private collectionsService: CollectionService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.getCollections();
|
||||
@@ -43,9 +45,19 @@ export class UserCollectionsPageComponent implements OnInit {
|
||||
|
||||
getCollections() {
|
||||
this.collectionsService.getCollections().subscribe({
|
||||
next: (l) => {
|
||||
next: (result) => {
|
||||
// console.log(`Loaded ${l.length} lists.`);
|
||||
this.collections = l;
|
||||
this.collections = result.map((c) => {
|
||||
c.mediasCount = c.medias.length;
|
||||
c.entriesCount = c.entries.length;
|
||||
|
||||
c.selectedPoster = this.getCollectionPosterPath(c);
|
||||
|
||||
c.medias = [];
|
||||
c.entries = [];
|
||||
|
||||
return c;
|
||||
});
|
||||
this.collectionsToShow = this.collections;
|
||||
this.applyFilter();
|
||||
},
|
||||
@@ -101,6 +113,69 @@ export class UserCollectionsPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
doShowCreate() {
|
||||
return this.searchControl.value && !this.collections.some(c => c.name.trim().toLowerCase() == this.searchControl.value?.trim().toLowerCase());
|
||||
return (
|
||||
this.searchControl.value &&
|
||||
!this.collections.some(
|
||||
(c) =>
|
||||
c.name.trim().toLowerCase() ==
|
||||
this.searchControl.value?.trim().toLowerCase()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getCollectionPosterPath(collection: UserCollection) {
|
||||
if (collection.medias && collection.medias.length != 0) {
|
||||
const selectedPosters = collection.medias.filter(
|
||||
(m) => m.type == 'poster' && m.isSelected
|
||||
);
|
||||
let selectedPoster;
|
||||
if (selectedPosters.length != 0) {
|
||||
selectedPoster = selectedPosters[0].path;
|
||||
} else {
|
||||
selectedPoster = collection.medias[0].path;
|
||||
}
|
||||
|
||||
return (
|
||||
environment.API_URL +
|
||||
`/media/collections/posters/preview/${selectedPoster}`
|
||||
);
|
||||
} else if (collection.entries && collection.entries.length != 0) {
|
||||
// * use the poster of the first entry in the collection
|
||||
// * if the collection is empty
|
||||
return this.getEntryPosterPath(collection.entries[0]);
|
||||
} else if (collection.posterPath) {
|
||||
// * use first remote tmdb poster
|
||||
// * if collection has none and has no entry
|
||||
return `https://www.themoviedb.org/w420/${collection.posterPath}`;
|
||||
} else {
|
||||
// * use default poster
|
||||
// * if collection has totaly no poster
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
}
|
||||
|
||||
getCollectionBakcgroundPath(collection: UserCollection) {
|
||||
return `https://www.themoviedb.org/w1280/${collection.backdropPath}`;
|
||||
}
|
||||
|
||||
getEntryPosterPath(entry: Entry) {
|
||||
// * Is in library: use a local poster
|
||||
if (entry.medias) {
|
||||
const selectedPosters = entry.medias.filter(
|
||||
(m) => m.type == 'poster' && m.isSelected
|
||||
);
|
||||
|
||||
if (selectedPosters.length != 0) {
|
||||
const name = selectedPosters[0].path;
|
||||
return environment.API_URL + `/media/entries/posters/preview/${name}`;
|
||||
}
|
||||
}
|
||||
|
||||
// * No local poster available, Use TMDB poster
|
||||
if (entry.poster_path)
|
||||
return `https://image.tmdb.org/t/p/w300` + entry.poster_path;
|
||||
|
||||
// * No poster found, use default poster image as a last stand
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user