New programming screen
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Show } from '../interfaces/show';
|
||||
import { getAppConfig } from './app-config.service';
|
||||
|
||||
export interface ShowScheduleCreate {
|
||||
day_of_week: number;
|
||||
time: string;
|
||||
}
|
||||
|
||||
export interface ShowCreatePayload {
|
||||
title: string;
|
||||
description: string;
|
||||
host: string;
|
||||
genre: string;
|
||||
show_art_url: string | null;
|
||||
hero_image_url: string | null;
|
||||
display_order: number;
|
||||
schedules: ShowScheduleCreate[];
|
||||
}
|
||||
|
||||
export interface ShowUpdatePayload {
|
||||
title?: string;
|
||||
description?: string;
|
||||
host?: string;
|
||||
genre?: string;
|
||||
show_art_url?: string | null;
|
||||
hero_image_url?: string | null;
|
||||
display_order?: number;
|
||||
active?: boolean;
|
||||
schedules?: ShowScheduleCreate[];
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowService {
|
||||
private http = inject(HttpClient);
|
||||
private baseUrl = `${getAppConfig().apiBaseUrl}/api/shows`;
|
||||
|
||||
getShows(): Observable<Show[]> {
|
||||
return this.http.get<Show[]>(this.baseUrl);
|
||||
}
|
||||
|
||||
getShow(id: number): Observable<Show> {
|
||||
return this.http.get<Show>(`${this.baseUrl}/${id}`);
|
||||
}
|
||||
|
||||
createShow(payload: ShowCreatePayload): Observable<Show> {
|
||||
return this.http.post<Show>(this.baseUrl, payload);
|
||||
}
|
||||
|
||||
updateShow(id: number, payload: ShowUpdatePayload): Observable<Show> {
|
||||
return this.http.put<Show>(`${this.baseUrl}/${id}`, payload);
|
||||
}
|
||||
|
||||
deleteShow(id: number): Observable<void> {
|
||||
return this.http.delete<void>(`${this.baseUrl}/${id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user