Frontend: Added Person & Credit model + People service
This commit is contained in:
1 parent
381f921df7
commit
1a18b826de
6 files changed
+134
-3
No files matched your search
@@ -14,6 +14,7 @@ import { EpisodeService } from './services/episode.service';
|
|||||||
import { EpisodeSeenService } from './services/episode-seen.service';
|
import { EpisodeSeenService } from './services/episode-seen.service';
|
||||||
import { ThemeService } from './services/theme.service';
|
import { ThemeService } from './services/theme.service';
|
||||||
import { SeasonService } from './services/season.service';
|
import { SeasonService } from './services/season.service';
|
||||||
|
import { PeopleService } from './services/people.service';
|
||||||
import { SearchPopupComponent } from './components/search-popup/search-popup.component';
|
import { SearchPopupComponent } from './components/search-popup/search-popup.component';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { SharedModule } from '../shared/shared.module';
|
import { SharedModule } from '../shared/shared.module';
|
||||||
@@ -34,14 +35,14 @@ import { ConfigService } from './services/config.service';
|
|||||||
RouterModule,
|
RouterModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
],
|
], providers: [
|
||||||
providers: [
|
|
||||||
CollectionService,
|
CollectionService,
|
||||||
EntrySeenService,
|
EntrySeenService,
|
||||||
EntryService,
|
EntryService,
|
||||||
EpisodeSeenService,
|
EpisodeSeenService,
|
||||||
EpisodeService,
|
EpisodeService,
|
||||||
LibraryService,
|
LibraryService,
|
||||||
|
PeopleService,
|
||||||
SeasonService,
|
SeasonService,
|
||||||
|
|
||||||
TmdbService,
|
TmdbService,
|
||||||
|
|||||||
@@ -18,5 +18,4 @@ export class ConfigService {
|
|||||||
public getTmdbApiKey(): string {
|
public getTmdbApiKey(): string {
|
||||||
return environment.TMDB_API_KEY;
|
return environment.TMDB_API_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { ConfigService } from './config.service';
|
||||||
|
import { Person } from '../../shared/models/person.model';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PeopleService {
|
||||||
|
private backend_apiUrl;
|
||||||
|
private apiAction = 'people';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient, private configService: ConfigService) {
|
||||||
|
this.backend_apiUrl = this.configService.getBackendApiUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all people
|
||||||
|
getPeople(): Observable<Person[]> {
|
||||||
|
return this.http.get<Person[]>(`${this.backend_apiUrl}/${this.apiAction}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get popular people with optional limit
|
||||||
|
getPopularPeople(limit: number = 10): Observable<Person[]> {
|
||||||
|
return this.http.get<Person[]>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/popular?limit=${limit}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a person by ID
|
||||||
|
getPersonById(id: number): Observable<Person> {
|
||||||
|
return this.http.get<Person>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/${id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search people by name
|
||||||
|
searchPeople(query: string): Observable<Person[]> {
|
||||||
|
return this.http.get<Person[]>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/search?query=${query}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new person
|
||||||
|
createPerson(person: Person): Observable<Person> {
|
||||||
|
return this.http.post<Person>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||||
|
person
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch and save a person from TMDB
|
||||||
|
fetchPersonFromTmdb(tmdbId: string): Observable<Person> {
|
||||||
|
return this.http.post<Person>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/fetch`,
|
||||||
|
{
|
||||||
|
tmdb_id: tmdbId,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update a person
|
||||||
|
updatePerson(person: Person): Observable<Person> {
|
||||||
|
return this.http.put<Person>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/${person.id}`,
|
||||||
|
person
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh a person's data from TMDB
|
||||||
|
refreshPerson(id: number): Observable<Person> {
|
||||||
|
return this.http.put<Person>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/${id}/refresh`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a person
|
||||||
|
deletePerson(id: number): Observable<any> {
|
||||||
|
return this.http.delete<any>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/${id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a person's credits (movies/TV shows they've been in)
|
||||||
|
getPersonCredits(id: number): Observable<any[]> {
|
||||||
|
return this.http.get<any[]>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/${id}/credits`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Entry } from './entry.model';
|
||||||
|
import { Person } from './person.model';
|
||||||
|
|
||||||
|
export interface Credit {
|
||||||
|
id?: number;
|
||||||
|
entry_id: number;
|
||||||
|
people_id: number;
|
||||||
|
character?: string;
|
||||||
|
department?: string;
|
||||||
|
job?: string;
|
||||||
|
order?: number;
|
||||||
|
entry?: Entry;
|
||||||
|
person?: Person;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { Media } from './media.model';
|
|||||||
import { Season } from './season.model';
|
import { Season } from './season.model';
|
||||||
import { Collection } from './collection.model';
|
import { Collection } from './collection.model';
|
||||||
import { Network } from './network.model';
|
import { Network } from './network.model';
|
||||||
|
import { Credit } from './credit.model';
|
||||||
|
|
||||||
export interface Entry {
|
export interface Entry {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -46,6 +47,7 @@ export interface Entry {
|
|||||||
genres: string[];
|
genres: string[];
|
||||||
medias: Media[];
|
medias: Media[];
|
||||||
networks: Network[];
|
networks: Network[];
|
||||||
|
credits: Credit[];
|
||||||
|
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
banner_path: string;
|
banner_path: string;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { Credit } from './credit.model';
|
||||||
|
import { Media } from './media.model';
|
||||||
|
|
||||||
|
export interface Person {
|
||||||
|
id?: number;
|
||||||
|
tmdb_id?: string;
|
||||||
|
name: string;
|
||||||
|
birthday?: string;
|
||||||
|
deathday?: string | null;
|
||||||
|
gender?: number;
|
||||||
|
biography?: string;
|
||||||
|
place_of_birth?: string;
|
||||||
|
adult?: boolean;
|
||||||
|
popularity?: number;
|
||||||
|
known_for_department?: string;
|
||||||
|
homepage?: string | null;
|
||||||
|
imdb_id?: string;
|
||||||
|
profile_path?: string;
|
||||||
|
last_fetch?: string;
|
||||||
|
profile_update?: string;
|
||||||
|
fully_fetched?: boolean;
|
||||||
|
medias?: Media[];
|
||||||
|
credits?: Credit[];
|
||||||
|
}
|
||||||
Reference in new issue
Block a user