109 lines
No EOL
2.9 KiB
TypeScript
109 lines
No EOL
2.9 KiB
TypeScript
// Interfaccia Podcast
|
|
import {cleanOptions} from "@/helpers/AxiosHelper.ts";
|
|
import axios, {type AxiosResponse} from "axios";
|
|
import {VCheckbox, VTextField} from "vuetify/components";
|
|
import type {PodcastEpisode} from "@models/podcast/podcastEpisode.ts";
|
|
|
|
export interface Podcast {
|
|
id: number;
|
|
url: string;
|
|
title: string;
|
|
creator?: string;
|
|
description: string;
|
|
language: string;
|
|
copyright?: string;
|
|
link: string;
|
|
itunes_author?: string;
|
|
itunes_keywords?: string;
|
|
itunes_summary?: string;
|
|
itunes_subtitle?: string;
|
|
itunes_category?: string;
|
|
itunes_explicit?: string;
|
|
owner: number; // ID dell'owner
|
|
episodes?: PodcastEpisode[];
|
|
}
|
|
|
|
// Costante basePodcast
|
|
export const basePodcast = (): Podcast => {
|
|
return {
|
|
id: 0,
|
|
url: '',
|
|
title: '',
|
|
description: '',
|
|
language: '',
|
|
link: '',
|
|
itunes_explicit: 'false',
|
|
owner: 0,
|
|
}
|
|
};
|
|
|
|
export const PodcastTableHeader = [
|
|
{title: 'Nome', value: 'title'},
|
|
{title: 'Creato da', value: 'owner.login'},
|
|
{title: 'Data di importazione', value: 'imported.auto_ingest_timestamp'},
|
|
{title: 'Azioni', value: 'actions'}
|
|
];
|
|
|
|
export const getPodcast = async (options: {
|
|
id?: number | null;
|
|
page?: Number | null;
|
|
per_page?: Number | null;
|
|
all?: string | null;
|
|
}): Promise<Podcast[]> => {
|
|
const filteredParams = cleanOptions(options);
|
|
return await axios.get(`/podcast`, {params: filteredParams})
|
|
.then((response: AxiosResponse) => {
|
|
return response.data
|
|
}).catch((error: Error) => {
|
|
console.log("Error: " + error);
|
|
})
|
|
}
|
|
|
|
export const deletePodcast = async (podcastIds: Number[]) => {
|
|
return axios.delete(`podcast`, {
|
|
data: {
|
|
_method: 'DELETE',
|
|
'podcastIds': podcastIds
|
|
}
|
|
})
|
|
}
|
|
|
|
export function podcast(item) {
|
|
const visibleFields = {
|
|
title: {
|
|
title: 'Nome del podcast',
|
|
required: true,
|
|
disabled: false
|
|
},
|
|
url: {
|
|
title: 'URL del podcast',
|
|
required: true,
|
|
disabled: true
|
|
},
|
|
auto_ingest: {
|
|
title: 'Scarica l\'ultimo episodio in automatico',
|
|
required: false,
|
|
disabled: false
|
|
}
|
|
}
|
|
|
|
return () => {
|
|
const fields = {}
|
|
Object.keys(visibleFields).forEach((key) => {
|
|
fields[key] = {
|
|
label: visibleFields[key].title,
|
|
value: item !== null ? item[key] : '',
|
|
required: visibleFields[key].required,
|
|
disabled: (visibleFields[key].disabled !== undefined) ? visibleFields[key].disabled : false,
|
|
component: VTextField
|
|
}
|
|
// console.log(fields)
|
|
switch (key) {
|
|
case 'auto_ingest':
|
|
fields[key].component = VCheckbox
|
|
break
|
|
}
|
|
})
|
|
return fields
|
|
}
|
|
} |