changes + fixes to collections related component + add filter by collection type
This commit is contained in:
1 parent
eba9721a3c
commit
776506b232
14 files changed
+219
-129
No files matched your search
@@ -4,12 +4,18 @@ const sequelize = require('../db/database');
|
|||||||
const UserCollection = sequelize.define("userCollection",
|
const UserCollection = sequelize.define("userCollection",
|
||||||
{
|
{
|
||||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||||
|
tmdbId: { type: DataTypes.STRING(30), field: 'tmdb_id' },
|
||||||
|
imdbId: { type: DataTypes.STRING(30), field: 'imdb_id' },
|
||||||
|
tvdbId: { type: DataTypes.STRING(30), field: 'tvdb_id' },
|
||||||
|
|
||||||
name: { type: DataTypes.STRING(150) },
|
name: { type: DataTypes.STRING(150) },
|
||||||
description: { type: DataTypes.STRING(500) },
|
description: { type: DataTypes.STRING(3000) },
|
||||||
user_rating: { type: DataTypes.FLOAT },
|
isUserCollection: { type: DataTypes.BOOLEAN, defaultValue: false, field: 'is_user_collection' },
|
||||||
|
userRating: { type: DataTypes.FLOAT, field: 'user_rating' },
|
||||||
|
|
||||||
poster_path: { type: DataTypes.STRING(200) },
|
posterPath: { type: DataTypes.STRING(200), field: 'poster_path' },
|
||||||
|
backdropPath: { type: DataTypes.STRING(200), field: 'backdrop_path' },
|
||||||
|
isLocal: { type: DataTypes.BOOLEAN, defaultValue: false, field: 'is_local' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,28 +13,21 @@ const router = express.Router();
|
|||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const { v4: uuidv4 } = require('uuid');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { getMediaFolder } = require('../services/mediaService');
|
const { getMediaFolder, generatePreview } = require('../services/mediaService');
|
||||||
|
|
||||||
// ! /user-collections
|
// ! /user-collections
|
||||||
// * POST - CREATE UserCollection
|
|
||||||
router.post('/', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { name, description, user_rating, poster_path } = req.body;
|
|
||||||
const newUserCollection = await UserCollection.create({ name, description, user_rating, poster_path });
|
|
||||||
res.status(201).json(newUserCollection);
|
|
||||||
} catch (error) {
|
|
||||||
res.status(400).json({ error: error.message });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// * GET - ALL UserCollections
|
// * GET - ALL UserCollections
|
||||||
router.get('/', async (req, res) => {
|
router.get('/', async (req, res) => {
|
||||||
let userCollections; // Declare outside to broaden scope, albeit unnecessary in your given context
|
let userCollections; // Declare outside to broaden scope, albeit unnecessary in your given context
|
||||||
try {
|
try {
|
||||||
userCollections = await UserCollection.findAll({
|
userCollections = await UserCollection.findAll({
|
||||||
include: [
|
include: [
|
||||||
{ model: UserCollectionEntry, as: 'userCollectionEntries' },
|
{
|
||||||
]
|
model: Entry, as: 'entries',
|
||||||
|
include: { model: Media, as: 'medias' }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
order: [['name', 'ASC']]
|
||||||
});
|
});
|
||||||
res.status(200).json(userCollections);
|
res.status(200).json(userCollections);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -82,6 +75,18 @@ router.get('/:id', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// * POST - CREATE UserCollection
|
||||||
|
router.post('/', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, description, userRating, posterPath } = req.body;
|
||||||
|
const isUserCollection = true;
|
||||||
|
const newUserCollection = await UserCollection.create({ name, description, userRating, posterPath, isUserCollection });
|
||||||
|
res.status(201).json(newUserCollection);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(400).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
cb(null, path.join(getMediaFolder(), 'images', 'collections', 'posters'))
|
cb(null, path.join(getMediaFolder(), 'images', 'collections', 'posters'))
|
||||||
@@ -94,23 +99,33 @@ const storage = multer.diskStorage({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const upload = multer({ storage: storage });
|
const upload = multer({ storage: storage });
|
||||||
|
|
||||||
// * PUT - UPDATE A UserCollection
|
// * PUT - UPDATE A UserCollection
|
||||||
router.put('/:id', upload.single('poster'), async (req, res) => {
|
router.put('/:id', upload.single('poster'), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const userCollectionId = req.params.id;
|
const userCollectionId = req.params.id;
|
||||||
const { name, description, user_rating, is_poster_link } = req.body;
|
const { name, description, userRating, is_poster_link } = req.body;
|
||||||
|
|
||||||
let poster_path = req.file ? req.file.filename : undefined;
|
let posterPath = req.file ? req.file.filename : undefined;
|
||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
user_rating: parseInt(user_rating, 10)
|
userRating: parseInt(userRating, 10),
|
||||||
|
isLocal: false,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (poster_path) {
|
if (posterPath) {
|
||||||
updateData.poster_path = poster_path;
|
updateData.posterPath = posterPath;
|
||||||
|
updateData.isLocal = true;
|
||||||
|
|
||||||
|
// ? generating preview
|
||||||
|
const fileNameWithoutExt = req.file.filename.split('.')[0];
|
||||||
|
const originalPath = req.file.path;
|
||||||
|
|
||||||
|
let previewWidth = 342; // ? poster preview width
|
||||||
|
const previewPath = path.join(req.file.destination, `${fileNameWithoutExt}_preview.jpg`);
|
||||||
|
generatePreview(originalPath, previewPath, previewWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updated = await UserCollection.update(updateData, {
|
const updated = await UserCollection.update(updateData, {
|
||||||
@@ -122,13 +137,16 @@ router.put('/:id', upload.single('poster'), async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
const updatedUserCollection = await UserCollection.findByPk(req.params.id, {
|
const updatedUserCollection = await UserCollection.findByPk(userCollectionId, {
|
||||||
include: [{
|
include: [{
|
||||||
model: Entry,
|
model: Entry,
|
||||||
as: 'entries',
|
as: 'entries',
|
||||||
include: [
|
include: [
|
||||||
{ model: EntryId, as: 'entryId' },
|
{ model: EntryId, as: 'entryId' },
|
||||||
{ model: EntryRating, as: 'entryRating' }
|
{ model: EntryRating, as: 'entryRating' },
|
||||||
|
{ model: Season, as: 'seasons' },
|
||||||
|
{ model: Media, as: 'medias' },
|
||||||
|
{ model: Genre, as: 'genres' },
|
||||||
],
|
],
|
||||||
through: {
|
through: {
|
||||||
model: UserCollectionEntry,
|
model: UserCollectionEntry,
|
||||||
@@ -162,7 +180,6 @@ router.delete('/:id', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// * POST - ADD ENTRY TO A UserCollection
|
// * POST - ADD ENTRY TO A UserCollection
|
||||||
router.post('/:userCollectionId/entries/:entryId', async (req, res) => {
|
router.post('/:userCollectionId/entries/:entryId', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+7
-7
@@ -1,15 +1,15 @@
|
|||||||
<div class="card border-top border-3 border-primary rounded-0" style="margin-bottom: 0 !important;">
|
<div class="card border-top border-3 border-primary rounded-0" style="margin-bottom: 0 !important;">
|
||||||
<div class="modal-header card-header py-3 px-4">
|
<div class="modal-header card-header py-3 px-4">
|
||||||
<h5 class="mb-0 text-primary">Collection Details</h5>
|
<h5 class="mb-0 text-primary">Modify Collection Details</h5>
|
||||||
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
|
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4">
|
<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">
|
<div class="col-md-12">
|
||||||
<label class="form-label">Collection Name</label>
|
<label class="form-label">Name</label>
|
||||||
<input type="text" class="form-control rounded-0" formControlName="name">
|
<input type="text" class="form-control rounded-0" formControlName="name">
|
||||||
<div *ngIf="form.get('name')?.invalid && form.get('name')?.touched" class="error-message">
|
<div *ngIf="form.get('name')?.invalid && form.get('name')?.touched" class="error-message">
|
||||||
Name is required
|
Collection name is required
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -24,15 +24,15 @@
|
|||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<label class="form-label">Rating</label>
|
<label class="form-label">Rating</label>
|
||||||
<div class="d-flex justify-content-center rating">
|
<div class="d-flex justify-content-center rating m-0">
|
||||||
<rating formControlName="user_rating" [max]="10" [readonly]="false">
|
<rating formControlName="userRating" [max]="10" [readonly]="false">
|
||||||
</rating>
|
</rating>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<label class="form-label">Poster</label>
|
<label class="form-label">Poster</label>
|
||||||
<input type="file" id="image" (change)="onFileChange($event)">
|
<input type="file" class="form-control" id="image" (change)="onFileChange($event)">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-30
@@ -38,8 +38,7 @@ export class CollectionEditModalComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<CollectionEditModalComponent>,
|
public dialogRef: MatDialogRef<CollectionEditModalComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder
|
||||||
private cd: ChangeDetectorRef
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -47,20 +46,11 @@ export class CollectionEditModalComponent implements OnInit {
|
|||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
name: [this.data.name, Validators.required],
|
name: [this.data.name, Validators.required],
|
||||||
description: [this.data.description],
|
description: [this.data.description],
|
||||||
user_rating: [this.data.user_rating],
|
userRating: [this.data.userRating],
|
||||||
poster: [null],
|
poster: [null],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private markFormGroupTouched(formGroup: FormGroup) {
|
|
||||||
Object.values(formGroup.controls).forEach((control) => {
|
|
||||||
control.markAsTouched();
|
|
||||||
if (control instanceof FormGroup) {
|
|
||||||
this.markFormGroupTouched(control);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onFileChange(event: any) {
|
onFileChange(event: any) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
this.form.patchValue({ poster: file });
|
this.form.patchValue({ poster: file });
|
||||||
@@ -68,28 +58,26 @@ export class CollectionEditModalComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onConfirm(): void {
|
onConfirm(): void {
|
||||||
if (this.form.valid) {
|
if (this.form.invalid) return this.form.markAllAsTouched();
|
||||||
let formData = new FormData();
|
|
||||||
|
|
||||||
formData.append('name', this.form.get('name')?.value);
|
let formData = new FormData();
|
||||||
formData.append('description', this.form.get('description')?.value || '');
|
|
||||||
formData.append(
|
|
||||||
'user_rating',
|
|
||||||
this.form.get('user_rating')?.value.toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check and append file if it exists
|
formData.append('name', this.form.get('name')?.value.toString().trim());
|
||||||
const posterFile = this.form.get('poster')?.value;
|
formData.append('description', this.form.get('description')?.value || '');
|
||||||
if (posterFile) {
|
formData.append(
|
||||||
formData.append('poster', posterFile);
|
'userRating',
|
||||||
}
|
this.form.get('userRating')?.value?.toString() || '0'
|
||||||
|
);
|
||||||
|
|
||||||
formData.append('is_poster_link', 'false');
|
// Check and append file if it exists
|
||||||
|
const posterFile = this.form.get('poster')?.value;
|
||||||
this.dialogRef.close({ formData: formData });
|
if (posterFile) {
|
||||||
} else {
|
formData.append('poster', posterFile);
|
||||||
this.markFormGroupTouched(this.form);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formData.append('is_poster_link', 'false');
|
||||||
|
|
||||||
|
this.dialogRef.close({ formData: formData });
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose(): void {
|
onClose(): void {
|
||||||
|
|||||||
+3
-2
@@ -13,6 +13,7 @@ import { trigger, transition, style, animate } from '@angular/animations';
|
|||||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tr [app-collection-table-line]',
|
selector: 'tr [app-collection-table-line]',
|
||||||
@@ -68,7 +69,7 @@ export class CollectionTableLineComponent implements OnInit {
|
|||||||
// * 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 (
|
||||||
@@ -78,7 +79,7 @@ export class CollectionTableLineComponent implements OnInit {
|
|||||||
) {
|
) {
|
||||||
const name = selectedLogos[0].path.split('.')[0];
|
const name = selectedLogos[0].path.split('.')[0];
|
||||||
const extention = selectedLogos[0].path.split('.')[1];
|
const extention = selectedLogos[0].path.split('.')[1];
|
||||||
return `http://localhost:4000/api/v1/media/entries/logos/${name}.${extention}`;
|
return environment.API_URL + `/media/entries/logos/original/${name}.${extention}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
@@ -58,6 +58,15 @@
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ! OVER LAY 1 HIDDEN MODE */
|
||||||
|
.movie-card .card-body {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card:hover .card-body {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* ! HOVER END*/
|
/* ! HOVER END*/
|
||||||
|
|
||||||
/* * BUTTONS */
|
/* * BUTTONS */
|
||||||
|
|||||||
+4
-4
@@ -5,6 +5,7 @@ import { trigger, transition, style, animate } from '@angular/animations';
|
|||||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollection-grid-card',
|
selector: 'app-userCollection-grid-card',
|
||||||
@@ -54,7 +55,7 @@ export class UserCollectionGridCardComponent implements OnInit {
|
|||||||
// * 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 (
|
||||||
@@ -62,9 +63,8 @@ export class UserCollectionGridCardComponent implements OnInit {
|
|||||||
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}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -24,17 +24,18 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item" href="javascript:;" (click)="openEditModal()">Edit</a>
|
<a class="dropdown-item" (click)="openEditModal()">Edit</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="dropdown-item" href="javascript:;" (click)="switchViewMode()">Switch View</a></li>
|
<li><a class="dropdown-item" (click)="switchViewMode()">Switch View</a></li>
|
||||||
<li><a class="dropdown-item" href="javascript:;" (click)="deleteCollection()">Delete</a></li>
|
<li><a class="dropdown-item" (click)="deleteCollection()">Delete</a></li>
|
||||||
<li><a class="dropdown-item" href="javascript:;" (click)="shareScreenshot()">Share (as image)</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>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>Created - {{createdAt}} | Updated - {{updatedAt}}
|
<div>Created - {{createdAt}} | Updated - {{updatedAt}}
|
||||||
<div class="d-flex justify-content-right rating">
|
<div class="d-flex justify-content-right rating">
|
||||||
<rating [(ngModel)]="collection.user_rating" [max]="10" [readonly]="true">
|
<rating [(ngModel)]="collection.userRating" [max]="10" [readonly]="true">
|
||||||
</rating>
|
</rating>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+18
-8
@@ -109,8 +109,8 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
data: {
|
data: {
|
||||||
name: this.collection.name,
|
name: this.collection.name,
|
||||||
description: this.collection.description,
|
description: this.collection.description,
|
||||||
user_rating: this.collection.user_rating || 0,
|
userRating: this.collection.userRating || 0,
|
||||||
poster: this.collection.poster_path,
|
poster: this.collection.posterPath,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,11 +179,14 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
const oldViewMode = this.viewMode;
|
const oldViewMode = this.viewMode;
|
||||||
this.viewMode = 'grid';
|
this.viewMode = 'grid';
|
||||||
|
|
||||||
this.screenshotService.capture('gridDiv').then(dataUrl => {
|
this.screenshotService
|
||||||
this.copyToClipboard(dataUrl);
|
.capture('gridDiv')
|
||||||
}).catch(error => {
|
.then((dataUrl) => {
|
||||||
console.error('Error capturing screenshot:', error);
|
this.copyToClipboard(dataUrl);
|
||||||
});
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error capturing screenshot:', error);
|
||||||
|
});
|
||||||
|
|
||||||
this.screenMode = false;
|
this.screenMode = false;
|
||||||
this.viewMode = oldViewMode;
|
this.viewMode = oldViewMode;
|
||||||
@@ -198,10 +201,17 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
canvas.width = img.width;
|
canvas.width = img.width;
|
||||||
canvas.height = img.height;
|
canvas.height = img.height;
|
||||||
ctx!.drawImage(img, 0, 0);
|
ctx!.drawImage(img, 0, 0);
|
||||||
canvas.toBlob(blob => {
|
canvas.toBlob((blob) => {
|
||||||
const item = new ClipboardItem({ 'image/png': blob as Blob });
|
const item = new ClipboardItem({ 'image/png': blob as Blob });
|
||||||
navigator.clipboard.write([item]);
|
navigator.clipboard.write([item]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redirectToTMDB() {
|
||||||
|
window.open(
|
||||||
|
`https://www.themoviedb.org/collection/${this.collection.tmdbId}`,
|
||||||
|
'_blank'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<div class="card-coat">
|
<div class="card-coat">
|
||||||
<div class="d-flex flex-column align-items-center collection-card" @fadeInOut>
|
<div class="d-flex flex-column align-items-center collection-card" @fadeInOut>
|
||||||
<img id="poster" [src]="getPostPath()" width="150" class="" alt="List poster" (click)="redirectTo()">
|
<img id="poster" [src]="getCollectionPosterPath()" width="150" class="" alt="List poster" (click)="redirectTo()">
|
||||||
<div class="list-item-1 mt-2 text-center">
|
<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()">{{list.name}}</h6>
|
||||||
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
|
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
|
||||||
|
|||||||
+46
-8
@@ -3,6 +3,8 @@ import { UserCollection } from '../../../../shared/models/userCollection.model';
|
|||||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { trigger, transition, style, animate } from '@angular/animations';
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollections-list-item',
|
selector: 'app-userCollections-list-item',
|
||||||
@@ -30,15 +32,51 @@ export class UserCollectionsListItemComponent {
|
|||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getPostPath() {
|
getCollectionPosterPath() {
|
||||||
if (this.list.poster_path == null) return 'https://pic.pnnet.dev/256x256';
|
if (this.list.isLocal) {
|
||||||
if (this.list.poster_path.startsWith('/'))
|
if (this.list.posterPath == null)
|
||||||
return `https://image.tmdb.org/t/p/w500` + this.list.poster_path;
|
return 'assets/images/default/default-poster.png';
|
||||||
|
|
||||||
return (
|
// * use the collection custom poster
|
||||||
`http://localhost:4000/api/v1/media/collections/posters/` +
|
return (
|
||||||
this.list.poster_path
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * 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
|
||||||
|
);
|
||||||
|
|
||||||
|
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 poster found, use default poster image as a last stand
|
||||||
|
return 'assets/images/default/default-poster.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
getCreatedDate(): string {
|
getCreatedDate(): string {
|
||||||
|
|||||||
+33
-27
@@ -15,35 +15,41 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--end breadcrumb-->
|
<!--end breadcrumb-->
|
||||||
|
|
||||||
<div>
|
<div class="row my-2">
|
||||||
<div class="col d-flex ">
|
<!-- Search Input for name -->
|
||||||
<div class="card w-100">
|
<div class="col-lg-6 col-md-6">
|
||||||
<div class="card-header border-0 p-3 border-bottom d-flex align-items-center justify-content-between">
|
<div class="input-group">
|
||||||
<div class="position-relative flex-grow-1 align-items-center">
|
<span class="input-group-text material-icons-outlined">search</span>
|
||||||
<input [formControl]="searchControl" matInput class="form-control rounded-5 px-5" type="text"
|
<input [formControl]="searchControl" matInput class="form-control" type="text" placeholder="Collection name...">
|
||||||
placeholder="Collection name...">
|
<button type="button" class="btn btn-primary d-flex align-items-center" *ngIf="doShowCreate()"
|
||||||
<span class="material-icons-outlined position-absolute ms-3 translate-middle-y start-0 top-50">search</span>
|
(click)="createCollection()">
|
||||||
</div>
|
<i class="material-icons-outlined">add</i>
|
||||||
<button type="button" class="btn btn-primary d-flex align-items-center m-2" *ngIf="doShowCreate()" (click)="createCollection()"><i
|
</button>
|
||||||
class="material-icons-outlined">add</i>
|
</div>
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-3">
|
||||||
|
<select name="seasons" class="form-select" [(ngModel)]="collectionType" (change)="onCollectionTypeChange($event)"
|
||||||
|
aria-placeholder="Select a season">
|
||||||
|
<option value="" disabled selected>Select a season</option>
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="Custom">Custom</option>
|
||||||
|
<option value="Official">Official</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col d-flex mt-2">
|
||||||
|
<div class="card w-100">
|
||||||
|
<div class="card-body p-0">
|
||||||
|
|
||||||
|
<div class="collections-container">
|
||||||
|
<app-userCollections-list-item *ngFor="let list of collectionsToShow" [list]="list"
|
||||||
|
@animateDestroy></app-userCollections-list-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body p-0">
|
|
||||||
|
|
||||||
<div class="collections-container">
|
|
||||||
<app-userCollections-list-item *ngFor="let list of collectionsToShow"
|
|
||||||
[list]="list" @animateDestroy></app-userCollections-list-item>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <div class="p-3 ps ps--active-y">
|
|
||||||
<div class="d-flex flex-column gap-3">
|
|
||||||
<app-userCollections-list-item *ngFor="let list of collectionsToShow"
|
|
||||||
[list]="list" @animateDestroy></app-userCollections-list-item>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
+17
-9
@@ -28,6 +28,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
|
|
||||||
collections: UserCollection[] = [];
|
collections: UserCollection[] = [];
|
||||||
collectionsToShow: UserCollection[] = [];
|
collectionsToShow: UserCollection[] = [];
|
||||||
|
collectionType: string = 'All';
|
||||||
|
|
||||||
lockActions: boolean = false;
|
lockActions: boolean = false;
|
||||||
|
|
||||||
@@ -54,16 +55,26 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCollectionTypeChange(event: any): void {
|
||||||
|
this.applyFilter();
|
||||||
|
}
|
||||||
|
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
let filterValue = this.searchControl.value;
|
// * type filter
|
||||||
if (filterValue == null) {
|
let collections = this.collections;
|
||||||
this.collectionsToShow = [...this.collections];
|
if (this.collectionType != 'All') {
|
||||||
return;
|
const type = this.collectionType == 'Custom' ? true : false;
|
||||||
|
collections = this.collections.filter(
|
||||||
|
(collection) => collection.isUserCollection == type
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filterValue = this.searchControl.value;
|
||||||
|
if (filterValue == null) return;
|
||||||
|
|
||||||
const normalizedFilter = filterValue.toLowerCase().trim();
|
const normalizedFilter = filterValue.toLowerCase().trim();
|
||||||
|
|
||||||
this.collectionsToShow = this.collections.filter((collection) =>
|
this.collectionsToShow = collections.filter((collection) =>
|
||||||
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
||||||
);
|
);
|
||||||
this.collectionsCount = this.collectionsToShow.length;
|
this.collectionsCount = this.collectionsToShow.length;
|
||||||
@@ -90,9 +101,6 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doShowCreate() {
|
doShowCreate() {
|
||||||
return (
|
return this.searchControl.value && !this.collections.some(c => c.name.trim().toLowerCase() == this.searchControl.value?.trim().toLowerCase());
|
||||||
this.searchControl.value?.trim() != '' &&
|
|
||||||
this.collectionsToShow.length == 0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,12 +3,18 @@ import { UserCollectionEntry } from './userCollectionEntry.model';
|
|||||||
|
|
||||||
export interface UserCollection {
|
export interface UserCollection {
|
||||||
id: number;
|
id: number;
|
||||||
|
tmdbId: number;
|
||||||
|
imdbId: number;
|
||||||
|
tvdbId: number;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
user_rating: number;
|
isUserCollection: boolean;
|
||||||
|
userRating: number;
|
||||||
|
|
||||||
poster_path: string;
|
posterPath: string;
|
||||||
|
backdropPath: string;
|
||||||
|
isLocal: boolean;
|
||||||
|
|
||||||
userCollectionEntries: UserCollectionEntry[];
|
userCollectionEntries: UserCollectionEntry[];
|
||||||
entries: CollectionEntry[];
|
entries: CollectionEntry[];
|
||||||
|
|||||||
Reference in new issue
Block a user