sintonia_webapp/resources/js/composables/content/models/show/show.ts

82 lines
2.2 KiB
TypeScript

import type {ShowInstance} from "@models/show/showInstance.ts";
import type {ShowDays} from "@models/show/showDays";
import type {ShowDJs} from "@models/show/showDJs.ts";
import axios, {type AxiosResponse} from "axios";
import {cleanOptions} from "@/helpers/AxiosHelper.ts";
export interface Show {
id?: number;
name: string;
url: string;
genre: string;
description: string;
color?: string;
backgroundColor: string;
liveStreamUsingAirtimeAuth?: boolean;
liveStreamUsingCustomAuth?: boolean;
liveStreamUser?: string;
liveStreamPass?: string;
imagePath?: string | File;
hasAutoplaylist: boolean;
autoplaylistId?: number;
autoplaylistRepeat: boolean;
// Relationships
block?: any;
showDays?: ShowDays;
showDjs?: ShowDJs[];
showInstances?: ShowInstance[];
playlist?: any;
}
export const baseShow = (): Show => {
return {
id: 0,
name: 'Esempio',
url: '',
genre: '',
description: '',
backgroundColor: '#21C043',
liveStreamUsingAirtimeAuth: false,
liveStreamUser: '',
liveStreamPass: '',
imagePath: '',
hasAutoplaylist: false,
autoplaylistId: null,
autoplaylistRepeat: false,
showDjs: null,
showDays: null,
}
}
export const showTableHeader = [
{title: 'Nome', value: 'name'},
{title: 'dj', value: 'dj'},
{title: 'Durata', value: 'length'},
{title: 'Schedulata', value: 'scheduled'},
{title: 'Azioni', value: 'actions'}
]
export const getShows = async (options: {
id?: number | null;
scheduled?: number | null;
withDjs?: boolean | null;
isScheduled?: boolean | null;
page?: Number | null;
per_page?: Number | null;
all?: string | null;
}): Promise<Show[]> => {
const filteredParams = cleanOptions(options);
return await axios.get(`/show`, {params: filteredParams})
.then((response: AxiosResponse) => {
return response.data
}).catch((error: Error) => {
console.log("Error: " + error);
})
}
export const deleteShow = async (showIds: Number[]) => {
return axios.delete(`show`, {data: {'showIds': showIds}})
}