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
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { TmdbService } from './services/tmdb.service';
|
||||
import { LibraryService } from './services/library.service';
|
||||
import { EntryService } from './services/entry.service';
|
||||
import { UserCollectionService } from './services/userCollection.service';
|
||||
import { CollectionService } from './services/userCollection.service';
|
||||
import { ToggleService } from './services/toggle.service';
|
||||
import { SidebarComponent } from './components/sidebar/sidebar.component';
|
||||
import { NavbarComponent } from './components/navbar/navbar.component';
|
||||
@@ -32,7 +32,7 @@ import { SharedModule } from '../shared/shared.module';
|
||||
LibraryService,
|
||||
EntryService,
|
||||
EntrySeenService,
|
||||
UserCollectionService,
|
||||
CollectionService,
|
||||
ToggleService,
|
||||
EpisodeService,
|
||||
EpisodeSeenService,
|
||||
|
||||
@@ -65,7 +65,7 @@ export class EntryService {
|
||||
// update entry
|
||||
refrechEntryById(entryId: number) {
|
||||
return this.http.get<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/refrech`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/refresh`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import { environment } from '../../../environments/environment.prod';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserCollectionService {
|
||||
export class CollectionService {
|
||||
private backend_apiUrl = environment.API_URL;
|
||||
private apiAction = 'user-collections';
|
||||
private apiAction = 'collections';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
@@ -23,68 +23,84 @@ export class UserCollectionService {
|
||||
}
|
||||
|
||||
// get a list by id
|
||||
getCollection(userCollectionId: string) {
|
||||
getCollection(collectionId: string) {
|
||||
return this.http.get<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
||||
);
|
||||
}
|
||||
|
||||
// Create a new list
|
||||
createCollection(userCollection: UserCollection): Observable<UserCollection> {
|
||||
createCollection(collection: UserCollection): Observable<UserCollection> {
|
||||
return this.http.post<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||
userCollection
|
||||
collection
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - update a collection
|
||||
updateCollection(
|
||||
userCollectionId: number,
|
||||
collectionId: number,
|
||||
formData: FormData
|
||||
): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`,
|
||||
formData
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - REFRESH COLLECTION
|
||||
refreshCollection(collectionId: number): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/refresh`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - GET COLLECTION PARTS
|
||||
getCollectionParts(collectionId: number): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/parts`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// Delete a list by ID
|
||||
deleteCollection(userCollectionId: number): Observable<any> {
|
||||
deleteCollection(collectionId: number): Observable<any> {
|
||||
return this.http.delete(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
||||
);
|
||||
}
|
||||
|
||||
// Add an entry to a list
|
||||
addEntryToCollection(
|
||||
userCollectionId: number,
|
||||
collectionId: number,
|
||||
entryId: number
|
||||
): Observable<UserCollectionEntry> {
|
||||
return this.http.post<UserCollectionEntry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// Update an entry's order in a list
|
||||
updateEntryOrder(
|
||||
userCollectionId: string,
|
||||
collectionId: string,
|
||||
entryId: number,
|
||||
newOrder: number
|
||||
): Observable<any> {
|
||||
return this.http.patch(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
||||
{ newOrder: newOrder }
|
||||
);
|
||||
}
|
||||
|
||||
// Remove an entry from a list
|
||||
removeEntryFromCollection(
|
||||
userCollectionId: string,
|
||||
collectionId: string,
|
||||
entryId: number
|
||||
): Observable<Entry> {
|
||||
return this.http.delete<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`
|
||||
);
|
||||
}
|
||||
}
|
||||
+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';
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,9 @@
|
||||
|
||||
.content-wrapper {
|
||||
color: #212529;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
rgba(255, 255, 255, 0.461) 10%,
|
||||
#eff1f3 100%
|
||||
);
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(255, 255, 255, 0.461) 10%,
|
||||
#eff1f3 100%);
|
||||
|
||||
backdrop-filter: blur(10px);
|
||||
padding: 20px;
|
||||
@@ -46,11 +44,9 @@
|
||||
|
||||
[data-bs-theme="dark"] .content-wrapper {
|
||||
color: #a7acb1;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
rgba(33, 37, 41, 0.7) 50%,
|
||||
#181c1f 100%
|
||||
);
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(33, 37, 41, 0.7) 50%,
|
||||
#181c1f 100%);
|
||||
|
||||
background-color: rgba(33, 37, 41, 0.7);
|
||||
border: 1px solid #181c1f;
|
||||
@@ -181,3 +177,17 @@
|
||||
background-color: transparent;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
|
||||
/* ! collection */
|
||||
.card-img-overlay:hover h5 {
|
||||
color: var(--shz-blue-default) !important;
|
||||
}
|
||||
|
||||
.card-img-overlay {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-img-overlay img {
|
||||
height: 100%;
|
||||
}
|
||||
@@ -219,6 +219,12 @@
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h3>Watch History</h3>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-filter bg-transparent" type="button" style="cursor: pointer;"
|
||||
(click)="addEpisodeSeen()">
|
||||
<i class="bi bi-check2"></i>
|
||||
</button>
|
||||
</div>
|
||||
<!-- <div class="dropdown">
|
||||
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret bg-transparent" type="button"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
@@ -226,7 +232,7 @@
|
||||
<ul class="dropdown-menu" style="cursor: pointer;">
|
||||
<li (click)="addEpisodeSeen()"><a class="dropdown-item">Add a watch date</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="card-body p-3">
|
||||
@@ -280,6 +286,33 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" *ngIf="this.entry.collections.length != 0">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h3>Belong to Collection(s)</h3>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-filter bg-transparent" type="button" style="cursor: pointer;"
|
||||
(click)="showAddToListModal()">
|
||||
<i class="bi bi-collection"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-3 pb-0">
|
||||
<!-- Iterate through each collection in the entry.collections array -->
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4" *ngFor="let collection of entry.collections">
|
||||
<div class="card h-100 mb-0 collection-card" [routerLink]="['/collections', collection.id]">
|
||||
<div class="card-img-overlay d-flex align-items-start justify-content-center"
|
||||
style="background-color: rgba(0, 0, 0, 0.5);">
|
||||
<h5 class="text-white">{{ collection.name }}</h5>
|
||||
</div>
|
||||
<img [src]="collection.selectedBackdrop" alt="{{ collection.name }}" class="card-img">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import { EntrySeen } from '../../../shared/models/entrySeen.model';
|
||||
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
|
||||
import { MediaModalComponent } from '../media-modal/media-modal.component';
|
||||
import { environment } from '../../../../environments/environment.prod';
|
||||
import { UserCollection } from '../../../shared/models/userCollection.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-page',
|
||||
@@ -76,6 +77,14 @@ export class EntryPageComponent implements OnInit {
|
||||
this.entry = data['entry'] as Entry;
|
||||
this.entry.isInLibrary = true;
|
||||
|
||||
this.entry.collections = this.entry.collections.map((c) => {
|
||||
c.mediasCount = c.medias.length;
|
||||
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
||||
|
||||
c.medias = [];
|
||||
return c;
|
||||
});
|
||||
|
||||
if (this.entry.is_tvseries) {
|
||||
// ? sorting seasons
|
||||
this.entry.seasons = this.entry.seasons.sort((a, b) => {
|
||||
@@ -316,6 +325,50 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
getCollectionBackdropPath(collection: UserCollection) {
|
||||
console.log(`collection media:`, collection.medias);
|
||||
if (collection.medias && collection.medias.length != 0) {
|
||||
const backdrops = collection.medias.filter((m) => m.type == 'backdrop');
|
||||
if (backdrops.length != 0) {
|
||||
const selectedBackdrops = backdrops.filter(
|
||||
(m) => m.type == 'backdrop' && m.isSelected
|
||||
);
|
||||
|
||||
console.log(selectedBackdrops);
|
||||
let selectedBackdrop;
|
||||
if (selectedBackdrops.length != 0) {
|
||||
selectedBackdrop = selectedBackdrops[0].path;
|
||||
} else {
|
||||
selectedBackdrop = backdrops[0].path;
|
||||
}
|
||||
|
||||
return (
|
||||
environment.API_URL +
|
||||
`/media/collections/backdrops/preview/${selectedBackdrop}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// if (collection.entries && collection.entries.length != 0) {
|
||||
// // * use the poster of the first entry in the collection
|
||||
// // * if the collection is empty
|
||||
// return this.getEntryBackdropPath(collection.entries[0]);
|
||||
// } else
|
||||
if (collection.backdropPath) {
|
||||
// * use first remote tmdb poster
|
||||
// * if collection has none and has no entry
|
||||
return `https://image.tmdb.org/t/p/w1280/${collection.backdropPath}`;
|
||||
} else {
|
||||
// * use default poster
|
||||
// * if collection has totaly no poster
|
||||
return 'assets/images/default/default-backdrop.png';
|
||||
}
|
||||
}
|
||||
|
||||
getEntryBackdropPath(entry: Entry) {
|
||||
return '';
|
||||
}
|
||||
|
||||
refrechEntry() {
|
||||
this.lockActions = true;
|
||||
this.entryService.refrechEntryById(this.entry.id).subscribe({
|
||||
@@ -417,7 +470,7 @@ export class EntryPageComponent implements OnInit {
|
||||
addEpisodeSeen() {
|
||||
if (!this.entry) return;
|
||||
|
||||
this.seenHistory[0]
|
||||
this.seenHistory[0];
|
||||
|
||||
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
|
||||
width: '360px',
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<div class="row row-cols-4 row-cols-md-6 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('poster')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('posters' , media.path)" class="card-img-top" alt="Media Image">
|
||||
<img [src]="getPath('posters' , media)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
@@ -58,7 +58,7 @@
|
||||
<div class="row row-cols-2 row-cols-md-4 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('backdrop')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('backdrops', media.path)" class="card-img-top" alt="Media Image">
|
||||
<img [src]="getPath('backdrops', media)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
@@ -78,7 +78,7 @@
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('logo')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('logos', media.path)" class="card-img-top" alt="Media Image">
|
||||
<img [src]="getPath('logos', media)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
|
||||
@@ -21,6 +21,7 @@ export class MediaPageComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.customMediaService.fetchCustomMedia().subscribe({
|
||||
next: (result) => {
|
||||
console.log(result);
|
||||
this.customMedia = result;
|
||||
console.log(result);
|
||||
},
|
||||
@@ -32,8 +33,11 @@ export class MediaPageComponent implements OnInit {
|
||||
return this.customMedia.filter((media) => media.type == type);
|
||||
}
|
||||
|
||||
getPath(type: string, fileName: string) {
|
||||
return `${environment.API_URL}/media/entries/${type}/preview/${fileName}`;
|
||||
getPath(type: string, media: Media) {
|
||||
let category = 'entries';
|
||||
if (media.mediaable == 'collection') category = 'collections';
|
||||
|
||||
return `${environment.API_URL}/media/${category}/${type}/preview/${media.path}`;
|
||||
}
|
||||
|
||||
setTab(tab: string) {
|
||||
@@ -71,7 +75,10 @@ export class MediaPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
expandMedia(media: any) {
|
||||
const fullSizePath = `${environment.API_URL}/media/entries/${media.type}s/original/${media.path}`;
|
||||
let category = 'entries';
|
||||
if (media.mediaable == 'collection') category = 'collections';
|
||||
|
||||
const fullSizePath = `${environment.API_URL}/media/${category}/${media.type}s/original/${media.path}`;
|
||||
window.open(fullSizePath, '_blank');
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { Component, Inject, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { NotificationPopupComponent } from '../../notification-popup/notification-popup.component';
|
||||
import { NotificationService } from '../../../services/notification.service';
|
||||
import { UserCollection } from '../../../models/userCollection.model';
|
||||
@@ -49,7 +49,7 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<UserCollectionsModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private listService: UserCollectionService,
|
||||
private listService: CollectionService,
|
||||
private notificationService: NotificationService
|
||||
) {}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { EntryRating } from './entryRating.model';
|
||||
import { EntrySeen } from './entrySeen.model';
|
||||
import { Media } from './media.model';
|
||||
import { Season } from './season.model';
|
||||
import { UserCollection } from './userCollection.model';
|
||||
|
||||
export interface Entry {
|
||||
id: number;
|
||||
@@ -11,6 +12,7 @@ export interface Entry {
|
||||
entryRating: EntryRating;
|
||||
entrySeen: EntrySeen[];
|
||||
seasons: Season[];
|
||||
collections: UserCollection[];
|
||||
|
||||
title: string;
|
||||
original_title: string;
|
||||
|
||||
@@ -4,6 +4,8 @@ export interface Media {
|
||||
id: number;
|
||||
|
||||
entry_id: number;
|
||||
mediaable: string;
|
||||
mediaableId: number;
|
||||
entry: Entry;
|
||||
|
||||
type: string;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CollectionEntry } from './dtos/collection-entry.dto';
|
||||
import { Media } from './media.model';
|
||||
import { UserCollectionEntry } from './userCollectionEntry.model';
|
||||
|
||||
export interface UserCollection {
|
||||
@@ -12,6 +13,7 @@ export interface UserCollection {
|
||||
isUserCollection: boolean;
|
||||
userRating: number;
|
||||
|
||||
medias: Media[];
|
||||
posterPath: string;
|
||||
backdropPath: string;
|
||||
isLocal: boolean;
|
||||
@@ -21,6 +23,12 @@ export interface UserCollection {
|
||||
changed: boolean;
|
||||
isChecked: boolean;
|
||||
|
||||
// * Processed fields
|
||||
mediasCount: number;
|
||||
entriesCount: number;
|
||||
selectedPoster: string;
|
||||
selectedBackdrop: string;
|
||||
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in new issue
Block a user