F: Added toast to entry-page and other components
This commit is contained in:
1 parent
d01913bb6d
commit
8533076080
6 files changed
+108
-78
No files matched your search
@@ -39,7 +39,7 @@ export class CalendarPageComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private episodeService: EpisodeService,
|
||||
private toastService: ToastService,
|
||||
private toast: ToastService,
|
||||
private entryService: EntryService,
|
||||
private router: Router,
|
||||
private configService: ConfigService
|
||||
@@ -56,13 +56,13 @@ export class CalendarPageComponent implements OnInit {
|
||||
|
||||
// console.log('First Day of First Week:', firstDayOfFirstWeek);
|
||||
// console.log('Last Day of Last Week:', lastDayOfLastWeek);
|
||||
this.toastService.show('Welcome', 'hello', 'success');
|
||||
this.entryService.syncSeries().subscribe({
|
||||
next: (result) => {
|
||||
console.log(`Tv-Series Synced Successfully`);
|
||||
// console.log(`Tv-Series Synced Successfully`);
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Error Syncing Tv-Series Successfully`);
|
||||
this.toast.show('', 'Error Syncing Tv-Series', 'error');
|
||||
// console.log(`Error Syncing Tv-Series`);
|
||||
},
|
||||
});
|
||||
// this.fetchEpisodes(firstDayOfFirstWeek, lastDayOfLastWeek);
|
||||
@@ -107,7 +107,6 @@ export class CalendarPageComponent implements OnInit {
|
||||
// alert(`Event clicked: ${clickInfo.event.extendedProps['id']}`);
|
||||
// const event = clickInfo.event as any;
|
||||
const entryId = clickInfo.event.extendedProps['id'];
|
||||
console.log(entryId);
|
||||
this.router.navigate([`/entries/${entryId}`]);
|
||||
// Example: You can also access other event properties
|
||||
// console.log('Clicked event details:', clickInfo.event);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { trigger, style, transition, animate } from '@angular/animations';
|
||||
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -16,13 +16,13 @@ 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';
|
||||
import { EntrySeen } from '../../../shared/models/entry-seen.model';
|
||||
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
|
||||
import { MediaModalComponent } from '../media-modal/media-modal.component';
|
||||
import { Collection } from '../../../shared/models/collection.model';
|
||||
import { EntrySettingsModalComponent } from '../entry-settings-modal/entry-settings-modal.component';
|
||||
import { ConfigService } from '../../../core/services/config.service';
|
||||
import { ToastService } from '../../../shared/services/toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-page',
|
||||
@@ -67,7 +67,7 @@ export class EntryPageComponent implements OnInit {
|
||||
private dialog: MatDialog,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toastr: ToastrService
|
||||
private toast: ToastService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -104,15 +104,10 @@ export class EntryPageComponent implements OnInit {
|
||||
},
|
||||
error: (error) => {
|
||||
// console.log(`Couldn't fetch season episodes data:`, error);
|
||||
this.toastr.success(
|
||||
this.toast.show(
|
||||
'Error',
|
||||
`Couldn't get season ${season.season_number} episodes.`,
|
||||
{
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
progressAnimation: 'increasing',
|
||||
}
|
||||
'error'
|
||||
);
|
||||
season.episodes = [];
|
||||
},
|
||||
@@ -143,14 +138,13 @@ export class EntryPageComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (entryRatings) => {
|
||||
if (entryRatings) {
|
||||
// TODO show notification
|
||||
this.entry.entryRating = entryRatings;
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO show notification
|
||||
console.error('Error updating entryRatings:', error);
|
||||
this.toast.show('', `Error updating rating.`, 'error');
|
||||
// console.error('Error updating entryRatings:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -159,20 +153,20 @@ export class EntryPageComponent implements OnInit {
|
||||
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 : {},
|
||||
data: entrySeen.id
|
||||
? {
|
||||
watchDate: entrySeen.date_seen,
|
||||
watchedWith: entrySeen.seen_with,
|
||||
}
|
||||
: {},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.watchDate == '') {
|
||||
// TODO show no was passed date notification
|
||||
this.toast.show('', 'You did not provide a watch date.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,7 +183,7 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
this.entrySeenService.updateEntrySeen(es).subscribe({
|
||||
next: (updatedEntrySeen) => {
|
||||
// TODO show confirm notification
|
||||
this.toast.show('', 'Watch record updated.', 'success');
|
||||
// ? 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) {
|
||||
@@ -216,7 +210,8 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entrySeen:', error);
|
||||
this.toast.show('', 'Error updating a watch record.', 'error');
|
||||
// console.error('Error updating entrySeen:', error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -226,7 +221,7 @@ export class EntryPageComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (entrySeen) => {
|
||||
if (entrySeen) {
|
||||
// TODO show confirm notification
|
||||
this.toast.show('', 'Watch record created.', 'success');
|
||||
this.entry.entrySeen.push(entrySeen);
|
||||
|
||||
// ? if the entry was in watch list creating and entry-seen would have removed it
|
||||
@@ -253,12 +248,11 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
this.toast.show('', 'Error creating a watch record.', 'error');
|
||||
console.error('Error adding entrySeen:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// TODO show notification
|
||||
} else {
|
||||
// console.log('Seen dialog was cancelled');
|
||||
}
|
||||
@@ -285,7 +279,7 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
this.entrySeenService.removeEntrySeen(id).subscribe({
|
||||
next: () => {
|
||||
this.toastr.success('success', `Removed successfuly.`, {
|
||||
this.toast.show('success', `Removed successfuly.`, 'success', {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
@@ -300,9 +294,11 @@ export class EntryPageComponent implements OnInit {
|
||||
this.entry.date_first_seen = null;
|
||||
this.entry.date_last_seen = null;
|
||||
}
|
||||
|
||||
this.toast.show('', 'Watch record deleted.');
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO show notification
|
||||
this.toast.show('', 'Error deleting watch record.', 'error');
|
||||
console.error('Error deleting entrySeen:', error);
|
||||
},
|
||||
});
|
||||
@@ -366,7 +362,7 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
// TODO update entry page collections
|
||||
// TODO * update entry page collections
|
||||
this.entryService.getEntryById(this.entry.id).subscribe({
|
||||
next: (result) => {
|
||||
this.entry.collections = result.collections.map((c) => {
|
||||
@@ -440,16 +436,23 @@ export class EntryPageComponent implements OnInit {
|
||||
return c;
|
||||
});
|
||||
// console.log(`Entry refreched: `, entry);
|
||||
this.toastr.success(`Movie refreshed successfuly.`, 'Success', {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
progressAnimation: 'increasing',
|
||||
});
|
||||
this.toast.show(
|
||||
'',
|
||||
`${
|
||||
this.entry.is_tvseries ? 'Tv-Serie' : 'Movie'
|
||||
} info refreshed successfuly.`,
|
||||
'success'
|
||||
);
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO show error notification
|
||||
console.error('Error refreching movie info:', error);
|
||||
this.toast.show(
|
||||
'',
|
||||
`Couln't refresh ${
|
||||
this.entry.is_tvseries ? 'Tv-Serie' : 'Movie'
|
||||
} info.`,
|
||||
'error'
|
||||
);
|
||||
// console.error('Error refreching movie info:', error);
|
||||
},
|
||||
complete: () => {
|
||||
this.lockActions = false;
|
||||
@@ -460,10 +463,24 @@ export class EntryPageComponent implements OnInit {
|
||||
fetchEntryCollection() {
|
||||
this.lockActions = true;
|
||||
this.entryService.fetchEntryCollectionById(this.entry.id).subscribe({
|
||||
next: (result) => {},
|
||||
next: (result) => {
|
||||
this.toast.show(
|
||||
'',
|
||||
`${
|
||||
this.entry.is_tvseries ? 'Tv-Serie' : 'Movie'
|
||||
} info refreshed successfuly.`,
|
||||
'success'
|
||||
);
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO show error notification
|
||||
console.error('Error refreching movie info:', error);
|
||||
this.toast.show(
|
||||
'',
|
||||
`Couln't refresh ${
|
||||
this.entry.is_tvseries ? 'Tv-Serie' : 'Movie'
|
||||
} info.`,
|
||||
'error'
|
||||
);
|
||||
// console.error('Error refreching movie collection:', error);
|
||||
},
|
||||
complete: () => {
|
||||
this.lockActions = false;
|
||||
@@ -547,7 +564,7 @@ export class EntryPageComponent implements OnInit {
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
// ? if an episode-seen was created then refresh the watch history table
|
||||
if (result && result.created) {
|
||||
// TODO: improve this logic, there shouldn't be a need to whole recall
|
||||
// TODO * improve this logic, there shouldn't be a need to whole recall
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
|
||||
@@ -580,15 +597,20 @@ export class EntryPageComponent implements OnInit {
|
||||
season.episodes = episodes;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Couldn't fetch season episodes data:`, error);
|
||||
// TODO show notification
|
||||
season.episodes = [];
|
||||
this.toast.show(
|
||||
'',
|
||||
'Error while adding episode watch record.',
|
||||
'error'
|
||||
);
|
||||
// console.log(`Couldn't fetch season episodes data:`, error);
|
||||
// season.episodes = [];
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
this.toast.show('', 'Episode watch record created.', 'success');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -627,6 +649,7 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
this.toast.show('', 'Episode watch record upated.', 'success');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -676,19 +699,27 @@ export class EntryPageComponent implements OnInit {
|
||||
season.episodes = episodes;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Couldn't fetch season episodes data:`, error);
|
||||
// TODO show notification
|
||||
season.episodes = [];
|
||||
this.toast.show(
|
||||
'',
|
||||
'Error while deleting episode watch record.',
|
||||
'error'
|
||||
);
|
||||
// console.log(`Couldn't fetch season episodes data:`, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
// TODO show notification
|
||||
this.toast.show('', 'Episode watch record deleted.', 'success');
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Episode seen delete error: `, error);
|
||||
this.toast.show(
|
||||
'',
|
||||
`Error while deleting episode watch record.`,
|
||||
'error'
|
||||
);
|
||||
// console.log(`Episode seen delete error: `, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -788,13 +819,7 @@ export class EntryPageComponent implements OnInit {
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
// TODO show notification
|
||||
} else {
|
||||
// console.log('Seen dialog was cancelled');
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().subscribe((result) => {});
|
||||
}
|
||||
|
||||
settingsModal() {
|
||||
@@ -810,6 +835,7 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.entry) {
|
||||
this.entry.watchlist = result.entry.watchlist;
|
||||
this.entry.favorit = result.entry.favorit;
|
||||
this.entry.hidden = result.entry.hidden;
|
||||
@@ -817,6 +843,11 @@ export class EntryPageComponent implements OnInit {
|
||||
this.entry.autoSync = result.entry.autoSync;
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
|
||||
this.toast.show('', `Settings updated.`, 'success');
|
||||
} else {
|
||||
this.toast.show('', `Couldn't updated settings.`, 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-4
@@ -12,7 +12,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
templateUrl: './entry-settings-modal.component.html',
|
||||
styleUrls: ['./entry-settings-modal.component.css'],
|
||||
})
|
||||
export class EntrySettingsModalComponent implements OnInit {
|
||||
export class EntrySettingsModalComponent {
|
||||
entryId!: number;
|
||||
entryForm: FormGroup;
|
||||
|
||||
@@ -38,8 +38,6 @@ export class EntrySettingsModalComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
onSubmit() {
|
||||
const entryData = this.entryForm.value;
|
||||
|
||||
@@ -48,7 +46,8 @@ export class EntrySettingsModalComponent implements OnInit {
|
||||
this.dialogRef.close({ entry: result });
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
// console.log(`Error while updating entry settings`, error);
|
||||
this.dialogRef.close();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
-1
@@ -38,6 +38,5 @@
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end; /* Moves button to the right */
|
||||
background: white;
|
||||
}
|
||||
|
||||
+5
-11
@@ -50,7 +50,7 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
public dialogRef: MatDialogRef<UserCollectionsModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private collectionService: CollectionService,
|
||||
private toastService: ToastService
|
||||
private toast: ToastService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -128,7 +128,7 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
// TODO TOAST entry added to collection
|
||||
this.showNotification(
|
||||
this.toast.show(
|
||||
'Entry Added',
|
||||
'Entry added successfully',
|
||||
'success'
|
||||
@@ -138,7 +138,7 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error:', error);
|
||||
// this.showNotification('Error', 'Failed to add entry', 'error');
|
||||
this.toast.show('Error', 'Failed to add entry', 'error');
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -149,16 +149,15 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
.removeEntryFromCollection(collection.id, this.entryId)
|
||||
.subscribe({
|
||||
next: (result) => {
|
||||
this.showNotification(
|
||||
this.toast.show(
|
||||
'Entry Removed',
|
||||
'Entry removed successfully',
|
||||
'success'
|
||||
);
|
||||
// TODO TOAST ENTRY REMOVE FROM COLLECTION
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error removing entry:', error);
|
||||
this.showNotification('Error', 'Failed to remove entry', 'error');
|
||||
this.toast.show('Error', 'Failed to remove entry', 'error');
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -171,9 +170,4 @@ export class UserCollectionsModalComponent implements OnInit {
|
||||
onSubmit(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
showNotification(title: string, message: string, type: string): void {
|
||||
// this.notificationComponent.showNotification(message, type);
|
||||
this.toastService.show(title, message, type);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,12 @@ import {
|
||||
} from '@angular/animations';
|
||||
import { formatDate } from '@angular/common';
|
||||
|
||||
interface ModalInputs {
|
||||
title?: string;
|
||||
watchedWith?: string;
|
||||
watchDate?: string;
|
||||
hideSeenWith?: boolean;
|
||||
}
|
||||
@Component({
|
||||
selector: 'app-seen-modal',
|
||||
templateUrl: './seen-modal.component.html',
|
||||
@@ -33,7 +39,7 @@ import { formatDate } from '@angular/common';
|
||||
],
|
||||
})
|
||||
export class SeenModalComponent implements OnInit {
|
||||
title: string = 'Watch Details';
|
||||
title: string = 'Watch Record Details';
|
||||
hideSeenWith: boolean = false;
|
||||
|
||||
public watchDate: string = '';
|
||||
@@ -41,7 +47,7 @@ export class SeenModalComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<SeenModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
@Inject(MAT_DIALOG_DATA) public data: ModalInputs
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -65,6 +71,8 @@ export class SeenModalComponent implements OnInit {
|
||||
'yyyy-MM-dd',
|
||||
'en-US'
|
||||
);
|
||||
} else {
|
||||
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
|
||||
}
|
||||
} else {
|
||||
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
|
||||
|
||||
Reference in new issue
Block a user