add: update modal for entry seen
This commit is contained in:
1 parent
d6c3a974a1
commit
bffc1227c3
8 files changed
+208
-81
No files matched your search
@@ -22,6 +22,16 @@ export class EntrySeenService {
|
||||
);
|
||||
}
|
||||
|
||||
updateEntrySeen(entrySeen: EntrySeen) {
|
||||
return this.http.put<EntrySeen>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entrySeen.id}`,
|
||||
{
|
||||
date_seen: entrySeen.date_seen,
|
||||
seen_with: entrySeen.seen_with,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// get entry seen by entry id
|
||||
getEntrySeenById(id: string) {
|
||||
return this.http.get<EntrySeen[]>(
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
}
|
||||
|
||||
.background-wrapper::after {
|
||||
content: '';
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
@@ -25,13 +25,17 @@
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] .background-wrapper::after {
|
||||
[data-bs-theme="dark"] .background-wrapper::after {
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #181c1f 100%);
|
||||
}
|
||||
|
||||
.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;
|
||||
@@ -40,17 +44,15 @@
|
||||
/* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] .content-wrapper {
|
||||
[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);
|
||||
background-color: rgba(33, 37, 41, 0.7);
|
||||
border: 1px solid #181c1f;
|
||||
}
|
||||
|
||||
@@ -79,7 +81,6 @@
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
|
||||
.side-info .list-group-item {
|
||||
background-color: rgba(255, 255, 255, 0.461) !important;
|
||||
background-color: transparent !important;
|
||||
@@ -96,7 +97,7 @@
|
||||
font-size: 2.9rem !important;
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] .title {
|
||||
[data-bs-theme="dark"] .title {
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] .right-col .entry-actions span {
|
||||
[data-bs-theme="dark"] .right-col .entry-actions span {
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -158,9 +159,28 @@
|
||||
}
|
||||
|
||||
.faved {
|
||||
font-variation-settings:
|
||||
'FILL' 1,
|
||||
'wght' 400,
|
||||
'GRAD' 0,
|
||||
'opsz' 24
|
||||
}
|
||||
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
color: var(--shz-blue-default);
|
||||
}
|
||||
|
||||
.info-card {
|
||||
background-color: transparent;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
color: #ffffff;
|
||||
}
|
||||
.info-card hr {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.info-card .accordion .accordion-item,
|
||||
.info-card .accordion .accordion-header,
|
||||
.info-card .accordion .accordion-header .accordion-button {
|
||||
background-color: transparent;
|
||||
border-radius: 0;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
</rating>
|
||||
</div>
|
||||
<!-- Movie Side Info -->
|
||||
<ul class="list-group side-info">
|
||||
<!-- <ul class="list-group side-info">
|
||||
<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>
|
||||
@@ -32,14 +32,61 @@
|
||||
<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>
|
||||
<!-- watch history -->
|
||||
<div class="card" *ngIf="entry.entrySeen.length > 0">
|
||||
</ul> -->
|
||||
<div class="card info-card" *ngIf="entry.entrySeen.length > 0">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Watch History</h5>
|
||||
<h6 class="card-title">Info</h6>
|
||||
<hr>
|
||||
<li class="list-group-item">
|
||||
<strong class="info-item">Premiere:</strong>
|
||||
{{this.entry.release_date | dateFormat:'MMM dd, yyyy'}}
|
||||
</li>
|
||||
<li class="list-group-item" *ngIf="entry.is_tvseries">
|
||||
<strong class="info-item">Next Episode:</strong>
|
||||
{{nextEpisode}}
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong class="info-item">Status:</strong>
|
||||
{{status}}
|
||||
</li>
|
||||
|
||||
<br>
|
||||
|
||||
<li class="list-group-item" *ngIf="entry.date_first_seen">
|
||||
<strong class="info-item">First Seen:</strong>
|
||||
{{entry.date_first_seen | dateFormat:'MMM dd, yyyy'}}
|
||||
</li>
|
||||
<li class="list-group-item" *ngIf="entry.date_last_seen">
|
||||
<strong class="info-item">Last Seen:</strong>
|
||||
{{entry.date_last_seen | dateFormat:'MMM dd, yyyy'}}
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card info-card" *ngIf="entry.entrySeen.length > 0">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Rating</h6>
|
||||
<hr>
|
||||
<li class="list-group-item" *ngIf="entry.entryRating.tmdb_rating">
|
||||
<strong class="info-item">TMDB Rating:</strong>
|
||||
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10
|
||||
</li>
|
||||
<li class="list-group-item" *ngIf="entry.entryRating.imdb_rating">
|
||||
<strong class="info-item">IMDB Rating:</strong>
|
||||
{{entry.entryRating.imdb_rating | floatFormat:1}}/10
|
||||
</li>
|
||||
<li class="list-group-item" *ngIf="entry.entryRating.rotten_tomatoes_rating">
|
||||
<strong class="info-item">Rotten Romatoes:</strong>
|
||||
{{entry.entryRating.rotten_tomatoes_rating | floatFormat:1}}/10
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- watch history -->
|
||||
<div class="card info-card" *ngIf="entry.entrySeen.length > 0">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Watch History</h6>
|
||||
<!-- <hr> -->
|
||||
<div class="accordion" id="accordionWatchHistory">
|
||||
<!-- start watch history - item -->
|
||||
<div class="accordion-item" *ngFor="let seen of entry.entrySeen">
|
||||
@@ -61,7 +108,11 @@
|
||||
<span class="material-symbols-outlined" (click)="removeEntrySeen(seen.id)">
|
||||
delete_forever
|
||||
</span>
|
||||
<!-- TODO add edit button -->
|
||||
</button>
|
||||
<button type="button" class="btn btn-icon-only">
|
||||
<span class="material-symbols-outlined" (click)="editEntrySeen(seen)">
|
||||
edit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ 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';
|
||||
import { EntrySeen } from '../../../shared/models/entrySeen.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-page',
|
||||
@@ -125,51 +126,6 @@ export class EntryPageComponent implements OnInit {
|
||||
this.getEpisodesSeenHistory();
|
||||
}
|
||||
|
||||
openEntrySeenModal() {
|
||||
if (!this.entry) return;
|
||||
|
||||
const dialogRef = this.dialog.open(SeenModalComponent, {
|
||||
width: '360px',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
// console.log('Seen dialog closed with:', result);
|
||||
|
||||
if (result.watchDate == '') {
|
||||
// TODO show no was passed date notification
|
||||
return;
|
||||
}
|
||||
|
||||
let watchDate = result.watchDate;
|
||||
let watchedWith = result.watchedWith.split('\n').join(', ');
|
||||
|
||||
this.entrySeenService
|
||||
.createEntrySeen(this.entry.id.toString(), watchDate, watchedWith)
|
||||
.subscribe({
|
||||
next: (entrySeen) => {
|
||||
if (entrySeen) {
|
||||
// TODO show confirm notification
|
||||
// console.log(`EntrySeen Added`, entrySeen);
|
||||
this.entry.entrySeen.push(entrySeen);
|
||||
|
||||
if (this.entry.watchlist) {
|
||||
this.libraryService.refrechEntries().subscribe();
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entrySeen:', error);
|
||||
},
|
||||
});
|
||||
|
||||
// TODO show notification
|
||||
} else {
|
||||
// console.log('Seen dialog was cancelled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onRatingChange(event: Event) {
|
||||
this.entryRatingsService
|
||||
.updateEntryRatings(this.entry.entryRating)
|
||||
@@ -187,6 +143,88 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// ! ENTRY SEEN
|
||||
openEntrySeenModal(entrySeen: EntrySeen = {} as EntrySeen) {
|
||||
if (!this.entry) return;
|
||||
|
||||
let oldData = {} as { watchDate: Date; watchedWith: string };
|
||||
if (entrySeen.id) {
|
||||
oldData.watchDate = entrySeen.date_seen;
|
||||
oldData.watchedWith = entrySeen.seen_with;
|
||||
}
|
||||
const dialogRef = this.dialog.open(SeenModalComponent, {
|
||||
width: '360px',
|
||||
data: oldData.watchDate ? oldData : {},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.watchDate == '') {
|
||||
// TODO show no was passed date notification
|
||||
return;
|
||||
}
|
||||
|
||||
let watchDate = result.watchDate;
|
||||
let watchedWith = result.watchedWith.split('\n').join(', ');
|
||||
|
||||
if (entrySeen.id) {
|
||||
const es = {
|
||||
id: entrySeen.id,
|
||||
date_seen: watchDate,
|
||||
seen_with: watchedWith,
|
||||
} as EntrySeen;
|
||||
|
||||
// * Update
|
||||
this.entrySeenService.updateEntrySeen(es).subscribe({
|
||||
next: (updatedEntrySeen) => {
|
||||
if (updatedEntrySeen) {
|
||||
// TODO show confirm notification
|
||||
// ? replace the entry-seen object with the updated one
|
||||
for (let i = 0; i < this.entry.entrySeen.length; i++) {
|
||||
if (this.entry.entrySeen[i].id == updatedEntrySeen.id)
|
||||
this.entry.entrySeen[i] = updatedEntrySeen;
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entrySeen:', error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// * Create
|
||||
this.entrySeenService
|
||||
.createEntrySeen(this.entry.id.toString(), watchDate, watchedWith)
|
||||
.subscribe({
|
||||
next: (entrySeen) => {
|
||||
if (entrySeen) {
|
||||
// TODO show confirm notification
|
||||
this.entry.entrySeen.push(entrySeen);
|
||||
|
||||
// ? if the entry was in watch list creating and entry-seen would have removed it
|
||||
// ? from the watchlist, so now we need to refrech libraryService in order to
|
||||
// ? update the watchlist page
|
||||
if (this.entry.watchlist) {
|
||||
this.libraryService.refrechEntries().subscribe();
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entrySeen:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// TODO show notification
|
||||
} else {
|
||||
// console.log('Seen dialog was cancelled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editEntrySeen(entrySeen: EntrySeen) {
|
||||
this.openEntrySeenModal(entrySeen);
|
||||
}
|
||||
|
||||
removeEntrySeen(id: number) {
|
||||
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||
width: '400px',
|
||||
|
||||
@@ -43,7 +43,7 @@ export class SeenModalComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.data == null) {
|
||||
if (this.data.watchDate == null) {
|
||||
// ? no initial data was passed: populate date field with current date
|
||||
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user