Files
frontend/src/app/http.service.ts
Piet Ostendorp 4f5a8e9661 Add IMDb movie importer feature and unify header
Introduces a new movie importer feature allowing admins to search and import movies from IMDb, including new components for search, result display, and error handling. Replaces the schedule header with a reusable menu header component. Updates routing, navigation, and HTTP service to support the new importer. Adds a poster placeholder image and improves poster error handling.
2025-11-07 01:57:42 +01:00

110 lines
3.3 KiB
TypeScript

import { Kinosaal, Sitzplatz, Vorstellung, Film, OmdbSearch } from '@infinimotion/model-frontend';
import { HttpClient } from "@angular/common/http";
import { inject, Injectable } from "@angular/core";
import { Observable } from "rxjs";
@Injectable({
providedIn: 'root'
})
export class HttpService {
private http = inject(HttpClient);
private baseUrl = 'https://infinimotion.de/api/';
/* Kinosaal APIs */
/* GET /api/kinosaal */
getAllKinosaal(): Observable<Kinosaal[]> {
return this.http.get<Kinosaal[]>(`${this.baseUrl}kinosaal`);
}
/* GET /api/kinosaal/{id} */
getKinosaalById(id: number): Observable<Kinosaal> {
return this.http.get<Kinosaal>(`${this.baseUrl}kinosaal/${id}`);
}
/* POST /api/kinosaal */
addKinosaal(kinosaal: Omit<Kinosaal, 'id'>): Observable<Kinosaal> {
return this.http.post<Kinosaal>(`${this.baseUrl}kinosaal`, kinosaal);
}
/* PUT /api/kinosaal/{id} */
updateKinosaal(id: number, kinosaal: Partial<Kinosaal>): Observable<Kinosaal> {
return this.http.put<Kinosaal>(`${this.baseUrl}kinosaal/${id}`, kinosaal);
}
/* DELETE /api/kinosaal/{id} */
deleteKinosaal(id: number): Observable<void> {
return this.http.delete<void>(`${this.baseUrl}kinosaal/${id}`);
}
/* Vorstellung APIs */
/* GET /api/vorstellung */
getPerformaces(): Observable<Vorstellung[]> {
return this.http.get<Vorstellung[]>(`${this.baseUrl}vorstellung`);
}
/* GET /api/vorstellung/{id} */
getPerformaceById(id: number): Observable<Vorstellung> {
return this.http.get<Vorstellung>(`${this.baseUrl}vorstellung/${id}`);
}
/* POST /api/vorstellung/filter */
getPerformacesByFilter(filter: string[]): Observable<Vorstellung[]> {
return this.http.post<Vorstellung[]>(`${this.baseUrl}vorstellung/filter`, filter);
}
/* POST /api/vorstellung */
addPerformace(vorstellung: Omit<Vorstellung, 'id'>): Observable<Vorstellung> {
return this.http.post<Vorstellung>(`${this.baseUrl}vorstellung`, vorstellung);
}
/* PUT /api/vorstellung/{id} */
updatePerformace(id: number, vorstellung: Partial<Vorstellung>): Observable<Vorstellung> {
return this.http.put<Vorstellung>(`${this.baseUrl}vorstellung/${id}`, vorstellung);
}
/* DELETE /api/vorstellung/{id} */
deletePerformace(id: number): Observable<void> {
return this.http.delete<void>(`${this.baseUrl}vorstellung/${id}`);
}
/* Film APIs */
/* GET /api/film */
getMovies(): Observable<Film[]> {
return this.http.get<Film[]>(`${this.baseUrl}film`);
}
/* POST /api/vorstellung/filter */
getMoviesByFilter(filter: string[]): Observable<Film[]> {
return this.http.post<Film[]>(`${this.baseUrl}film/filter`, filter);
}
/* Show-Seats APIs */
/* GET /api/show-seats/{show} */
getSeatsByShowId(show: number): Observable<{seats:Sitzplatz[], reserved:Sitzplatz[], booked:Sitzplatz[]}> {
return this.http.get<{seats:Sitzplatz[], reserved:Sitzplatz[], booked:Sitzplatz[]}>(`${this.baseUrl}show-seats/${show}`);
}
/* Movie Importer APIs */
/* GET /api/importer/search */
searchMovie(query: string): Observable<OmdbSearch> {
return this.http.get<OmdbSearch>(`${this.baseUrl}importer/search`, {
params: { title: query }
});
}
/* POST /api/importer/import */
importMovie(imdbId: string): Observable<Film> {
return this.http.post<Film>(`${this.baseUrl}importer/import?id=${imdbId}`, {})
}
}