diff --git a/frontend/src/app/features/people/people-details/people-details.component.css b/frontend/src/app/features/people/people-details/people-details.component.css new file mode 100644 index 0000000..c8086c2 --- /dev/null +++ b/frontend/src/app/features/people/people-details/people-details.component.css @@ -0,0 +1,164 @@ +.person-details-container { + padding: 20px 0; +} + +.person-header { + margin-bottom: 30px; +} + +.profile-image-container { + border-radius: 8px; + overflow: hidden; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2); +} + +.profile-image { + width: 100%; + display: block; +} + +.person-name { + font-size: 2rem; + font-weight: 700; + margin-bottom: 15px; +} + +/* Biography section */ +.biography-section { + margin-bottom: 30px; +} + +.biography-section h3 { + font-size: 1.5rem; + font-weight: 600; + margin-bottom: 15px; +} + +.biography-text { + line-height: 1.6; + color: #333; +} + +.missing-biography { + padding: 15px; + background-color: #f8f9fa; + border-radius: 6px; + font-style: italic; + color: #6c757d; +} + +/* Personal info sidebar */ +.person-info-sidebar { + background-color: #f8f9fa; + border-radius: 8px; + padding: 15px; + margin-top: 20px; +} + +.person-info-sidebar h5 { + font-weight: 600; + margin-bottom: 15px; + padding-bottom: 10px; + border-bottom: 1px solid #dee2e6; +} + +.info-item { + margin-bottom: 12px; +} + +.info-label { + display: block; + font-weight: 600; + font-size: 0.85rem; + color: #6c757d; +} + +.info-value { + display: block; + font-size: 0.95rem; +} + +/* Credits section */ +.credits-section h3 { + font-size: 1.5rem; + font-weight: 600; + margin-bottom: 15px; + padding-bottom: 10px; + border-bottom: 1px solid #dee2e6; +} + +.credits-list { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); + gap: 15px; +} + +.credit-card { + border-radius: 8px; + overflow: hidden; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + cursor: pointer; + transition: transform 0.3s ease, box-shadow 0.3s ease; + height: 100%; +} + +.credit-card:hover { + transform: translateY(-3px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); +} + +.credit-poster { + height: 225px; + overflow: hidden; +} + +.entry-poster { + width: 100%; + height: 100%; + object-fit: cover; +} + +.credit-info { + padding: 10px; +} + +.credit-title { + font-weight: 600; + font-size: 0.9rem; + margin-bottom: 3px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.credit-character, .credit-job { + font-size: 0.85rem; + color: #6c757d; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.credit-year { + font-size: 0.8rem; + color: #adb5bd; +} + +/* Loading container */ +.loading-container, .error-container, .not-found-container { + display: flex; + justify-content: center; + align-items: center; + min-height: 400px; +} + +/* Responsive adjustments */ +@media (max-width: 767px) { + .person-info-sidebar { + margin-bottom: 20px; + } + + .credits-list { + grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); + } +} \ No newline at end of file diff --git a/frontend/src/app/features/people/people-details/people-details.component.html b/frontend/src/app/features/people/people-details/people-details.component.html new file mode 100644 index 0000000..7e3f65e --- /dev/null +++ b/frontend/src/app/features/people/people-details/people-details.component.html @@ -0,0 +1,155 @@ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+ + +
+
Personal Info
+ +
+ Known For + {{ person.known_for_department || 'Unknown' }} +
+ +
+ Gender + {{ getGenderText() }} +
+ +
+ Birthday + {{ formatDate(person.birthday) }} +
+ +
+ Day of Death + {{ formatDate(person.deathday) }} +
+ +
+ Age + {{ calculateAge(person.birthday, person.deathday) }} +
+ +
+ Place of Birth + {{ person.place_of_birth }} +
+ +
+ Popularity + {{ person.popularity | number:'1.1-1' }} +
+ +
+ IMDB + + + View on IMDB + + +
+
+
+ + +
+
+

{{ person.name }}

+ + +
+

Biography

+
+
+
+

We don't have a biography for {{ person.name }}.

+
+
+ + +
+

Acting

+
+
+
+ +
+
+
{{ credit.entry?.title }}
+
{{ credit.character }}
+
+ {{ credit.entry?.release_date | date:'yyyy' }} +
+
+
+
+
+ + +
+

Production

+
+
+
+ +
+
+
{{ credit.entry?.title }}
+
{{ credit.job }}
+
+ {{ credit.entry?.release_date | date:'yyyy' }} +
+
+
+
+
+
+
+
+
+ +
+
+ Loading... +
+
+ +
+ +
+ +
+ +
diff --git a/frontend/src/app/features/people/people-details/people-details.component.spec.ts b/frontend/src/app/features/people/people-details/people-details.component.spec.ts new file mode 100644 index 0000000..5ca282c --- /dev/null +++ b/frontend/src/app/features/people/people-details/people-details.component.spec.ts @@ -0,0 +1,28 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { PeopleDetailsComponent } from './people-details.component'; + +describe('PeopleDetailsComponent', () => { + let component: PeopleDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PeopleDetailsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PeopleDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/features/people/people-details/people-details.component.ts b/frontend/src/app/features/people/people-details/people-details.component.ts new file mode 100644 index 0000000..2c31f02 --- /dev/null +++ b/frontend/src/app/features/people/people-details/people-details.component.ts @@ -0,0 +1,222 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subject, takeUntil } from 'rxjs'; +import { PeopleService } from '../../../core/services/people.service'; +import { ConfigService } from '../../../core/services/config.service'; +import { Person } from '../../../shared/models/person.model'; +import { Credit } from '../../../shared/models/credit.model'; + +@Component({ + selector: 'app-people-details', + templateUrl: './people-details.component.html', + styleUrls: ['./people-details.component.css'], +}) +export class PeopleDetailsComponent implements OnInit, OnDestroy { + person: Person | null = null; + loading: boolean = true; + error: string | null = null; + backendUrl: string; + defaultImage = 'assets/images/default-profile.png'; + + // For credits + castCredits: Credit[] = []; + crewCredits: Credit[] = []; + + private destroy$ = new Subject(); + + constructor( + private peopleService: PeopleService, + private route: ActivatedRoute, + private router: Router, + private configService: ConfigService + ) { + this.backendUrl = this.configService.getBackendApiUrl(); + } + + ngOnInit() { + this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => { + const id = params['id']; + if (id) { + this.loadPersonDetails(Number(id)); + } + }); + } + + ngOnDestroy() { + this.destroy$.next(); + this.destroy$.complete(); + } + + loadPersonDetails(id: number) { + this.loading = true; + this.error = null; + + this.peopleService + .getPersonById(id) + .pipe(takeUntil(this.destroy$)) + .subscribe({ + next: (person) => { + this.person = person; + this.processPerson(); + this.loading = false; + }, + error: (err) => { + console.error('Error loading person details:', err); + this.error = 'Failed to load person details. Please try again later.'; + this.loading = false; + }, + }); + } + + private processPerson() { + if (!this.person || !this.person.credits) return; + + // Separate cast and crew credits + this.castCredits = this.person.credits.filter( + (credit) => + credit.job?.toLowerCase() === 'actor' || + credit.job?.toLowerCase() === 'actress' || + credit.department?.toLowerCase() === 'acting' + ); + + this.crewCredits = this.person.credits.filter( + (credit) => + credit.job?.toLowerCase() !== 'actor' && + credit.job?.toLowerCase() !== 'actress' && + credit.department?.toLowerCase() !== 'acting' + ); + + // Sort credits by entry popularity or release date + this.castCredits.sort((a, b) => { + if (a.entry?.entryRating.tmdb_rating && b.entry?.entryRating.tmdb_rating) { + return b.entry.entryRating.tmdb_rating - a.entry.entryRating.tmdb_rating; + } + return 0; + }); + + this.crewCredits.sort((a, b) => { + if (a.entry?.entryRating.tmdb_rating && b.entry?.entryRating.tmdb_rating) { + return b.entry.entryRating.tmdb_rating - a.entry.entryRating.tmdb_rating; + } + return 0; + }); + } + + refreshPersonDetails() { + if (!this.person || !this.person.id) return; + + this.loading = true; + this.peopleService + .refreshPerson(this.person.id) + .pipe(takeUntil(this.destroy$)) + .subscribe({ + next: (person) => { + this.person = person; + this.processPerson(); + this.loading = false; + }, + error: (err) => { + console.error('Error refreshing person details:', err); + this.error = + 'Failed to refresh person details. Please try again later.'; + this.loading = false; + }, + }); + } + + getProfileImageUrl(): string { + if (!this.person) return this.defaultImage; + + // First check if we have a local media + // if (this.person.medias && this.person.medias.length > 0) { + // const profileMedia = this.person.medias.find((m) => m.type === 'profile'); + // if (profileMedia) { + // return `${this.backendUrl}/images/people/profiles/${profileMedia.file_name}`; + // } + // } + + // Fallback to TMDB image if available + if (this.person.profile_path) { + return `https://image.tmdb.org/t/p/w342${this.person.profile_path}`; + } + + // Default image if nothing else is available + return this.defaultImage; + } + + getEntryImageUrl(credit: Credit): string { + if (!credit.entry) return this.defaultImage; + + // First check if we have a local media + // if (credit.entry.medias && credit.entry.medias.length > 0) { + // const posterMedia = credit.entry.medias.find((m) => m.type === 'poster'); + // if (posterMedia) { + // return `${this.backendUrl}/images/entries/posters/${posterMedia.file_name}`; + // } + // } + + // Fallback to TMDB image if available + if (credit.entry.poster_path) { + return `https://image.tmdb.org/t/p/w185${credit.entry.poster_path}`; + } + + // Default image if nothing else is available + return this.defaultImage; + } + + getGenderText(): string { + if (!this.person || this.person.gender === undefined) + return 'Not specified'; + + switch (this.person.gender) { + case 0: + return 'Not specified'; + case 1: + return 'Female'; + case 2: + return 'Male'; + case 3: + return 'Non-binary'; + default: + return 'Not specified'; + } + } + + formatDate(dateString?: string): string { + if (!dateString) return 'Unknown'; + + const date = new Date(dateString); + if (isNaN(date.getTime())) return 'Unknown'; + + return date.toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + }); + } + + calculateAge(birthDate?: string, deathDate?: string | null): string { + if (!birthDate) return 'Unknown'; + + const birth = new Date(birthDate); + if (isNaN(birth.getTime())) return 'Unknown'; + + let end = deathDate ? new Date(deathDate) : new Date(); + if (deathDate && isNaN(end.getTime())) end = new Date(); + + let age = end.getFullYear() - birth.getFullYear(); + const monthDiff = end.getMonth() - birth.getMonth(); + + if (monthDiff < 0 || (monthDiff === 0 && end.getDate() < birth.getDate())) { + age--; + } + + return `${age} years`; + } + + navigateToEntry(entryId?: number) { + if (entryId) { + this.router.navigate(['/entries', entryId]); + } + } +}