Front/Back: add entry settings modal

This commit is contained in:
X4Lo committed 2024-10-21 15:43:09 +01:00
1 parent 8724a96b81
commit 625ec3367e
15 files changed
+334 -57

No files matched your search

@@ -149,7 +149,7 @@
</span>
</button>
<button class="btn btn-icon-only-success wh-48" (click)="showAddToListModal()">
<button class="btn btn-icon-only-success wh-48" (click)="addToCollectionModal()">
<span class="material-symbols-outlined">
playlist_add
</span>
@@ -172,6 +172,12 @@
image
</span>
</button>
<button class="btn btn-icon-only-success wh-48" (click)="settingsModal()">
<span class="material-symbols-outlined">
settings
</span>
</button>
</div>
<!-- End Interraction buttons -->
</div>
@@ -291,7 +297,7 @@
<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()">
(click)="addToCollectionModal()">
<i class="bi bi-collection"></i>
</button>
</div>
@@ -23,6 +23,7 @@ import { EpisodeSeenModalComponent } from '../../../shared/components/modals/epi
import { MediaModalComponent } from '../media-modal/media-modal.component';
import { environment } from '../../../../environments/environment.prod';
import { Collection } from '../../../shared/models/collection.model';
import { EntrySettingsModalComponent } from '../entry-settings-modal/entry-settings-modal.component';
@Component({
selector: 'app-entry-page',
@@ -275,10 +276,14 @@ export class EntryPageComponent implements OnInit {
toggleFavorite() {
this.lockActions = true;
this.entry.favorit = !this.entry.favorit;
this.entryService.updateEntry(this.entry).subscribe({
const entryData = { favorit: this.entry.favorit };
this.entryService.updateEntry(this.entry.id, entryData).subscribe({
next: (entry) => {
// console.log(`Entry updated: `, entry);
this.entry = entry;
this.entry.isInLibrary = true;
},
error: (error) => {
console.log(`Error updating entry: `, error);
@@ -293,10 +298,14 @@ export class EntryPageComponent implements OnInit {
toggleHidden() {
this.lockActions = true;
this.entry.hidden = !this.entry.hidden;
this.entryService.updateEntry(this.entry).subscribe({
const entryData = { hidden: this.entry.hidden };
this.entryService.updateEntry(this.entry.id, entryData).subscribe({
next: (entry) => {
// console.log(`Entry updated: `, entry);
this.entry = entry;
this.entry.isInLibrary = true;
},
error: (error) => {
console.log(`Error updating entry: `, error);
@@ -308,7 +317,7 @@ export class EntryPageComponent implements OnInit {
});
}
showAddToListModal() {
addToCollectionModal() {
if (this.entry) {
const dialogRef = this.dialog.open(UserCollectionsModalComponent, {
width: '400px',
@@ -320,13 +329,24 @@ export class EntryPageComponent implements OnInit {
dialogRef.afterClosed().subscribe((result) => {
// TODO update entry page collections
// console.log('Modal Closed: ', result);
this.entryService.getEntryById(this.entry.id).subscribe({
next: (result) => {
this.entry.collections = result.collections.map((c) => {
c.mediasCount = c.medias.length;
c.selectedBackdrop = this.getCollectionBackdropPath(c);
c.medias = [];
return c;
});
result.collections;
},
});
});
}
}
getCollectionBackdropPath(collection: Collection) {
console.log(`collection media:`, collection.medias);
// 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) {
@@ -334,7 +354,7 @@ export class EntryPageComponent implements OnInit {
(m) => m.type == 'backdrop' && m.isSelected
);
console.log(selectedBackdrops);
// console.log(selectedBackdrops);
let selectedBackdrop;
if (selectedBackdrops.length != 0) {
selectedBackdrop = selectedBackdrops[0].path;
@@ -374,6 +394,14 @@ export class EntryPageComponent implements OnInit {
this.entryService.refrechEntryById(this.entry.id).subscribe({
next: (entry) => {
this.entry = 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;
});
// console.log(`Entry refreched: `, entry);
this.toastr.success(`Movie refreshed successfuly.`, 'Success', {
tapToDismiss: true,
@@ -551,7 +579,11 @@ export class EntryPageComponent implements OnInit {
next: () => {
// console.log(`Episode seen deleted.`);
// ? call this function to fetch the new episode-seen history
this.getEpisodesSeenHistory();
// this.getEpisodesSeenHistory();
this.seenHistory = this.seenHistory.filter(
(eps) => eps.id != episodeSeen.id
);
this.filterEpisodesSeenHistory();
// ? Updating the episodes seen progress bar in the season card
// ? by fetching a new updated episodes list
@@ -684,6 +716,29 @@ export class EntryPageComponent implements OnInit {
});
}
settingsModal() {
const dialogRef = this.dialog.open(EntrySettingsModalComponent, {
width: '800px',
height: '600px',
minHeight: '50%',
panelClass: 'media-dialog-container',
data: {
entry: this.entry,
},
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
this.entry.watchlist = result.entry.watchlist;
this.entry.favorit = result.entry.favorit;
this.entry.hidden = result.entry.hidden;
this.entry.showInCalendar = result.entry.showInCalendar;
this.entry.autoSync = result.entry.autoSync;
} else {
}
});
}
// * getters
get status() {
return this.entry.status;
@@ -759,4 +814,12 @@ export class EntryPageComponent implements OnInit {
if (!this.entry.is_tvseries) return 'This is a movie';
return 'sooon';
}
fetchEntry() {
this.entryService.getEntryById(this.entry.id).subscribe({
next: (result) => {
this.entry = { ...result, isInLibrary: true };
},
});
}
}