add confirm delete for ep/entry seen + implemented actionsLock + fixed seasons order

This commit is contained in:
X4Lo committed 2024-05-11 05:33:30 +01:00
1 parent 01e79b262a
commit 5807652843
3 files changed
+189 -119

No files matched your search

@@ -3,8 +3,7 @@
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 80vh; height: 100vh;
/* Use 100vh to ensure it covers the viewport height */
z-index: -1; z-index: -1;
overflow: hidden; overflow: hidden;
} }
@@ -35,13 +34,9 @@
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); backdrop-filter: blur(10px);
/* Blur effect */
padding: 20px; padding: 20px;
/* Padding for content */
border-radius: 8px; border-radius: 8px;
/* Rounded corners */
border: 1px solid #eff1f3; border: 1px solid #eff1f3;
/* Optional: subtle border */
/* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */ /* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
} }
@@ -56,11 +51,7 @@
37, 37,
41, 41,
0.7); 0.7);
/* Dark semi-transparent background */
border: 1px solid #181c1f; border: 1px solid #181c1f;
/* Subtle light border for contrast */
/* box-shadow: 0 4px 6px rgba(255, 255, 255, 0.1); */
/* Lighter shadow for a glow effect */
} }
.main-container { .main-container {
@@ -74,6 +65,7 @@
.poster { .poster {
padding: px 10px 0 10px; padding: px 10px 0 10px;
cursor: pointer;
} }
.poster img { .poster img {
@@ -110,9 +102,10 @@
.right-col .entry-actions span { .right-col .entry-actions span {
color: black; color: black;
font-size: 2rem;
} }
[data-bs-theme=dark] .right-col .entry-actions span { [data-bs-theme=dark] .right-col .entry-actions span {
color: white; color: white;
} }
@@ -163,3 +156,11 @@
.right-col .entry-actions .favorite span { .right-col .entry-actions .favorite span {
color: var(--shz-gold-1); color: var(--shz-gold-1);
} }
.faved {
font-variation-settings:
'FILL' 1,
'wght' 400,
'GRAD' 0,
'opsz' 24
}
@@ -6,7 +6,7 @@
<div class="col-md-3 left-col"> <div class="col-md-3 left-col">
<!-- Movie Poster --> <!-- Movie Poster -->
<div class="poster"> <div class="poster">
<img [src]="poster" alt="Movie Poster" class="img-fluid mb-3"> <img [src]="poster" alt="Movie Poster" class="img-fluid mb-3" (click)="enlargePoster()">
</div> </div>
<div class="d-flex justify-content-center rating"> <div class="d-flex justify-content-center rating">
<rating [(ngModel)]="entry.entryRating.user_rating" [max]="10" [readonly]="false" <rating [(ngModel)]="entry.entryRating.user_rating" [max]="10" [readonly]="false"
@@ -15,12 +15,23 @@
</div> </div>
<!-- Movie Side Info --> <!-- Movie Side Info -->
<ul class="list-group side-info"> <ul class="list-group side-info">
<li class="list-group-item"><strong>Rating:</strong> {{tmdbRating}}/10</li> <li class="list-group-item" *ngIf="entry.entryRating.tmdb_rating"><strong>TMDB Rating:</strong>
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10</li>
<li class="list-group-item" *ngIf="entry.entryRating.imdb_rating"><strong>IMDB Rating:</strong>
{{entry.entryRating.imdb_rating | floatFormat:1}}/10</li>
<li class="list-group-item" *ngIf="entry.entryRating.rotten_tomatoes_rating"><strong>Rotten Romatoes:</strong>
{{entry.entryRating.rotten_tomatoes_rating | floatFormat:1}}/10</li>
<li class="list-group-item"><strong>Premiere:</strong> {{this.entry.release_date | dateFormat:'MMM dd, yyyy'}} <li class="list-group-item"><strong>Premiere:</strong> {{this.entry.release_date | dateFormat:'MMM dd, yyyy'}}
</li> </li>
<li class="list-group-item" *ngIf="entry.is_tvseries"><strong>Next Episode:</strong> {{nextEpisode}}</li> <li class="list-group-item" *ngIf="entry.is_tvseries"><strong>Next Episode:</strong> {{nextEpisode}}</li>
<li class="list-group-item"><strong>Status:</strong> {{status}}</li> <li class="list-group-item"><strong>Status:</strong> {{status}}</li>
<li class="list-group-item"><strong>Genre:</strong> {{genres}}</li> <li class="list-group-item"><strong>Genre:</strong> {{genres}}</li>
<li class="list-group-item" *ngIf="entry.date_first_seen"><strong>First Seen:</strong> {{entry.date_first_seen |
dateFormat:'MMM dd, yyyy'}}
</li>
<li class="list-group-item" *ngIf="entry.date_last_seen"><strong>Last Seen:</strong> {{entry.date_last_seen |
dateFormat:'MMM dd, yyyy'}}
</li>
</ul> </ul>
<!-- End Movie Side Info --> <!-- End Movie Side Info -->
<br> <br>
@@ -72,13 +83,19 @@
<!-- Interraction buttons --> <!-- Interraction buttons -->
<div class="row entry-actions"> <div class="row entry-actions">
<button class="btn btn-icon-only-favorite wh-48" (click)="toggleFavorite()" <button class="btn btn-icon-only-favorite wh-48" (click)="toggleFavorite()"
[ngClass]="{ 'favorite': entry.favorit }"> [ngClass]="{ 'faved': entry.favorit }">
<span class="material-symbols-outlined">{{ entry.favorit ? 'workspace_premium' : 'license' }}</span> <span class="material-symbols-outlined">grade</span>
</button>
<button class="btn btn-icon-only-success wh-48" (click)="toggleHidden()">
<span class="material-symbols-outlined">
{{ entry.hidden ? 'visibility_off' : 'visibility' }}
</span>
</button> </button>
<button class="btn btn-icon-only-success wh-48" *ngIf="!entry.is_tvseries" (click)="openEntrySeenModal()"> <button class="btn btn-icon-only-success wh-48" *ngIf="!entry.is_tvseries" (click)="openEntrySeenModal()">
<span class="material-symbols-outlined"> <span class="material-symbols-outlined">
visibility event_available
</span> </span>
</button> </button>
@@ -100,6 +117,7 @@
<p>{{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}</p> <p>{{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}</p>
<!-- Movie Overview --> <!-- Movie Overview -->
<p *ngIf="this.entry.title != this.entry.original_title">{{this.entry.original_title}}</p>
<p><strong>{{this.entry.tagline}}</strong></p> <p><strong>{{this.entry.tagline}}</strong></p>
<p>{{this.entry.storyline}}</p> <p>{{this.entry.storyline}}</p>
@@ -124,13 +142,13 @@
</div> </div>
</div> </div>
<div class="row"> <!-- <div class="row">
<h3>Cast</h3> <h3>Cast</h3>
</div> </div> -->
<div class="row"> <!-- <div class="row">
<h3>Collections</h3> <h3>Collections</h3>
</div> </div> -->
<div class="row" *ngIf="this.entry.is_tvseries && this.seenHistory.length != 0"> <div class="row" *ngIf="this.entry.is_tvseries && this.seenHistory.length != 0">
<h3>Watch History</h3> <h3>Watch History</h3>
@@ -181,11 +199,6 @@
</li> </li>
</ul> </ul>
</div> </div>
<!--
<div>
<button (click)="previousPage()" [disabled]="currentPage === 1">Previous</button>
<button (click)="nextPage()" [disabled]="currentPage === totalPageCount()">Next</button>
</div> -->
</div> </div>
</div> </div>
@@ -7,16 +7,17 @@ import { MatDialog } from '@angular/material/dialog';
import { Entry } from '../../../shared/models/entry.model'; import { Entry } from '../../../shared/models/entry.model';
import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto'; import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto';
import { DatePipe } from '@angular/common';
import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component'; import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component';
import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component';
import { ConfirmModalComponent } from '../../../shared/components/modals/confirm-modal/confirm-modal.component';
import { EntrySeenService } from '../../../core/services/entry-seen.service'; import { EntrySeenService } from '../../../core/services/entry-seen.service';
import { EntryRatingsService } from '../../../core/services/entry-ratings.service'; import { EntryRatingsService } from '../../../core/services/entry-ratings.service';
import { EntryService } from '../../../core/services/entry.service'; import { EntryService } from '../../../core/services/entry.service';
import { EpisodeSeenService } from '../../../core/services/episode-seen.service'; import { EpisodeSeenService } from '../../../core/services/episode-seen.service';
import { SeasonService } from '../../../core/services/season.service'; import { SeasonService } from '../../../core/services/season.service';
import { LibraryService } from '../../../core/services/library.service';
import { ToastrService } from 'ngx-toastr';
@Component({ @Component({
selector: 'app-entry-page', selector: 'app-entry-page',
@@ -42,6 +43,8 @@ export class EntryPageComponent implements OnInit {
public showAll = false; public showAll = false;
public initialCount = 2; public initialCount = 2;
lockActions: boolean = false;
seenHistory: any[] = []; seenHistory: any[] = [];
seenHistoryToShow: any[] = []; seenHistoryToShow: any[] = [];
@@ -51,15 +54,16 @@ export class EntryPageComponent implements OnInit {
pageSize: number = 10; pageSize: number = 10;
constructor( constructor(
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
private episodeSeenService: EpisodeSeenService, private episodeSeenService: EpisodeSeenService,
private entryService: EntryService, private entryService: EntryService,
private seasonService: SeasonService, private seasonService: SeasonService,
private entrySeenService: EntrySeenService, private entrySeenService: EntrySeenService,
private entryRatingsService: EntryRatingsService, private entryRatingsService: EntryRatingsService,
private datePipe: DatePipe private libraryService: LibraryService,
private dialog: MatDialog,
private route: ActivatedRoute,
private router: Router,
private toastr: ToastrService
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
@@ -69,22 +73,33 @@ export class EntryPageComponent implements OnInit {
if (this.entry.is_tvseries) { if (this.entry.is_tvseries) {
// ? sorting seasons // ? sorting seasons
this.entry.seasons = this.entry.seasons.sort((a, b) => this.entry.seasons = this.entry.seasons.sort((a, b) => {
a.name.localeCompare(b.name) if (b.season_number == 0) b.season_number = 30; // this will make the special season go last
); if (a.season_number == 0) a.season_number = 30; // this will make the special season go last
return a.season_number - b.season_number;
});
// ? getting seaons episodes // ? getting seaons episodes
this.entry.seasons.forEach((season) => { this.entry.seasons.forEach((season) => {
this.seasonService.getSeasonEpisodes(season.id).subscribe({ this.seasonService.getSeasonEpisodes(season.id).subscribe({
next: (episodes) => { next: (episodes) => {
console.log( // console.log(
`Loaded Season ${season.season_number} Episodes (${episodes.length})` // `Loaded Season ${season.season_number} Episodes (${episodes.length})`
); // );
season.episodes = episodes; season.episodes = episodes;
}, },
error: (error) => { error: (error) => {
console.log(`Couldn't fetch season episodes data:`, error); console.log(`Couldn't fetch season episodes data:`, error);
// TODO show notification this.toastr.success(
'Error',
`Couldn't get season ${season.season_number} episodes.`,
{
tapToDismiss: true,
progressBar: true,
progressAnimation: 'increasing',
}
);
season.episodes = []; season.episodes = [];
}, },
}); });
@@ -115,11 +130,9 @@ export class EntryPageComponent implements OnInit {
width: '360px', width: '360px',
}); });
console.log('Seen dialog opened');
dialogRef.afterClosed().subscribe((result) => { dialogRef.afterClosed().subscribe((result) => {
if (result) { if (result) {
console.log('Seen dialog closed with:', result); // console.log('Seen dialog closed with:', result);
if (result.watchDate == '') { if (result.watchDate == '') {
// TODO show no was passed date notification // TODO show no was passed date notification
@@ -135,8 +148,12 @@ export class EntryPageComponent implements OnInit {
next: (entrySeen) => { next: (entrySeen) => {
if (entrySeen) { if (entrySeen) {
// TODO show confirm notification // TODO show confirm notification
console.log(`EntrySeen Added`, entrySeen); // console.log(`EntrySeen Added`, entrySeen);
this.entry.entrySeen.push(entrySeen); this.entry.entrySeen.push(entrySeen);
if (this.entry.watchlist) {
this.libraryService.refrechEntries().subscribe();
}
} }
}, },
error: (error) => { error: (error) => {
@@ -169,31 +186,72 @@ export class EntryPageComponent implements OnInit {
} }
removeEntrySeen(id: number) { removeEntrySeen(id: number) {
// TODO add confirm modal const dialogRef = this.dialog.open(ConfirmModalComponent, {
this.entrySeenService.removeEntrySeen(id).subscribe({ width: '400px',
next: () => { data: {
this.entry.entrySeen = this.entry.entrySeen.filter( title: 'Confirmation',
(item) => item.id !== id message: `Are you sure you want to delete this?`,
); type: 'danger',
},
error: (error) => {
// TODO show notification
console.error('Error deleting entrySeen:', error);
}, },
}); });
dialogRef.afterClosed().subscribe((result) => {
if (result) {
if (result.confirmed != true) return;
this.entrySeenService.removeEntrySeen(id).subscribe({
next: () => {
this.toastr.success('success', `Removed successfuly.`, {
tapToDismiss: true,
progressBar: true,
progressAnimation: 'increasing',
});
this.entry.entrySeen = this.entry.entrySeen.filter(
(item) => item.id !== id
);
},
error: (error) => {
// TODO show notification
console.error('Error deleting entrySeen:', error);
},
});
}
});
} }
toggleFavorite() { toggleFavorite() {
this.lockActions = true;
this.entry.favorit = !this.entry.favorit; this.entry.favorit = !this.entry.favorit;
this.entryService.updateEntry(this.entry).subscribe({ this.entryService.updateEntry(this.entry).subscribe({
next: (entry) => { next: (entry) => {
console.log(`Entry updated: `, entry); // console.log(`Entry updated: `, entry);
this.entry = entry; this.entry = entry;
}, },
error: (error) => { error: (error) => {
console.log(`Error updating entry: `, error); console.log(`Error updating entry: `, error);
this.entry.favorit = !this.entry.favorit; this.entry.favorit = !this.entry.favorit;
}, },
complete: () => {
this.lockActions = false;
},
});
}
toggleHidden() {
this.lockActions = true;
this.entry.hidden = !this.entry.hidden;
this.entryService.updateEntry(this.entry).subscribe({
next: (entry) => {
// console.log(`Entry updated: `, entry);
this.entry = entry;
},
error: (error) => {
console.log(`Error updating entry: `, error);
this.entry.favorit = !this.entry.favorit;
},
complete: () => {
this.lockActions = false;
}
}); });
} }
@@ -214,16 +272,20 @@ export class EntryPageComponent implements OnInit {
} }
refrechEntry() { refrechEntry() {
this.lockActions = true;
this.entryService.refrechEntryById(this.entry.id).subscribe({ this.entryService.refrechEntryById(this.entry.id).subscribe({
next: (entry) => { next: (entry) => {
this.entry = entry; this.entry = entry;
console.log(`Entry refreched: `, entry); // console.log(`Entry refreched: `, entry);
// TODO show updated notification // TODO show updated notification
}, },
error: (error) => { error: (error) => {
// TODO show error notification // TODO show error notification
console.error('Error refreching movie info:', error); console.error('Error refreching movie info:', error);
}, },
complete: () => {
this.lockActions = false;
},
}); });
} }
@@ -263,13 +325,13 @@ export class EntryPageComponent implements OnInit {
}); });
this.seenHistory = episodeSeens; this.seenHistory = episodeSeens;
console.log(`Episode Seen History Received: `, episodeSeens); // console.log(`Episode Seen History Received: `, episodeSeens);
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
}, },
error: (error) => { error: (error) => {
this.seenHistory = [] as EpisodeSeenDto[]; this.seenHistory = [] as EpisodeSeenDto[];
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
console.log(error); console.log(`Error getting episodes watch history`, error);
}, },
}); });
} }
@@ -301,12 +363,9 @@ export class EntryPageComponent implements OnInit {
dialogRef.afterClosed().subscribe((result) => { dialogRef.afterClosed().subscribe((result) => {
// ? dialog closed // ? dialog closed
if (result == null) { if (result == null) return;
return console.log('Seen dialog was cancelled');
}
// ? dialog confimed // ? dialog confimed
console.log('Episode seen dialog closed with:', result); // console.log('Episode seen dialog closed with:', result);
if (result.watchDate == '') { if (result.watchDate == '') {
// TODO show no date was passed notification // TODO show no date was passed notification
return console.log(`Episode seen dialog closed with no date.`); return console.log(`Episode seen dialog closed with no date.`);
@@ -317,7 +376,7 @@ export class EntryPageComponent implements OnInit {
this.episodeSeenService.updateEpisodeSeen(episodeSeen).subscribe({ this.episodeSeenService.updateEpisodeSeen(episodeSeen).subscribe({
next: () => { next: () => {
console.log(`Episode seen updated.`); // console.log(`Episode seen updated.`);
this.getEpisodesSeenHistory(); this.getEpisodesSeenHistory();
// TODO show notification // TODO show notification
}, },
@@ -332,39 +391,56 @@ export class EntryPageComponent implements OnInit {
deleteEpisodeSeen(episodeSeen: EpisodeSeenDto) { deleteEpisodeSeen(episodeSeen: EpisodeSeenDto) {
if (episodeSeen.id == null) return; if (episodeSeen.id == null) return;
// first start by calling the service and deleting the episode-seen const dialogRef = this.dialog.open(ConfirmModalComponent, {
this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({ width: '400px',
next: () => { data: {
console.log(`Episode seen deleted.`); title: 'Confirmation',
// call this function to fetch the new episode-seen history message: `Are you sure you want to delete this?`,
this.getEpisodesSeenHistory(); type: 'danger',
// trying to update the episodes seen progress bar in the season card
// by fetching a new updated episodes list
this.entry.seasons.forEach(async (season) => {
if (season.season_number == episodeSeen.season_number) {
this.seasonService.getSeasonEpisodes(season.id).subscribe({
next: (episodes) => {
console.log(
`Loaded Season ${season.season_number} Episodes (${episodes.length})`
);
season.episodes = episodes;
},
error: (error) => {
console.log(`Couldn't fetch season episodes data:`, error);
// TODO show notification
season.episodes = [];
},
});
}
});
// TODO show notification
},
error: (error) => {
console.log(`Episode seen delete error: `, error);
}, },
}); });
dialogRef.afterClosed().subscribe((result) => {
if (result) {
console.log(result);
if (result.confirmed != true) return;
// first start by calling the service and deleting the episode-seen
this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({
next: () => {
// console.log(`Episode seen deleted.`);
// call this function to fetch the new episode-seen history
this.getEpisodesSeenHistory();
// trying to update the episodes seen progress bar in the season card
// by fetching a new updated episodes list
this.entry.seasons.forEach(async (season) => {
if (season.season_number == episodeSeen.season_number) {
this.seasonService.getSeasonEpisodes(season.id).subscribe({
next: (episodes) => {
// console.log(
// `Loaded Season ${season.season_number} Episodes (${episodes.length})`
// );
season.episodes = episodes;
},
error: (error) => {
console.log(`Couldn't fetch season episodes data:`, error);
// TODO show notification
season.episodes = [];
},
});
}
});
// TODO show notification
},
error: (error) => {
console.log(`Episode seen delete error: `, error);
},
});
}
});
} }
triggerEpisodeWatchedDeletedEvent() { triggerEpisodeWatchedDeletedEvent() {
console.log(`Emitted Episode Watched Deleted Event`); console.log(`Emitted Episode Watched Deleted Event`);
} }
@@ -406,23 +482,18 @@ export class EntryPageComponent implements OnInit {
this.showAll = !this.showAll; this.showAll = !this.showAll;
} }
enlargePoster() {
window.open(
'https://image.tmdb.org/t/p/original' + this.entry.poster_path,
'_blank'
);
}
// * getters // * getters
get status() { get status() {
return this.entry.status; return this.entry.status;
} }
get createdDate() {
return this.datePipe.transform(this.entry.createdAt, 'dd MMMM, yyyy');
}
get releaseDate() {
return this.datePipe.transform(this.entry.release_date, 'MMM dd, yyyy');
}
get year() {
return this.datePipe.transform(this.entry.release_date, 'yyyy');
}
get runtime() { get runtime() {
return this.entry.runtime; return this.entry.runtime;
} }
@@ -431,21 +502,6 @@ export class EntryPageComponent implements OnInit {
return this.entry.genres.join(', '); return this.entry.genres.join(', ');
} }
get userRating(): string {
if (!this.entry.entryRating.user_rating) return '0';
return this.entry.entryRating.user_rating.toFixed(1);
}
get tmdbRating(): string {
if (!this.entry.entryRating.tmdb_rating) return '0';
return this.entry.entryRating.tmdb_rating.toFixed(1);
}
get imdbRating(): string {
if (!this.entry.entryRating.imdb_rating) return '0';
return this.entry.entryRating.imdb_rating.toFixed(1);
}
get poster(): string { get poster(): string {
if (this.entry.poster_path == null) if (this.entry.poster_path == null)
return 'assets/images/default/default-poster.png'; return 'assets/images/default/default-poster.png';