add season card component
This commit is contained in:
1 parent
3cde0731a1
commit
3374aa9944
4 files changed
+147
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Season } from '../../models/season.model';
|
||||
import { SeasonService } from '../../../core/services/season.service';
|
||||
import {
|
||||
trigger,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
animate,
|
||||
} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-season-main-card',
|
||||
templateUrl: './season-main-card.component.html',
|
||||
styleUrl: './season-main-card.component.css',
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
// void => *
|
||||
style({ opacity: 0 }),
|
||||
animate('0.5s ease-in', style({ opacity: 1 })),
|
||||
]),
|
||||
transition(':leave', [
|
||||
// * => void
|
||||
animate('0.5s ease-out', style({ opacity: 0 })),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class SeasonMainCardComponent implements OnInit {
|
||||
@Input() season: Season = {} as Season;
|
||||
|
||||
constructor(private seasonService: SeasonService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// // TODO: GET SEASON EPISODES
|
||||
// this.seasonService.getSeasonById(this.season.id).subscribe({
|
||||
// next: (season) => {
|
||||
// console.log(season);
|
||||
// this.season = season;
|
||||
// },
|
||||
// error: (error) => {
|
||||
// console.log(`Couldn't fetch season data:`, error);
|
||||
// // TODO show notification
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
get posterPath() {
|
||||
if (this.season.poster_path == null)
|
||||
return 'assets/images/default/default-poster.png';
|
||||
|
||||
return 'http://image.tmdb.org/t/p/w154/' + this.season.poster_path;
|
||||
}
|
||||
|
||||
get episodesWatchedCount() {
|
||||
let count = 0;
|
||||
this.season.episodes.forEach((ep) => {
|
||||
if (ep.date_first_seen != null) count++;
|
||||
});
|
||||
|
||||
if (this.season.episode_count == null) return 0;
|
||||
|
||||
let value = (count * 100) / this.season.episode_count;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user