Front/Back: add tv-series auto sync when vising the calendar
This commit is contained in:
1 parent
9530b52830
commit
7160669468
2 files changed
+34
-16
No files matched your search
@@ -7,10 +7,11 @@ import {
|
||||
} from '@fullcalendar/core';
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
import interactionPlugin from '@fullcalendar/interaction';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { environment } from '../../../../environments/environment.prod';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { Router } from '@angular/router';
|
||||
import { ToastService } from '../../../shared/services/toast.service';
|
||||
import { EntryService } from '../../../core/services/entry.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-calendar-page',
|
||||
@@ -36,7 +37,12 @@ export class CalendarPageComponent implements OnInit {
|
||||
height: 'auto',
|
||||
};
|
||||
|
||||
constructor(private episodeService: EpisodeService, private router: Router) {}
|
||||
constructor(
|
||||
private episodeService: EpisodeService,
|
||||
private toastService: ToastService,
|
||||
private entryService: EntryService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
const today = new Date();
|
||||
@@ -49,15 +55,24 @@ export class CalendarPageComponent implements OnInit {
|
||||
|
||||
// console.log('First Day of First Week:', firstDayOfFirstWeek);
|
||||
// console.log('Last Day of Last Week:', lastDayOfLastWeek);
|
||||
|
||||
this.fetchEpisodes(firstDayOfFirstWeek, lastDayOfLastWeek);
|
||||
this.toastService.show('Welcome', 'hello', 'success');
|
||||
this.entryService.syncSeries().subscribe({
|
||||
next: (result) => {
|
||||
console.log(`Tv-Series Synced Successfully`);
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Error Syncing Tv-Series Successfully`);
|
||||
},
|
||||
});
|
||||
// this.fetchEpisodes(firstDayOfFirstWeek, lastDayOfLastWeek);
|
||||
}
|
||||
|
||||
fetchEpisodes(startDate: string, endDate: string) {
|
||||
this.episodeService.getMonthEpisodes(startDate, endDate).subscribe({
|
||||
next: (result) => {
|
||||
// console.log(result);
|
||||
this.calendarOptions.events = result
|
||||
.filter((e) => e.season.season_number != 0)
|
||||
.filter((e) => e.season.season_number != 0 && e.entry.showInCalendar)
|
||||
.map((e) => {
|
||||
return {
|
||||
title: `S${e.season.season_number}E${e.episode_number}`,
|
||||
@@ -78,9 +93,9 @@ export class CalendarPageComponent implements OnInit {
|
||||
|
||||
// ? month change
|
||||
handleDatesSet(arg: DatesSetArg) {
|
||||
// console.log('View dates changed:', arg.startStr, arg.endStr);
|
||||
console.log('View dates changed:', arg.startStr, arg.endStr);
|
||||
|
||||
this.fetchEpisodes(arg.startStr, arg.endStr);
|
||||
this.fetchEpisodes(arg.startStr.split('T')[0], arg.endStr.split('T')[0]);
|
||||
}
|
||||
|
||||
handleEventClick(clickInfo: EventClickArg) {
|
||||
@@ -89,7 +104,6 @@ export class CalendarPageComponent implements OnInit {
|
||||
// const event = clickInfo.event as any;
|
||||
// console.log(event);
|
||||
// this.router.navigate([`/entries/${clickInfo.event.publicId}`]);
|
||||
|
||||
// Example: You can also access other event properties
|
||||
// console.log('Clicked event details:', clickInfo.event);
|
||||
}
|
||||
@@ -149,8 +163,8 @@ export class CalendarPageComponent implements OnInit {
|
||||
|
||||
getPosterPath(entry: Entry) {
|
||||
// * Not in library, use TMDB poster
|
||||
if (!entry.isInLibrary)
|
||||
return `https://image.tmdb.org/t/p/w342` + entry.poster_path;
|
||||
// if (!entry.isInLibrary)
|
||||
// return `https://image.tmdb.org/t/p/w342` + entry.poster_path;
|
||||
|
||||
// * Is in library: use a local poster
|
||||
if (entry.medias) {
|
||||
|
||||
Reference in new issue
Block a user