mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
update downloadCSV and downloadRundown to accept a file name and add two new options to ProjectListItem
This commit is contained in:
@@ -143,15 +143,19 @@ export async function postOscSubscriptions(data: OscSubscription) {
|
|||||||
/**
|
/**
|
||||||
* @description HTTP request to download db in CSV format
|
* @description HTTP request to download db in CSV format
|
||||||
*/
|
*/
|
||||||
export const downloadCSV = () => {
|
export const downloadCSV = (fileName?: string) => {
|
||||||
return fileDownload(ontimeURL, { name: 'rundown', type: 'csv' }, { type: 'text/csv;charset=utf-8;' });
|
return fileDownload(ontimeURL, { name: fileName ?? 'rundown', type: 'csv' }, { type: 'text/csv;charset=utf-8;' });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description HTTP request to download db in JSON format
|
* @description HTTP request to download db in JSON format
|
||||||
*/
|
*/
|
||||||
export const downloadRundown = () => {
|
export const downloadRundown = (fileName?: string) => {
|
||||||
return fileDownload(ontimeURL, { name: 'rundown', type: 'json' }, { type: 'application/json;charset=utf-8;' });
|
return fileDownload(
|
||||||
|
ontimeURL,
|
||||||
|
{ name: fileName ?? 'rundown', type: 'json' },
|
||||||
|
{ type: 'application/json;charset=utf-8;' },
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: should this be extracted to shared code?
|
// TODO: should this be extracted to shared code?
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ import { IconButton, Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/rea
|
|||||||
import { IoEllipsisHorizontal } from '@react-icons/all-files/io5/IoEllipsisHorizontal';
|
import { IoEllipsisHorizontal } from '@react-icons/all-files/io5/IoEllipsisHorizontal';
|
||||||
|
|
||||||
import { invalidateAllCaches, maybeAxiosError } from '../../../../common/api/apiUtils';
|
import { invalidateAllCaches, maybeAxiosError } from '../../../../common/api/apiUtils';
|
||||||
import { deleteProject, duplicateProject, loadProject, renameProject } from '../../../../common/api/ontimeApi';
|
import {
|
||||||
|
deleteProject,
|
||||||
|
downloadCSV,
|
||||||
|
downloadRundown,
|
||||||
|
duplicateProject,
|
||||||
|
loadProject,
|
||||||
|
renameProject,
|
||||||
|
} from '../../../../common/api/ontimeApi';
|
||||||
|
|
||||||
import ProjectForm, { ProjectFormValues } from './ProjectForm';
|
import ProjectForm, { ProjectFormValues } from './ProjectForm';
|
||||||
|
|
||||||
@@ -139,6 +146,14 @@ function ActionMenu({
|
|||||||
await onRefetch();
|
await onRefetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDownload = async () => {
|
||||||
|
await downloadRundown(filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleExportCSV = async () => {
|
||||||
|
await downloadCSV(filename);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu variant='ontime-on-dark' size='sm'>
|
<Menu variant='ontime-on-dark' size='sm'>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
@@ -154,6 +169,8 @@ function ActionMenu({
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem onClick={handleRename}>Rename</MenuItem>
|
<MenuItem onClick={handleRename}>Rename</MenuItem>
|
||||||
<MenuItem onClick={handleDuplicate}>Duplicate</MenuItem>
|
<MenuItem onClick={handleDuplicate}>Duplicate</MenuItem>
|
||||||
|
<MenuItem onClick={handleDownload}>Download</MenuItem>
|
||||||
|
{current && <MenuItem onClick={handleExportCSV}>Export CSV Rundown</MenuItem>}
|
||||||
<MenuItem isDisabled={current} onClick={handleDelete}>
|
<MenuItem isDisabled={current} onClick={handleDelete}>
|
||||||
Delete
|
Delete
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user