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 { ThemeService } from './services/theme.service';
|
||||
import { SeasonService } from './services/season.service';
|
||||
import { PeopleService } from './services/people.service';
|
||||
import { SearchPopupComponent } from './components/search-popup/search-popup.component';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
@@ -34,14 +35,14 @@ import { ConfigService } from './services/config.service';
|
||||
RouterModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
providers: [
|
||||
], providers: [
|
||||
CollectionService,
|
||||
EntrySeenService,
|
||||
EntryService,
|
||||
EpisodeSeenService,
|
||||
EpisodeService,
|
||||
LibraryService,
|
||||
PeopleService,
|
||||
SeasonService,
|
||||
|
||||
TmdbService,
|
||||
|
||||
@@ -18,5 +18,4 @@ export class ConfigService {
|
||||
public getTmdbApiKey(): string {
|
||||
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`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user