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
@@ -65,13 +65,15 @@ entryRouter.get('/:id', async (req, res) => {
|
|||||||
attributes: [] // Do not fetch any attributes from the join table
|
attributes: [] // Do not fetch any attributes from the join table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
order: [
|
||||||
|
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
if (!entry) { // ! entry not found
|
if (!entry) { // ! entry not found
|
||||||
res.status(404).json({ message: 'Entry not found' });
|
res.status(404).json({ message: 'Entry not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const entryData = entry.get({ plain: true });
|
const entryData = entry.get({ plain: true });
|
||||||
const genres = entryData.genres.map(genre => genre.name);
|
const genres = entryData.genres.map(genre => genre.name);
|
||||||
|
|
||||||
@@ -172,7 +174,10 @@ entryRouter.put('/:id', async (req, res) => {
|
|||||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||||
|
|
||||||
const updatedEntry = await Entry.findByPk(id, {
|
const updatedEntry = await Entry.findByPk(id, {
|
||||||
include: includes
|
include: includes,
|
||||||
|
order: [
|
||||||
|
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const entryData = updatedEntry.get({ plain: true });
|
const entryData = updatedEntry.get({ plain: true });
|
||||||
|
|||||||
+3
-3
@@ -63,12 +63,12 @@ app.use(errorHandler);
|
|||||||
app.use('/killer', killerRouter);
|
app.use('/killer', killerRouter);
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
|
const doUpdate = false;
|
||||||
console.log(`Syncing database schema...`);
|
console.log(`Syncing database schema...`);
|
||||||
sequelize
|
sequelize
|
||||||
// .sync({force: true}) // will drop all tables and recreate them.
|
// .sync({force: true}) // will drop all tables and recreate them.
|
||||||
// .sync({ alter: true }) // will attempt to automatically alter tables to fit the model definitions.
|
.sync({ alter: doUpdate }) // will attempt to automatically alter tables to fit the model definitions.
|
||||||
.sync()
|
// .sync()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log(`Database schema synced...`);
|
console.log(`Database schema synced...`);
|
||||||
initializeData();
|
initializeData();
|
||||||
|
|||||||
@@ -515,7 +515,10 @@ async function refrechEntry(entryId) {
|
|||||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||||
|
|
||||||
const updatedEntry = await Entry.findByPk(entryId, {
|
const updatedEntry = await Entry.findByPk(entryId, {
|
||||||
include: includes
|
include: includes,
|
||||||
|
order: [
|
||||||
|
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const entryData = updatedEntry.get({ plain: true });
|
const entryData = updatedEntry.get({ plain: true });
|
||||||
|
|||||||
@@ -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
|
// get entry seen by entry id
|
||||||
getEntrySeenById(id: string) {
|
getEntrySeenById(id: string) {
|
||||||
return this.http.get<EntrySeen[]>(
|
return this.http.get<EntrySeen[]>(
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.background-wrapper::after {
|
.background-wrapper::after {
|
||||||
content: '';
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -25,13 +25,17 @@
|
|||||||
z-index: 2;
|
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%);
|
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #181c1f 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
color: #212529;
|
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);
|
backdrop-filter: blur(10px);
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
@@ -40,17 +44,15 @@
|
|||||||
/* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
|
/* 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;
|
color: #a7acb1;
|
||||||
background: linear-gradient(to bottom, rgba(33,
|
background: linear-gradient(
|
||||||
37,
|
to bottom,
|
||||||
41,
|
rgba(33, 37, 41, 0.7) 50%,
|
||||||
0.7) 50%, #181c1f 100%);
|
#181c1f 100%
|
||||||
|
);
|
||||||
|
|
||||||
background-color: rgba(33,
|
background-color: rgba(33, 37, 41, 0.7);
|
||||||
37,
|
|
||||||
41,
|
|
||||||
0.7);
|
|
||||||
border: 1px solid #181c1f;
|
border: 1px solid #181c1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +81,6 @@
|
|||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.side-info .list-group-item {
|
.side-info .list-group-item {
|
||||||
background-color: rgba(255, 255, 255, 0.461) !important;
|
background-color: rgba(255, 255, 255, 0.461) !important;
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
@@ -96,7 +97,7 @@
|
|||||||
font-size: 2.9rem !important;
|
font-size: 2.9rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-bs-theme=dark] .title {
|
[data-bs-theme="dark"] .title {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
font-size: 2rem;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +159,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.faved {
|
.faved {
|
||||||
font-variation-settings:
|
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
|
||||||
'FILL' 1,
|
}
|
||||||
'wght' 400,
|
|
||||||
'GRAD' 0,
|
.info-item {
|
||||||
'opsz' 24
|
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>
|
</rating>
|
||||||
</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" *ngIf="entry.entryRating.tmdb_rating"><strong>TMDB Rating:</strong>
|
<li class="list-group-item" *ngIf="entry.entryRating.tmdb_rating"><strong>TMDB Rating:</strong>
|
||||||
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10</li>
|
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10</li>
|
||||||
<li class="list-group-item" *ngIf="entry.entryRating.imdb_rating"><strong>IMDB Rating:</strong>
|
<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 |
|
<li class="list-group-item" *ngIf="entry.date_last_seen"><strong>Last Seen:</strong> {{entry.date_last_seen |
|
||||||
dateFormat:'MMM dd, yyyy'}}
|
dateFormat:'MMM dd, yyyy'}}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
<!-- End Movie Side Info -->
|
<div class="card info-card" *ngIf="entry.entrySeen.length > 0">
|
||||||
<br>
|
|
||||||
<!-- watch history -->
|
|
||||||
<div class="card" *ngIf="entry.entrySeen.length > 0">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Watch History</h5>
|
<h6 class="card-title">Info</h6>
|
||||||
<hr>
|
<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">
|
<div class="accordion" id="accordionWatchHistory">
|
||||||
<!-- start watch history - item -->
|
<!-- start watch history - item -->
|
||||||
<div class="accordion-item" *ngFor="let seen of entry.entrySeen">
|
<div class="accordion-item" *ngFor="let seen of entry.entrySeen">
|
||||||
@@ -61,7 +108,11 @@
|
|||||||
<span class="material-symbols-outlined" (click)="removeEntrySeen(seen.id)">
|
<span class="material-symbols-outlined" (click)="removeEntrySeen(seen.id)">
|
||||||
delete_forever
|
delete_forever
|
||||||
</span>
|
</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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ 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 { LibraryService } from '../../../core/services/library.service';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
|
import { EntrySeen } from '../../../shared/models/entrySeen.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-entry-page',
|
selector: 'app-entry-page',
|
||||||
@@ -125,51 +126,6 @@ export class EntryPageComponent implements OnInit {
|
|||||||
this.getEpisodesSeenHistory();
|
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) {
|
onRatingChange(event: Event) {
|
||||||
this.entryRatingsService
|
this.entryRatingsService
|
||||||
.updateEntryRatings(this.entry.entryRating)
|
.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) {
|
removeEntrySeen(id: number) {
|
||||||
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||||
width: '400px',
|
width: '400px',
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export class SeenModalComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.data == null) {
|
if (this.data.watchDate == null) {
|
||||||
// ? no initial data was passed: populate date field with current date
|
// ? no initial data was passed: populate date field with current date
|
||||||
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
|
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user