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
+153 -83

No files matched your search

@@ -3,8 +3,7 @@
top: 0;
left: 0;
width: 100%;
height: 80vh;
/* Use 100vh to ensure it covers the viewport height */
height: 100vh;
z-index: -1;
overflow: hidden;
}
@@ -35,13 +34,9 @@
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.461) 10%, #eff1f3 100%);
backdrop-filter: blur(10px);
/* Blur effect */
padding: 20px;
/* Padding for content */
border-radius: 8px;
/* Rounded corners */
border: 1px solid #eff1f3;
/* Optional: subtle border */
/* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
}
@@ -56,11 +51,7 @@
37,
41,
0.7);
/* Dark semi-transparent background */
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 {
@@ -74,6 +65,7 @@
.poster {
padding: px 10px 0 10px;
cursor: pointer;
}
.poster img {
@@ -110,6 +102,7 @@
.right-col .entry-actions span {
color: black;
font-size: 2rem;
}
[data-bs-theme=dark] .right-col .entry-actions span {
@@ -163,3 +156,11 @@
.right-col .entry-actions .favorite span {
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">
<!-- Movie 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 class="d-flex justify-content-center rating">
<rating [(ngModel)]="entry.entryRating.user_rating" [max]="10" [readonly]="false"
@@ -15,12 +15,23 @@
</div>
<!-- Movie 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>
<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>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>
<!-- End Movie Side Info -->
<br>
@@ -72,13 +83,19 @@
<!-- Interraction buttons -->
<div class="row entry-actions">
<button class="btn btn-icon-only-favorite wh-48" (click)="toggleFavorite()"
[ngClass]="{ 'favorite': entry.favorit }">
<span class="material-symbols-outlined">{{ entry.favorit ? 'workspace_premium' : 'license' }}</span>
[ngClass]="{ 'faved': entry.favorit }">
<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 class="btn btn-icon-only-success wh-48" *ngIf="!entry.is_tvseries" (click)="openEntrySeenModal()">
<span class="material-symbols-outlined">
visibility
event_available
</span>
</button>
@@ -100,6 +117,7 @@
<p>{{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}</p>
<!-- Movie Overview -->
<p *ngIf="this.entry.title != this.entry.original_title">{{this.entry.original_title}}</p>
<p><strong>{{this.entry.tagline}}</strong></p>
<p>{{this.entry.storyline}}</p>
@@ -124,13 +142,13 @@
</div>
</div>
<div class="row">
<!-- <div class="row">
<h3>Cast</h3>
</div>
</div> -->
<div class="row">
<!-- <div class="row">
<h3>Collections</h3>
</div>
</div> -->
<div class="row" *ngIf="this.entry.is_tvseries && this.seenHistory.length != 0">
<h3>Watch History</h3>
@@ -181,11 +199,6 @@
</li>
</ul>
</div>
<!--
<div>
<button (click)="previousPage()" [disabled]="currentPage === 1">Previous</button>
<button (click)="nextPage()" [disabled]="currentPage === totalPageCount()">Next</button>
</div> -->
</div>
</div>
@@ -7,16 +7,17 @@ import { MatDialog } from '@angular/material/dialog';
import { Entry } from '../../../shared/models/entry.model';
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 { 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 { EntryRatingsService } from '../../../core/services/entry-ratings.service';
import { EntryService } from '../../../core/services/entry.service';
import { EpisodeSeenService } from '../../../core/services/episode-seen.service';
import { SeasonService } from '../../../core/services/season.service';
import { LibraryService } from '../../../core/services/library.service';
import { ToastrService } from 'ngx-toastr';
@Component({
selector: 'app-entry-page',
@@ -42,6 +43,8 @@ export class EntryPageComponent implements OnInit {
public showAll = false;
public initialCount = 2;
lockActions: boolean = false;
seenHistory: any[] = [];
seenHistoryToShow: any[] = [];
@@ -51,15 +54,16 @@ export class EntryPageComponent implements OnInit {
pageSize: number = 10;
constructor(
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
private episodeSeenService: EpisodeSeenService,
private entryService: EntryService,
private seasonService: SeasonService,
private entrySeenService: EntrySeenService,
private entryRatingsService: EntryRatingsService,
private datePipe: DatePipe
private libraryService: LibraryService,
private dialog: MatDialog,
private route: ActivatedRoute,
private router: Router,
private toastr: ToastrService
) {}
ngOnInit(): void {
@@ -69,22 +73,33 @@ export class EntryPageComponent implements OnInit {
if (this.entry.is_tvseries) {
// ? sorting seasons
this.entry.seasons = this.entry.seasons.sort((a, b) =>
a.name.localeCompare(b.name)
);
this.entry.seasons = this.entry.seasons.sort((a, b) => {
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
this.entry.seasons.forEach((season) => {
this.seasonService.getSeasonEpisodes(season.id).subscribe({
next: (episodes) => {
console.log(
`Loaded Season ${season.season_number} Episodes (${episodes.length})`
);
// 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
this.toastr.success(
'Error',
`Couldn't get season ${season.season_number} episodes.`,
{
tapToDismiss: true,
progressBar: true,
progressAnimation: 'increasing',
}
);
season.episodes = [];
},
});
@@ -115,11 +130,9 @@ export class EntryPageComponent implements OnInit {
width: '360px',
});
console.log('Seen dialog opened');
dialogRef.afterClosed().subscribe((result) => {
if (result) {
console.log('Seen dialog closed with:', result);
// console.log('Seen dialog closed with:', result);
if (result.watchDate == '') {
// TODO show no was passed date notification
@@ -135,8 +148,12 @@ export class EntryPageComponent implements OnInit {
next: (entrySeen) => {
if (entrySeen) {
// TODO show confirm notification
console.log(`EntrySeen Added`, entrySeen);
// console.log(`EntrySeen Added`, entrySeen);
this.entry.entrySeen.push(entrySeen);
if (this.entry.watchlist) {
this.libraryService.refrechEntries().subscribe();
}
}
},
error: (error) => {
@@ -169,9 +186,26 @@ export class EntryPageComponent implements OnInit {
}
removeEntrySeen(id: number) {
// TODO add confirm modal
const dialogRef = this.dialog.open(ConfirmModalComponent, {
width: '400px',
data: {
title: 'Confirmation',
message: `Are you sure you want to delete this?`,
type: 'danger',
},
});
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
);
@@ -182,18 +216,42 @@ export class EntryPageComponent implements OnInit {
},
});
}
});
}
toggleFavorite() {
this.lockActions = true;
this.entry.favorit = !this.entry.favorit;
this.entryService.updateEntry(this.entry).subscribe({
next: (entry) => {
console.log(`Entry updated: `, 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;
},
});
}
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() {
this.lockActions = true;
this.entryService.refrechEntryById(this.entry.id).subscribe({
next: (entry) => {
this.entry = entry;
console.log(`Entry refreched: `, entry);
// console.log(`Entry refreched: `, entry);
// TODO show updated notification
},
error: (error) => {
// TODO show error notification
console.error('Error refreching movie info:', error);
},
complete: () => {
this.lockActions = false;
},
});
}
@@ -263,13 +325,13 @@ export class EntryPageComponent implements OnInit {
});
this.seenHistory = episodeSeens;
console.log(`Episode Seen History Received: `, episodeSeens);
// console.log(`Episode Seen History Received: `, episodeSeens);
this.filterEpisodesSeenHistory();
},
error: (error) => {
this.seenHistory = [] as EpisodeSeenDto[];
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) => {
// ? dialog closed
if (result == null) {
return console.log('Seen dialog was cancelled');
}
if (result == null) return;
// ? dialog confimed
console.log('Episode seen dialog closed with:', result);
// console.log('Episode seen dialog closed with:', result);
if (result.watchDate == '') {
// TODO show no date was passed notification
return console.log(`Episode seen dialog closed with no date.`);
@@ -317,7 +376,7 @@ export class EntryPageComponent implements OnInit {
this.episodeSeenService.updateEpisodeSeen(episodeSeen).subscribe({
next: () => {
console.log(`Episode seen updated.`);
// console.log(`Episode seen updated.`);
this.getEpisodesSeenHistory();
// TODO show notification
},
@@ -332,10 +391,24 @@ export class EntryPageComponent implements OnInit {
deleteEpisodeSeen(episodeSeen: EpisodeSeenDto) {
if (episodeSeen.id == null) return;
const dialogRef = this.dialog.open(ConfirmModalComponent, {
width: '400px',
data: {
title: 'Confirmation',
message: `Are you sure you want to delete this?`,
type: 'danger',
},
});
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.`);
// console.log(`Episode seen deleted.`);
// call this function to fetch the new episode-seen history
this.getEpisodesSeenHistory();
@@ -345,9 +418,9 @@ export class EntryPageComponent implements OnInit {
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})`
);
// console.log(
// `Loaded Season ${season.season_number} Episodes (${episodes.length})`
// );
season.episodes = episodes;
},
error: (error) => {
@@ -365,6 +438,9 @@ export class EntryPageComponent implements OnInit {
},
});
}
});
}
triggerEpisodeWatchedDeletedEvent() {
console.log(`Emitted Episode Watched Deleted Event`);
}
@@ -406,23 +482,18 @@ export class EntryPageComponent implements OnInit {
this.showAll = !this.showAll;
}
enlargePoster() {
window.open(
'https://image.tmdb.org/t/p/original' + this.entry.poster_path,
'_blank'
);
}
// * getters
get 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() {
return this.entry.runtime;
}
@@ -431,21 +502,6 @@ export class EntryPageComponent implements OnInit {
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 {
if (this.entry.poster_path == null)
return 'assets/images/default/default-poster.png';