mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
Merge remote-tracking branch 'origin/refactor-project-data' into excel-import-preview
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// REST stuff
|
// REST stuff
|
||||||
export const EVENT_DATA = ['eventdata'];
|
export const PROJECT_DATA = ['project'];
|
||||||
export const ALIASES = ['aliases'];
|
export const ALIASES = ['aliases'];
|
||||||
export const USERFIELDS = ['userFields'];
|
export const USERFIELDS = ['userFields'];
|
||||||
export const RUNDOWN_TABLE_KEY = 'rundown';
|
export const RUNDOWN_TABLE_KEY = 'rundown';
|
||||||
@@ -19,7 +19,7 @@ export const serverPort = isProduction ? location.port : STATIC_PORT;
|
|||||||
export const serverURL = `${location.protocol}//${location.hostname}:${serverPort}`;
|
export const serverURL = `${location.protocol}//${location.hostname}:${serverPort}`;
|
||||||
export const websocketUrl = `${socketProtocol}://${location.hostname}:${serverPort}/ws`;
|
export const websocketUrl = `${socketProtocol}://${location.hostname}:${serverPort}/ws`;
|
||||||
|
|
||||||
export const eventURL = `${serverURL}/eventdata`;
|
export const projectDataURL = `${serverURL}/project`;
|
||||||
export const rundownURL = `${serverURL}/events`;
|
export const rundownURL = `${serverURL}/events`;
|
||||||
export const ontimeURL = `${serverURL}/ontime`;
|
export const ontimeURL = `${serverURL}/ontime`;
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
import { EventData } from 'ontime-types';
|
|
||||||
|
|
||||||
import { eventURL } from './apiConstants';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description HTTP request to fetch event data
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
export async function fetchEventData(): Promise<EventData> {
|
|
||||||
const res = await axios.get(eventURL);
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description HTTP request to mutate event data
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
export async function postEventData(data: EventData) {
|
|
||||||
return axios.post(eventURL, data);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Alias, EventData, OSCSettings, OscSubscription, Settings, UserFields, ViewSettings } from 'ontime-types';
|
import { Alias, OSCSettings, OscSubscription, ProjectData, Settings, UserFields, ViewSettings } from 'ontime-types';
|
||||||
|
|
||||||
import { apiRepoLatest } from '../../externals';
|
import { apiRepoLatest } from '../../externals';
|
||||||
import { InfoType } from '../models/Info';
|
import { InfoType } from '../models/Info';
|
||||||
@@ -196,6 +196,6 @@ export async function getLatestVersion(): Promise<HasUpdate> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postNew(initialData: Partial<EventData>) {
|
export async function postNew(initialData: Partial<ProjectData>) {
|
||||||
return axios.post(`${ontimeURL}/new`, initialData);
|
return axios.post(`${ontimeURL}/new`, initialData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
|
import { projectDataURL } from './apiConstants';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description HTTP request to fetch project data
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
export async function getProjectData(): Promise<ProjectData> {
|
||||||
|
const res = await axios.get(projectDataURL);
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description HTTP request to mutate project data
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
export async function postProjectData(data: ProjectData) {
|
||||||
|
return axios.post(projectDataURL, data);
|
||||||
|
}
|
||||||
+7
-7
@@ -1,15 +1,15 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
||||||
import { EVENT_DATA } from '../api/apiConstants';
|
import { PROJECT_DATA } from '../api/apiConstants';
|
||||||
import { fetchEventData } from '../api/eventDataApi';
|
import { getProjectData } from '../api/projectDataApi';
|
||||||
import { eventDataPlaceholder } from '../models/EventData';
|
import { projectDataPlaceholder } from '../models/ProjectData';
|
||||||
|
|
||||||
export default function useEventData() {
|
export default function useProjectData() {
|
||||||
const { data, status, isFetching, isError, refetch } = useQuery({
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
||||||
queryKey: EVENT_DATA,
|
queryKey: PROJECT_DATA,
|
||||||
queryFn: fetchEventData,
|
queryFn: getProjectData,
|
||||||
placeholderData: eventDataPlaceholder,
|
placeholderData: projectDataPlaceholder,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: (attempt) => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { EventData } from 'ontime-types';
|
import { ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
export const eventDataPlaceholder: EventData = {
|
export const projectDataPlaceholder: ProjectData = {
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
publicUrl: '',
|
publicUrl: '',
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useCallback, useEffect, useMemo } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
import { EventData, OntimeRundownEntry } from 'ontime-types';
|
import { OntimeRundownEntry, ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
import Empty from '../../common/components/state/Empty';
|
import Empty from '../../common/components/state/Empty';
|
||||||
import { useEventAction } from '../../common/hooks/useEventAction';
|
import { useEventAction } from '../../common/hooks/useEventAction';
|
||||||
@@ -69,7 +69,7 @@ export default function CuesheetWrapper() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const exportHandler = useCallback(
|
const exportHandler = useCallback(
|
||||||
(headerData: EventData) => {
|
(headerData: ProjectData) => {
|
||||||
if (!headerData || !rundown || !userFields) {
|
if (!headerData || !rundown || !userFields) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import { IoContract } from '@react-icons/all-files/io5/IoContract';
|
|||||||
import { IoExpand } from '@react-icons/all-files/io5/IoExpand';
|
import { IoExpand } from '@react-icons/all-files/io5/IoExpand';
|
||||||
import { IoLocate } from '@react-icons/all-files/io5/IoLocate';
|
import { IoLocate } from '@react-icons/all-files/io5/IoLocate';
|
||||||
import { IoSettingsOutline } from '@react-icons/all-files/io5/IoSettingsOutline';
|
import { IoSettingsOutline } from '@react-icons/all-files/io5/IoSettingsOutline';
|
||||||
import { EventData, Playback } from 'ontime-types';
|
import { Playback, ProjectData } from 'ontime-types';
|
||||||
import { formatDisplay } from 'ontime-utils';
|
import { formatDisplay } from 'ontime-utils';
|
||||||
|
|
||||||
import useFullscreen from '../../../common/hooks/useFullscreen';
|
import useFullscreen from '../../../common/hooks/useFullscreen';
|
||||||
import { useTimer } from '../../../common/hooks/useSocket';
|
import { useTimer } from '../../../common/hooks/useSocket';
|
||||||
import useEventData from '../../../common/hooks-query/useEventData';
|
import useProjectData from '../../../common/hooks-query/useProjectData';
|
||||||
import { formatTime } from '../../../common/utils/time';
|
import { formatTime } from '../../../common/utils/time';
|
||||||
import { tooltipDelayFast } from '../../../ontimeConfig';
|
import { tooltipDelayFast } from '../../../ontimeConfig';
|
||||||
import { useCuesheetSettings } from '../store/CuesheetSettings';
|
import { useCuesheetSettings } from '../store/CuesheetSettings';
|
||||||
@@ -17,7 +17,7 @@ import PlaybackIcon from '../tableElements/PlaybackIcon';
|
|||||||
import style from './CuesheetTableHeader.module.scss';
|
import style from './CuesheetTableHeader.module.scss';
|
||||||
|
|
||||||
interface CuesheetTableHeaderProps {
|
interface CuesheetTableHeaderProps {
|
||||||
handleCSVExport: (headerData: EventData) => void;
|
handleCSVExport: (headerData: ProjectData) => void;
|
||||||
featureData: {
|
featureData: {
|
||||||
playback: Playback;
|
playback: Playback;
|
||||||
selectedEventIndex: number | null;
|
selectedEventIndex: number | null;
|
||||||
@@ -33,11 +33,11 @@ export default function CuesheetTableHeader({ handleCSVExport, featureData }: Cu
|
|||||||
const toggleFollow = useCuesheetSettings((state) => state.toggleFollow);
|
const toggleFollow = useCuesheetSettings((state) => state.toggleFollow);
|
||||||
const timer = useTimer();
|
const timer = useTimer();
|
||||||
const { isFullScreen, toggleFullScreen } = useFullscreen();
|
const { isFullScreen, toggleFullScreen } = useFullscreen();
|
||||||
const { data: event } = useEventData();
|
const { data: project } = useProjectData();
|
||||||
|
|
||||||
const exportCsv = () => {
|
const exportCsv = () => {
|
||||||
if (event) {
|
if (project) {
|
||||||
handleCSVExport(event);
|
handleCSVExport(project);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export default function CuesheetTableHeader({ handleCSVExport, featureData }: Cu
|
|||||||
return (
|
return (
|
||||||
<div className={style.header}>
|
<div className={style.header}>
|
||||||
<div className={style.event}>
|
<div className={style.event}>
|
||||||
<div className={style.title}>{event?.title || '-'}</div>
|
<div className={style.title}>{project?.title || '-'}</div>
|
||||||
<div className={style.eventNow}>{featureData?.titleNow || '-'}</div>
|
<div className={style.eventNow}>{featureData?.titleNow || '-'}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.playback}>
|
<div className={style.playback}>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { stringify } from 'csv-stringify/browser/esm/sync';
|
import { stringify } from 'csv-stringify/browser/esm/sync';
|
||||||
import { EventData, OntimeEntryCommonKeys, OntimeRundown, UserFields } from 'ontime-types';
|
import { OntimeEntryCommonKeys, OntimeRundown, ProjectData, UserFields } from 'ontime-types';
|
||||||
import { millisToString } from 'ontime-utils';
|
import { millisToString } from 'ontime-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,10 +38,11 @@ export const parseField = (field: keyof OntimeRundown, data: unknown): string =>
|
|||||||
* @param {object} userFields
|
* @param {object} userFields
|
||||||
* @return {(string[])[]}
|
* @return {(string[])[]}
|
||||||
*/
|
*/
|
||||||
export const makeTable = (headerData: EventData, rundown: OntimeRundown, userFields: UserFields): string[][] => {
|
export const makeTable = (headerData: ProjectData, rundown: OntimeRundown, userFields: UserFields): string[][] => {
|
||||||
const data = [
|
const data = [
|
||||||
['Ontime · Schedule Template'],
|
['Ontime · Schedule Template'],
|
||||||
['Event Name', headerData?.title || ''],
|
['Project Title', headerData?.title || ''],
|
||||||
|
['Project Description', headerData?.description || ''],
|
||||||
['Public URL', headerData?.publicUrl || ''],
|
['Public URL', headerData?.publicUrl || ''],
|
||||||
['Backstage URL', headerData?.backstageUrl || ''],
|
['Backstage URL', headerData?.backstageUrl || ''],
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import useEventData from '../../../common/hooks-query/useEventData';
|
import useProjectData from '../../../common/hooks-query/useProjectData';
|
||||||
|
|
||||||
import style from '../Info.module.scss';
|
import style from '../Info.module.scss';
|
||||||
|
|
||||||
export default function InfoHeader({ selected }: { selected: string }) {
|
export default function InfoHeader({ selected }: { selected: string }) {
|
||||||
const { data } = useEventData();
|
const { data } = useProjectData();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ import {
|
|||||||
ModalOverlay,
|
ModalOverlay,
|
||||||
Textarea,
|
Textarea,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import type { EventData } from 'ontime-types';
|
import type { ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
import { EVENT_DATA, RUNDOWN_TABLE } from '../../../common/api/apiConstants';
|
import { PROJECT_DATA, RUNDOWN_TABLE } from '../../../common/api/apiConstants';
|
||||||
import { postNew } from '../../../common/api/ontimeApi';
|
import { postNew } from '../../../common/api/ontimeApi';
|
||||||
import useEventData from '../../../common/hooks-query/useEventData';
|
import useProjectData from '../../../common/hooks-query/useProjectData';
|
||||||
import { eventDataPlaceholder } from '../../../common/models/EventData';
|
import { projectDataPlaceholder } from '../../../common/models/ProjectData';
|
||||||
import { ontimeQueryClient } from '../../../common/queryClient';
|
import { ontimeQueryClient } from '../../../common/queryClient';
|
||||||
|
|
||||||
import styles from '../Modal.module.scss';
|
import styles from '../Modal.module.scss';
|
||||||
@@ -32,7 +32,7 @@ interface QuickStartProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
||||||
const { data, status } = useEventData();
|
const { data, status } = useProjectData();
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
register,
|
register,
|
||||||
@@ -49,10 +49,10 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
if (data) reset(data);
|
if (data) reset(data);
|
||||||
}, [data, reset]);
|
}, [data, reset]);
|
||||||
|
|
||||||
const onSubmit = async (data: Partial<EventData>) => {
|
const onSubmit = async (data: Partial<ProjectData>) => {
|
||||||
try {
|
try {
|
||||||
await postNew(data);
|
await postNew(data);
|
||||||
await ontimeQueryClient.invalidateQueries(EVENT_DATA);
|
await ontimeQueryClient.invalidateQueries(PROJECT_DATA);
|
||||||
await ontimeQueryClient.invalidateQueries(RUNDOWN_TABLE);
|
await ontimeQueryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
@@ -61,7 +61,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onReset = () => reset(eventDataPlaceholder);
|
const onReset = () => reset(projectDataPlaceholder);
|
||||||
|
|
||||||
const disableButtons = status !== 'success' || isSubmitting;
|
const disableButtons = status !== 'success' || isSubmitting;
|
||||||
return (
|
return (
|
||||||
@@ -86,13 +86,13 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
<div className={styles.column}>
|
<div className={styles.column}>
|
||||||
<AlertTitle>Note</AlertTitle>
|
<AlertTitle>Note</AlertTitle>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
On submit, application options will be kept but rundown and event data will be reset
|
On submit, application options will be kept but rundown and project data will be reset
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</div>
|
</div>
|
||||||
</Alert>
|
</Alert>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Event title
|
Project title
|
||||||
<Input
|
<Input
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
@@ -104,7 +104,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Event description
|
Project description
|
||||||
<Input
|
<Input
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
@@ -116,7 +116,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Public Info
|
Public info
|
||||||
<Textarea
|
<Textarea
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
@@ -128,7 +128,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Public QR Code Url
|
Public QR code Url
|
||||||
<Input
|
<Input
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
@@ -139,7 +139,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Backstage Info
|
Backstage info
|
||||||
<Textarea
|
<Textarea
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
@@ -151,7 +151,7 @@ export default function QuickStart({ onClose, isOpen }: QuickStartProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.entryRow}>
|
<div className={styles.entryRow}>
|
||||||
<label className={styles.sectionTitle}>
|
<label className={styles.sectionTitle}>
|
||||||
Backstage QR Code Url
|
Backstage QR code Url
|
||||||
<Input
|
<Input
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
size='sm'
|
size='sm'
|
||||||
|
|||||||
+15
-15
@@ -1,11 +1,11 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { Input, Textarea } from '@chakra-ui/react';
|
import { Input, Textarea } from '@chakra-ui/react';
|
||||||
import { EventData } from 'ontime-types';
|
import { ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
import { logAxiosError } from '../../../common/api/apiUtils';
|
import { logAxiosError } from '../../../common/api/apiUtils';
|
||||||
import { postEventData } from '../../../common/api/eventDataApi';
|
import { postProjectData } from '../../../common/api/projectDataApi';
|
||||||
import useEventData from '../../../common/hooks-query/useEventData';
|
import useProjectData from '../../../common/hooks-query/useProjectData';
|
||||||
import ModalLoader from '../modal-loader/ModalLoader';
|
import ModalLoader from '../modal-loader/ModalLoader';
|
||||||
import { inputProps } from '../modalHelper';
|
import { inputProps } from '../modalHelper';
|
||||||
import ModalInput from '../ModalInput';
|
import ModalInput from '../ModalInput';
|
||||||
@@ -13,14 +13,14 @@ import OntimeModalFooter from '../OntimeModalFooter';
|
|||||||
|
|
||||||
import style from './SettingsModal.module.scss';
|
import style from './SettingsModal.module.scss';
|
||||||
|
|
||||||
export default function EventDataForm() {
|
export default function ProjectDataForm() {
|
||||||
const { data, status, isFetching, refetch } = useEventData();
|
const { data, status, isFetching, refetch } = useProjectData();
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
register,
|
register,
|
||||||
reset,
|
reset,
|
||||||
formState: { errors, isSubmitting, isDirty, isValid },
|
formState: { errors, isSubmitting, isDirty, isValid },
|
||||||
} = useForm<EventData>({
|
} = useForm<ProjectData>({
|
||||||
defaultValues: data,
|
defaultValues: data,
|
||||||
values: data,
|
values: data,
|
||||||
resetOptions: {
|
resetOptions: {
|
||||||
@@ -34,11 +34,11 @@ export default function EventDataForm() {
|
|||||||
}
|
}
|
||||||
}, [data, reset]);
|
}, [data, reset]);
|
||||||
|
|
||||||
const onSubmit = async (formData: EventData) => {
|
const onSubmit = async (formData: ProjectData) => {
|
||||||
try {
|
try {
|
||||||
await postEventData(formData);
|
await postProjectData(formData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logAxiosError('Error saving event settings', error);
|
logAxiosError('Error saving project data', error);
|
||||||
} finally {
|
} finally {
|
||||||
await refetch();
|
await refetch();
|
||||||
}
|
}
|
||||||
@@ -55,10 +55,10 @@ export default function EventDataForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)} id='event-data' className={style.sectionContainer}>
|
<form onSubmit={handleSubmit(onSubmit)} id='project-data' className={style.sectionContainer}>
|
||||||
<ModalInput
|
<ModalInput
|
||||||
field='title'
|
field='title'
|
||||||
title='Event title'
|
title='Project title'
|
||||||
description='Shown in overview screens'
|
description='Shown in overview screens'
|
||||||
error={errors.title?.message}
|
error={errors.title?.message}
|
||||||
>
|
>
|
||||||
@@ -73,7 +73,7 @@ export default function EventDataForm() {
|
|||||||
</ModalInput>
|
</ModalInput>
|
||||||
<ModalInput
|
<ModalInput
|
||||||
field='description'
|
field='description'
|
||||||
title='Event description'
|
title='Project description'
|
||||||
description='Free field, shown in editor'
|
description='Free field, shown in editor'
|
||||||
error={errors.description?.message}
|
error={errors.description?.message}
|
||||||
>
|
>
|
||||||
@@ -87,7 +87,7 @@ export default function EventDataForm() {
|
|||||||
/>
|
/>
|
||||||
</ModalInput>
|
</ModalInput>
|
||||||
<div style={{ height: '16px' }} />
|
<div style={{ height: '16px' }} />
|
||||||
<ModalInput field='publicInfo' title='Public Info' description='Information shown in public screens'>
|
<ModalInput field='publicInfo' title='Public info' description='Information shown in public screens'>
|
||||||
<Textarea
|
<Textarea
|
||||||
{...inputProps}
|
{...inputProps}
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
@@ -107,7 +107,7 @@ export default function EventDataForm() {
|
|||||||
/>
|
/>
|
||||||
</ModalInput>
|
</ModalInput>
|
||||||
<div style={{ height: '16px' }} />
|
<div style={{ height: '16px' }} />
|
||||||
<ModalInput field='backstageInfo' title='Backstage Info' description='Information shown in public screens'>
|
<ModalInput field='backstageInfo' title='Backstage info' description='Information shown in public screens'>
|
||||||
<Textarea
|
<Textarea
|
||||||
{...inputProps}
|
{...inputProps}
|
||||||
variant='ontime-filled-on-light'
|
variant='ontime-filled-on-light'
|
||||||
@@ -128,7 +128,7 @@ export default function EventDataForm() {
|
|||||||
/>
|
/>
|
||||||
</ModalInput>
|
</ModalInput>
|
||||||
<OntimeModalFooter
|
<OntimeModalFooter
|
||||||
formId='event-data'
|
formId='project-data'
|
||||||
handleRevert={onReset}
|
handleRevert={onReset}
|
||||||
isDirty={isDirty}
|
isDirty={isDirty}
|
||||||
isValid={isValid}
|
isValid={isValid}
|
||||||
@@ -6,7 +6,7 @@ import AliasesForm from './AliasesForm';
|
|||||||
import AppSettingsModal from './AppSettings';
|
import AppSettingsModal from './AppSettings';
|
||||||
import CuesheetSettingsForm from './CuesheetSettingsForm';
|
import CuesheetSettingsForm from './CuesheetSettingsForm';
|
||||||
import EditorSettings from './EditorSettings';
|
import EditorSettings from './EditorSettings';
|
||||||
import EventDataForm from './EventDataForm';
|
import ProjectDataForm from './ProjectDataForm';
|
||||||
import ViewSettingsForm from './ViewSettingsForm';
|
import ViewSettingsForm from './ViewSettingsForm';
|
||||||
|
|
||||||
interface ModalManagerProps {
|
interface ModalManagerProps {
|
||||||
@@ -22,7 +22,7 @@ export default function SettingsModal(props: ModalManagerProps) {
|
|||||||
<Tabs variant='ontime' size='sm' isLazy>
|
<Tabs variant='ontime' size='sm' isLazy>
|
||||||
<TabList>
|
<TabList>
|
||||||
<Tab>App</Tab>
|
<Tab>App</Tab>
|
||||||
<Tab>Event Data</Tab>
|
<Tab>Project Data</Tab>
|
||||||
<Tab>Editor</Tab>
|
<Tab>Editor</Tab>
|
||||||
<Tab>Cuesheet</Tab>
|
<Tab>Cuesheet</Tab>
|
||||||
<Tab>Views</Tab>
|
<Tab>Views</Tab>
|
||||||
@@ -33,7 +33,7 @@ export default function SettingsModal(props: ModalManagerProps) {
|
|||||||
<AppSettingsModal />
|
<AppSettingsModal />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<EventDataForm />
|
<ProjectDataForm />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<EditorSettings />
|
<EditorSettings />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ComponentType, useMemo } from 'react';
|
|||||||
import { TitleBlock } from 'ontime-types';
|
import { TitleBlock } from 'ontime-types';
|
||||||
import { useStore } from 'zustand';
|
import { useStore } from 'zustand';
|
||||||
|
|
||||||
import useEventData from '../../common/hooks-query/useEventData';
|
import useProjectData from '../../common/hooks-query/useProjectData';
|
||||||
import useRundown from '../../common/hooks-query/useRundown';
|
import useRundown from '../../common/hooks-query/useRundown';
|
||||||
import useViewSettings from '../../common/hooks-query/useViewSettings';
|
import useViewSettings from '../../common/hooks-query/useViewSettings';
|
||||||
import { runtime } from '../../common/stores/runtime';
|
import { runtime } from '../../common/stores/runtime';
|
||||||
@@ -18,7 +18,7 @@ const withData = <P extends object>(Component: ComponentType<P>) => {
|
|||||||
|
|
||||||
// HTTP API data
|
// HTTP API data
|
||||||
const { data: rundownData } = useRundown();
|
const { data: rundownData } = useRundown();
|
||||||
const { data: eventData } = useEventData();
|
const { data: project } = useProjectData();
|
||||||
const { data: viewSettings } = useViewSettings();
|
const { data: viewSettings } = useViewSettings();
|
||||||
|
|
||||||
const publicEvents = useMemo(() => {
|
const publicEvents = useMemo(() => {
|
||||||
@@ -104,7 +104,7 @@ const withData = <P extends object>(Component: ComponentType<P>) => {
|
|||||||
publicSelectedId={publicSelectedId}
|
publicSelectedId={publicSelectedId}
|
||||||
viewSettings={viewSettings}
|
viewSettings={viewSettings}
|
||||||
nextId={nextId}
|
nextId={nextId}
|
||||||
general={eventData}
|
general={project}
|
||||||
onAir={onAir}
|
onAir={onAir}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/* =================== HEADER + EXTRAS ===================*/
|
/* =================== HEADER + EXTRAS ===================*/
|
||||||
|
|
||||||
.event-header {
|
.project-header {
|
||||||
grid-area: header;
|
grid-area: header;
|
||||||
font-size: clamp(32px, 4.5vw, 64px);
|
font-size: clamp(32px, 4.5vw, 64px);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import QRCode from 'react-qr-code';
|
import QRCode from 'react-qr-code';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { EventData, Message, OntimeEvent, SupportedEvent, ViewSettings } from 'ontime-types';
|
import { Message, OntimeEvent, ProjectData, SupportedEvent, ViewSettings } from 'ontime-types';
|
||||||
import { formatDisplay } from 'ontime-utils';
|
import { formatDisplay } from 'ontime-utils';
|
||||||
|
|
||||||
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
||||||
@@ -34,7 +34,7 @@ interface BackstageProps {
|
|||||||
time: TimeManagerType;
|
time: TimeManagerType;
|
||||||
backstageEvents: OntimeEvent[];
|
backstageEvents: OntimeEvent[];
|
||||||
selectedId: string | null;
|
selectedId: string | null;
|
||||||
general: EventData;
|
general: ProjectData;
|
||||||
viewSettings: ViewSettings;
|
viewSettings: ViewSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export default function Backstage(props: BackstageProps) {
|
|||||||
<div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'>
|
<div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'>
|
||||||
<NavigationMenu />
|
<NavigationMenu />
|
||||||
<ViewParamsEditor paramFields={[TIME_FORMAT_OPTION]} />
|
<ViewParamsEditor paramFields={[TIME_FORMAT_OPTION]} />
|
||||||
<div className='event-header'>
|
<div className='project-header'>
|
||||||
{general.title}
|
{general.title}
|
||||||
<div className='clock-container'>
|
<div className='clock-container'>
|
||||||
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { EventData, Playback, TimerMessage, TimerType, ViewSettings } from 'ontime-types';
|
import { Playback, TimerMessage, TimerType, ViewSettings } from 'ontime-types';
|
||||||
|
|
||||||
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
||||||
import NavigationMenu from '../../../common/components/navigation-menu/NavigationMenu';
|
import NavigationMenu from '../../../common/components/navigation-menu/NavigationMenu';
|
||||||
@@ -19,7 +19,6 @@ interface MinimalTimerProps {
|
|||||||
pres: TimerMessage;
|
pres: TimerMessage;
|
||||||
time: TimeManagerType;
|
time: TimeManagerType;
|
||||||
viewSettings: ViewSettings;
|
viewSettings: ViewSettings;
|
||||||
general: EventData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MinimalTimer(props: MinimalTimerProps) {
|
export default function MinimalTimer(props: MinimalTimerProps) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
/* =================== HEADER + EXTRAS ===================*/
|
/* =================== HEADER + EXTRAS ===================*/
|
||||||
|
|
||||||
.event-header {
|
.project-header {
|
||||||
grid-area: header;
|
grid-area: header;
|
||||||
font-size: clamp(32px, 4.5vw, 64px);
|
font-size: clamp(32px, 4.5vw, 64px);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import QRCode from 'react-qr-code';
|
import QRCode from 'react-qr-code';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { EventData, Message, OntimeEvent, ViewSettings } from 'ontime-types';
|
import { Message, OntimeEvent, ProjectData, ViewSettings } from 'ontime-types';
|
||||||
|
|
||||||
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
||||||
import NavigationMenu from '../../../common/components/navigation-menu/NavigationMenu';
|
import NavigationMenu from '../../../common/components/navigation-menu/NavigationMenu';
|
||||||
@@ -32,7 +32,7 @@ interface BackstageProps {
|
|||||||
time: TimeManagerType;
|
time: TimeManagerType;
|
||||||
events: OntimeEvent[];
|
events: OntimeEvent[];
|
||||||
publicSelectedId: string | null;
|
publicSelectedId: string | null;
|
||||||
general: EventData;
|
general: ProjectData;
|
||||||
viewSettings: ViewSettings;
|
viewSettings: ViewSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export default function Public(props: BackstageProps) {
|
|||||||
<div className={`public-screen ${isMirrored ? 'mirror' : ''}`} data-testid='public-view'>
|
<div className={`public-screen ${isMirrored ? 'mirror' : ''}`} data-testid='public-view'>
|
||||||
<NavigationMenu />
|
<NavigationMenu />
|
||||||
<ViewParamsEditor paramFields={[TIME_FORMAT_OPTION]} />
|
<ViewParamsEditor paramFields={[TIME_FORMAT_OPTION]} />
|
||||||
<div className='event-header'>
|
<div className='project-header'>
|
||||||
{general.title}
|
{general.title}
|
||||||
<div className='clock-container'>
|
<div className='clock-container'>
|
||||||
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { EventData, Playback, TimerMessage, TimerType, ViewSettings } from 'ontime-types';
|
import { Playback, TimerMessage, TimerType, ViewSettings } from 'ontime-types';
|
||||||
|
|
||||||
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
import { overrideStylesURL } from '../../../common/api/apiConstants';
|
||||||
import MultiPartProgressBar from '../../../common/components/multi-part-progress-bar/MultiPartProgressBar';
|
import MultiPartProgressBar from '../../../common/components/multi-part-progress-bar/MultiPartProgressBar';
|
||||||
@@ -40,7 +40,6 @@ const titleVariants = {
|
|||||||
|
|
||||||
interface TimerProps {
|
interface TimerProps {
|
||||||
isMirrored: boolean;
|
isMirrored: boolean;
|
||||||
general: EventData;
|
|
||||||
pres: TimerMessage;
|
pres: TimerMessage;
|
||||||
title: TitleManager;
|
title: TitleManager;
|
||||||
time: TimeManagerType;
|
time: TimeManagerType;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { LogOrigin, OSCSettings } from 'ontime-types';
|
|||||||
|
|
||||||
// Import Routes
|
// Import Routes
|
||||||
import { router as rundownRouter } from './routes/rundownRouter.js';
|
import { router as rundownRouter } from './routes/rundownRouter.js';
|
||||||
import { router as eventDataRouter } from './routes/eventDataRouter.js';
|
import { router as projectRouter } from './routes/projectRouter.js';
|
||||||
import { router as ontimeRouter } from './routes/ontimeRouter.js';
|
import { router as ontimeRouter } from './routes/ontimeRouter.js';
|
||||||
import { router as playbackRouter } from './routes/playbackRouter.js';
|
import { router as playbackRouter } from './routes/playbackRouter.js';
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ app.use(express.json({ limit: '1mb' }));
|
|||||||
|
|
||||||
// Implement route endpoints
|
// Implement route endpoints
|
||||||
app.use('/events', rundownRouter);
|
app.use('/events', rundownRouter);
|
||||||
app.use('/eventdata', eventDataRouter);
|
app.use('/project', projectRouter);
|
||||||
app.use('/ontime', ontimeRouter);
|
app.use('/ontime', ontimeRouter);
|
||||||
app.use('/playback', playbackRouter);
|
app.use('/playback', playbackRouter);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Class Event Provider is a mediator for handling the local db
|
* Class Event Provider is a mediator for handling the local db
|
||||||
* and adds logic specific to ontime data
|
* and adds logic specific to ontime data
|
||||||
*/
|
*/
|
||||||
import { EventData, OntimeRundown, ViewSettings } from 'ontime-types';
|
import { ProjectData, OntimeRundown, ViewSettings } from 'ontime-types';
|
||||||
|
|
||||||
import { data, db } from '../../modules/loadDb.js';
|
import { data, db } from '../../modules/loadDb.js';
|
||||||
import { safeMerge } from './DataProvider.utils.js';
|
import { safeMerge } from './DataProvider.utils.js';
|
||||||
@@ -12,14 +12,14 @@ export class DataProvider {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setEventData(newData: Partial<EventData>) {
|
static async setProjectData(newData: Partial<ProjectData>) {
|
||||||
data.eventData = { ...data.eventData, ...newData };
|
data.project = { ...data.project, ...newData };
|
||||||
await this.persist();
|
await this.persist();
|
||||||
return data.eventData;
|
return data.project;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getEventData() {
|
static getProjectData() {
|
||||||
return data.eventData;
|
return data.project;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setRundown(newData: OntimeRundown) {
|
static async setRundown(newData: OntimeRundown) {
|
||||||
@@ -97,7 +97,7 @@ export class DataProvider {
|
|||||||
|
|
||||||
static async mergeIntoData(newData) {
|
static async mergeIntoData(newData) {
|
||||||
const mergedData = safeMerge(data, newData);
|
const mergedData = safeMerge(data, newData);
|
||||||
data.eventData = mergedData.eventData;
|
data.project = mergedData.project;
|
||||||
data.settings = mergedData.settings;
|
data.settings = mergedData.settings;
|
||||||
data.viewSettings = mergedData.viewSettings;
|
data.viewSettings = mergedData.viewSettings;
|
||||||
data.osc = mergedData.osc;
|
data.osc = mergedData.osc;
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
* @param {object} newData
|
* @param {object} newData
|
||||||
*/
|
*/
|
||||||
export function safeMerge(existing, newData) {
|
export function safeMerge(existing, newData) {
|
||||||
const { rundown, eventData, settings, viewSettings, osc, http, aliases, userFields } = newData || {};
|
const { rundown, project, settings, viewSettings, osc, http, aliases, userFields } = newData || {};
|
||||||
return {
|
return {
|
||||||
...existing,
|
...existing,
|
||||||
rundown: rundown ?? existing.rundown,
|
rundown: rundown ?? existing.rundown,
|
||||||
eventData: { ...existing.eventData, ...eventData },
|
project: { ...existing.project, ...project },
|
||||||
settings: { ...existing.settings, ...settings },
|
settings: { ...existing.settings, ...settings },
|
||||||
viewSettings: { ...existing.viewSettings, ...viewSettings },
|
viewSettings: { ...existing.viewSettings, ...viewSettings },
|
||||||
aliases: aliases ?? existing.aliases,
|
aliases: aliases ?? existing.aliases,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { safeMerge } from '../DataProvider.utils.js';
|
|||||||
describe('safeMerge', () => {
|
describe('safeMerge', () => {
|
||||||
const existing = {
|
const existing = {
|
||||||
rundown: [],
|
rundown: [],
|
||||||
eventData: {
|
project: {
|
||||||
title: 'existing title',
|
title: 'existing title',
|
||||||
publicUrl: 'existing public URL',
|
publicUrl: 'existing public URL',
|
||||||
backstageUrl: 'existing backstageUrl',
|
backstageUrl: 'existing backstageUrl',
|
||||||
@@ -62,15 +62,15 @@ describe('safeMerge', () => {
|
|||||||
expect(mergedData.rundown).toEqual(newData.rundown);
|
expect(mergedData.rundown).toEqual(newData.rundown);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('merges the event key', () => {
|
it('merges the project key', () => {
|
||||||
const newData = {
|
const newData = {
|
||||||
eventData: {
|
project: {
|
||||||
title: 'new title',
|
title: 'new title',
|
||||||
publicInfo: 'new public info',
|
publicInfo: 'new public info',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const mergedData = safeMerge(existing, newData);
|
const mergedData = safeMerge(existing, newData);
|
||||||
expect(mergedData.eventData).toEqual({
|
expect(mergedData.project).toEqual({
|
||||||
title: 'new title',
|
title: 'new title',
|
||||||
publicUrl: 'existing public URL',
|
publicUrl: 'existing public URL',
|
||||||
publicInfo: 'new public info',
|
publicInfo: 'new public info',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Alias, EventData, LogOrigin } from 'ontime-types';
|
import { Alias, LogOrigin, ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
import { RequestHandler } from 'express';
|
import { RequestHandler } from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
@@ -31,7 +31,7 @@ export const poll = async (req, res) => {
|
|||||||
// Create controller for GET request to '/ontime/db'
|
// Create controller for GET request to '/ontime/db'
|
||||||
// Returns -
|
// Returns -
|
||||||
export const dbDownload = async (req, res) => {
|
export const dbDownload = async (req, res) => {
|
||||||
const { title } = DataProvider.getEventData();
|
const { title } = DataProvider.getProjectData();
|
||||||
const fileTitle = title || 'ontime data';
|
const fileTitle = title || 'ontime data';
|
||||||
|
|
||||||
res.download(resolveDbPath, `${fileTitle}.json`, (err) => {
|
res.download(resolveDbPath, `${fileTitle}.json`, (err) => {
|
||||||
@@ -368,7 +368,7 @@ export const dbUpload = async (req, res) => {
|
|||||||
// Create controller for POST request to '/ontime/new'
|
// Create controller for POST request to '/ontime/new'
|
||||||
export const postNew: RequestHandler = async (req, res) => {
|
export const postNew: RequestHandler = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const newEventData: EventData = {
|
const newProjectData: ProjectData = {
|
||||||
title: req.body?.title ?? '',
|
title: req.body?.title ?? '',
|
||||||
description: req.body?.description ?? '',
|
description: req.body?.description ?? '',
|
||||||
publicUrl: req.body?.publicUrl ?? '',
|
publicUrl: req.body?.publicUrl ?? '',
|
||||||
@@ -376,7 +376,7 @@ export const postNew: RequestHandler = async (req, res) => {
|
|||||||
backstageUrl: req.body?.backstageUrl ?? '',
|
backstageUrl: req.body?.backstageUrl ?? '',
|
||||||
backstageInfo: req.body?.backstageInfo ?? '',
|
backstageInfo: req.body?.backstageInfo ?? '',
|
||||||
};
|
};
|
||||||
const newData = await DataProvider.setEventData(newEventData);
|
const newData = await DataProvider.setProjectData(newProjectData);
|
||||||
await deleteAllEvents();
|
await deleteAllEvents();
|
||||||
res.status(201).send(newData);
|
res.status(201).send(newData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+8
-8
@@ -1,24 +1,24 @@
|
|||||||
import { RequestHandler } from 'express';
|
import { RequestHandler } from 'express';
|
||||||
|
|
||||||
import { EventData } from 'ontime-types';
|
import { ProjectData } from 'ontime-types';
|
||||||
|
|
||||||
import { removeUndefined } from '../utils/parserUtils.js';
|
import { removeUndefined } from '../utils/parserUtils.js';
|
||||||
import { failEmptyObjects } from '../utils/routerUtils.js';
|
import { failEmptyObjects } from '../utils/routerUtils.js';
|
||||||
import { DataProvider } from '../classes/data-provider/DataProvider.js';
|
import { DataProvider } from '../classes/data-provider/DataProvider.js';
|
||||||
|
|
||||||
// Create controller for GET request to 'event'
|
// Create controller for GET request to 'project'
|
||||||
export const getEventData: RequestHandler = async (req, res) => {
|
export const getProject: RequestHandler = async (req, res) => {
|
||||||
res.json(DataProvider.getEventData());
|
res.json(DataProvider.getProjectData());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create controller for POST request to 'event'
|
// Create controller for POST request to 'project'
|
||||||
export const postEventData: RequestHandler = async (req, res) => {
|
export const postProject: RequestHandler = async (req, res) => {
|
||||||
if (failEmptyObjects(req.body, res)) {
|
if (failEmptyObjects(req.body, res)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newEvent: Partial<EventData> = removeUndefined({
|
const newEvent: Partial<ProjectData> = removeUndefined({
|
||||||
title: req.body?.title,
|
title: req.body?.title,
|
||||||
description: req.body?.description,
|
description: req.body?.description,
|
||||||
publicUrl: req.body?.publicUrl,
|
publicUrl: req.body?.publicUrl,
|
||||||
@@ -27,7 +27,7 @@ export const postEventData: RequestHandler = async (req, res) => {
|
|||||||
backstageInfo: req.body?.backstageInfo,
|
backstageInfo: req.body?.backstageInfo,
|
||||||
endMessage: req.body?.endMessage,
|
endMessage: req.body?.endMessage,
|
||||||
});
|
});
|
||||||
const newData = await DataProvider.setEventData(newEvent);
|
const newData = await DataProvider.setProjectData(newEvent);
|
||||||
res.status(200).send(newData);
|
res.status(200).send(newData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(400).send(error);
|
res.status(400).send(error);
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { body, validationResult } from 'express-validator';
|
import { body, validationResult } from 'express-validator';
|
||||||
|
|
||||||
export const eventDataSanitizer = [
|
export const projectSanitiser = [
|
||||||
body('title').optional().isString().trim(),
|
body('title').optional().isString().trim(),
|
||||||
body('description').optional().isString().trim(),
|
body('description').optional().isString().trim(),
|
||||||
body('publicUrl').optional().isString().trim(),
|
body('publicUrl').optional().isString().trim(),
|
||||||
@@ -2,7 +2,7 @@ import { DatabaseModel } from 'ontime-types';
|
|||||||
|
|
||||||
export const dbModel: DatabaseModel = {
|
export const dbModel: DatabaseModel = {
|
||||||
rundown: [],
|
rundown: [],
|
||||||
eventData: {
|
project: {
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
publicUrl: '',
|
publicUrl: '',
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import express from 'express';
|
|
||||||
import { getEventData, postEventData } from '../controllers/eventDataController.js';
|
|
||||||
import { eventDataSanitizer } from '../controllers/eventDataController.validate.js';
|
|
||||||
|
|
||||||
export const router = express.Router();
|
|
||||||
|
|
||||||
// create route between controller and 'GET /event' endpoint
|
|
||||||
router.get('/', getEventData);
|
|
||||||
|
|
||||||
// create route between controller and 'POST /event' endpoint
|
|
||||||
router.post('/', eventDataSanitizer, postEventData);
|
|
||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
validateUserFields,
|
validateUserFields,
|
||||||
viewValidator,
|
viewValidator,
|
||||||
} from '../controllers/ontimeController.validate.js';
|
} from '../controllers/ontimeController.validate.js';
|
||||||
import { eventDataSanitizer } from '../controllers/eventDataController.validate.js';
|
import { projectSanitiser } from '../controllers/projectController.validate.js';
|
||||||
|
|
||||||
export const router = express.Router();
|
export const router = express.Router();
|
||||||
|
|
||||||
@@ -81,4 +81,4 @@ router.post('/osc', validateOSC, postOSC);
|
|||||||
router.post('/osc-subscriptions', validateOscSubscription, postOscSubscriptions);
|
router.post('/osc-subscriptions', validateOscSubscription, postOscSubscriptions);
|
||||||
|
|
||||||
// create route between controller and '/ontime/new' endpoint
|
// create route between controller and '/ontime/new' endpoint
|
||||||
router.post('/new', eventDataSanitizer, postNew);
|
router.post('/new', projectSanitiser, postNew);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import { getProject, postProject } from '../controllers/projectController.js';
|
||||||
|
import { projectSanitiser } from '../controllers/projectController.validate.js';
|
||||||
|
|
||||||
|
export const router = express.Router();
|
||||||
|
|
||||||
|
// create route between controller and 'GET /project' endpoint
|
||||||
|
router.get('/', getProject);
|
||||||
|
|
||||||
|
// create route between controller and 'POST /project' endpoint
|
||||||
|
router.post('/', projectSanitiser, postProject);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { EndAction, OntimeEvent, TimerType } from 'ontime-types';
|
import { EndAction, TimerType } from 'ontime-types';
|
||||||
|
|
||||||
import { dbModel } from '../../models/dataModel.js';
|
import { dbModel } from '../../models/dataModel.js';
|
||||||
import { parseExcel, parseJson, validateEvent } from '../parser.js';
|
import { parseExcel, parseJson, validateEvent } from '../parser.js';
|
||||||
@@ -192,7 +192,7 @@ describe('test json parser with valid def', () => {
|
|||||||
user9: '',
|
user9: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
eventData: {
|
project: {
|
||||||
title: 'This is a test definition',
|
title: 'This is a test definition',
|
||||||
url: 'www.carlosvalente.com',
|
url: 'www.carlosvalente.com',
|
||||||
publicInfo: 'WiFi: demoproject \nPassword: ontimeproject',
|
publicInfo: 'WiFi: demoproject \nPassword: ontimeproject',
|
||||||
@@ -246,7 +246,7 @@ describe('test json parser with valid def', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('loaded event settings', () => {
|
it('loaded event settings', () => {
|
||||||
const eventTitle = parseResponse?.eventData?.title;
|
const eventTitle = parseResponse?.project?.title;
|
||||||
expect(eventTitle).toBe('This is a test definition');
|
expect(eventTitle).toBe('This is a test definition');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -402,10 +402,10 @@ describe('test corrupt data', () => {
|
|||||||
expect(parsedDef.rundown.length).toBe(0);
|
expect(parsedDef.rundown.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles missing event data', async () => {
|
it('handles missing project data', async () => {
|
||||||
const emptyEventData = {
|
const emptyProjectData = {
|
||||||
rundown: [{}, {}, {}, {}, {}, {}, {}, {}],
|
rundown: [{}, {}, {}, {}, {}, {}, {}, {}],
|
||||||
eventData: {},
|
project: {},
|
||||||
settings: {
|
settings: {
|
||||||
app: 'ontime',
|
app: 'ontime',
|
||||||
version: 2,
|
version: 2,
|
||||||
@@ -415,8 +415,8 @@ describe('test corrupt data', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const parsedDef = await parseJson(emptyEventData);
|
const parsedDef = await parseJson(emptyProjectData);
|
||||||
expect(parsedDef.eventData).toStrictEqual(dbModel.eventData);
|
expect(parsedDef.project).toStrictEqual(dbModel.project);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles missing settings', async () => {
|
it('handles missing settings', async () => {
|
||||||
@@ -629,7 +629,7 @@ describe('test parseExcel function', () => {
|
|||||||
[],
|
[],
|
||||||
];
|
];
|
||||||
|
|
||||||
const expectedParsedEvent = {
|
const expectedParsedProjectData = {
|
||||||
title: 'Test Event',
|
title: 'Test Event',
|
||||||
publicUrl: 'www.public.com',
|
publicUrl: 'www.public.com',
|
||||||
backstageUrl: 'www.backstage.com',
|
backstageUrl: 'www.backstage.com',
|
||||||
@@ -682,7 +682,7 @@ describe('test parseExcel function', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const parsedData = await parseExcel(testdata);
|
const parsedData = await parseExcel(testdata);
|
||||||
expect(parsedData.eventData).toStrictEqual(expectedParsedEvent);
|
expect(parsedData.project).toStrictEqual(expectedParsedProjectData);
|
||||||
expect(parsedData.rundown).toBeDefined();
|
expect(parsedData.rundown).toBeDefined();
|
||||||
expect(parsedData.rundown[0]).toMatchObject(expectedParsedRundown[0]);
|
expect(parsedData.rundown[0]).toMatchObject(expectedParsedRundown[0]);
|
||||||
expect(parsedData.rundown[1]).toMatchObject(expectedParsedRundown[1]);
|
expect(parsedData.rundown[1]).toMatchObject(expectedParsedRundown[1]);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { generateId, calculateDuration } from 'ontime-utils';
|
|||||||
import {
|
import {
|
||||||
DatabaseModel,
|
DatabaseModel,
|
||||||
EndAction,
|
EndAction,
|
||||||
EventData,
|
|
||||||
OntimeEvent,
|
OntimeEvent,
|
||||||
OntimeRundown,
|
OntimeRundown,
|
||||||
SupportedEvent,
|
SupportedEvent,
|
||||||
@@ -19,7 +18,7 @@ import { dbModel } from '../models/dataModel.js';
|
|||||||
import { deleteFile, makeString } from './parserUtils.js';
|
import { deleteFile, makeString } from './parserUtils.js';
|
||||||
import {
|
import {
|
||||||
parseAliases,
|
parseAliases,
|
||||||
parseEventData,
|
parseProject,
|
||||||
parseOsc,
|
parseOsc,
|
||||||
parseRundown,
|
parseRundown,
|
||||||
parseSettings,
|
parseSettings,
|
||||||
@@ -37,8 +36,9 @@ export const JSON_MIME = 'application/json';
|
|||||||
* @returns {object} - parsed object
|
* @returns {object} - parsed object
|
||||||
*/
|
*/
|
||||||
export const parseExcel = async (excelData) => {
|
export const parseExcel = async (excelData) => {
|
||||||
const eventData: Partial<EventData> = {
|
const projectData: Partial<ProjectData> = {
|
||||||
title: '',
|
title: '',
|
||||||
|
description: '',
|
||||||
publicUrl: '',
|
publicUrl: '',
|
||||||
backstageUrl: '',
|
backstageUrl: '',
|
||||||
};
|
};
|
||||||
@@ -71,6 +71,7 @@ export const parseExcel = async (excelData) => {
|
|||||||
.filter((e) => e.length > 0)
|
.filter((e) => e.length > 0)
|
||||||
.forEach((row) => {
|
.forEach((row) => {
|
||||||
let eventTitleNext = false;
|
let eventTitleNext = false;
|
||||||
|
let projectTitleNext = false;
|
||||||
let publicUrlNext = false;
|
let publicUrlNext = false;
|
||||||
let publicInfoNext = false;
|
let publicInfoNext = false;
|
||||||
let backstageUrlNext = false;
|
let backstageUrlNext = false;
|
||||||
@@ -81,19 +82,22 @@ export const parseExcel = async (excelData) => {
|
|||||||
row.forEach((column, j) => {
|
row.forEach((column, j) => {
|
||||||
// check flags
|
// check flags
|
||||||
if (eventTitleNext) {
|
if (eventTitleNext) {
|
||||||
eventData.title = column;
|
projectData.title = column;
|
||||||
eventTitleNext = false;
|
eventTitleNext = false;
|
||||||
|
} else if (projectTitleNext) {
|
||||||
|
projectData.description = column;
|
||||||
|
projectTitleNext = false;
|
||||||
} else if (publicUrlNext) {
|
} else if (publicUrlNext) {
|
||||||
eventData.publicUrl = column;
|
projectData.publicUrl = column;
|
||||||
publicUrlNext = false;
|
publicUrlNext = false;
|
||||||
} else if (publicInfoNext) {
|
} else if (publicInfoNext) {
|
||||||
eventData.publicInfo = column;
|
projectData.publicInfo = column;
|
||||||
publicInfoNext = false;
|
publicInfoNext = false;
|
||||||
} else if (backstageUrlNext) {
|
} else if (backstageUrlNext) {
|
||||||
eventData.backstageUrl = column;
|
projectData.backstageUrl = column;
|
||||||
backstageUrlNext = false;
|
backstageUrlNext = false;
|
||||||
} else if (backstageInfoNext) {
|
} else if (backstageInfoNext) {
|
||||||
eventData.backstageInfo = column;
|
projectData.backstageInfo = column;
|
||||||
backstageInfoNext = false;
|
backstageInfoNext = false;
|
||||||
} else if (j === timeStartIndex) {
|
} else if (j === timeStartIndex) {
|
||||||
event.timeStart = parseExcelDate(column);
|
event.timeStart = parseExcelDate(column);
|
||||||
@@ -154,9 +158,12 @@ export const parseExcel = async (excelData) => {
|
|||||||
// look for keywords
|
// look for keywords
|
||||||
// need to make sure it is a string first
|
// need to make sure it is a string first
|
||||||
switch (col) {
|
switch (col) {
|
||||||
case 'event name':
|
case 'project name':
|
||||||
eventTitleNext = true;
|
eventTitleNext = true;
|
||||||
break;
|
break;
|
||||||
|
case 'project description':
|
||||||
|
projectTitleNext = true;
|
||||||
|
break;
|
||||||
case 'public url':
|
case 'public url':
|
||||||
publicUrlNext = true;
|
publicUrlNext = true;
|
||||||
break;
|
break;
|
||||||
@@ -273,7 +280,7 @@ export const parseExcel = async (excelData) => {
|
|||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
rundown,
|
rundown,
|
||||||
eventData,
|
project: projectData,
|
||||||
settings: {
|
settings: {
|
||||||
app: 'ontime',
|
app: 'ontime',
|
||||||
version: 2,
|
version: 2,
|
||||||
@@ -299,7 +306,7 @@ export const parseJson = async (jsonData, enforce = false): Promise<DatabaseMode
|
|||||||
// parse Events
|
// parse Events
|
||||||
returnData.rundown = parseRundown(jsonData);
|
returnData.rundown = parseRundown(jsonData);
|
||||||
// parse Event
|
// parse Event
|
||||||
returnData.eventData = parseEventData(jsonData, enforce);
|
returnData.project = parseProject(jsonData, enforce);
|
||||||
// Settings handled partially
|
// Settings handled partially
|
||||||
returnData.settings = parseSettings(jsonData, enforce);
|
returnData.settings = parseSettings(jsonData, enforce);
|
||||||
// View settings handled partially
|
// View settings handled partially
|
||||||
@@ -396,7 +403,7 @@ export const fileHandler = async (file): Promise<ResponseOK | ResponseError> =>
|
|||||||
const dataFromExcel = await parseExcel(excelData.data);
|
const dataFromExcel = await parseExcel(excelData.data);
|
||||||
res.data = {};
|
res.data = {};
|
||||||
res.data.rundown = parseRundown(dataFromExcel);
|
res.data.rundown = parseRundown(dataFromExcel);
|
||||||
res.data.eventData = parseEventData(dataFromExcel, true);
|
res.data.project = parseProject(dataFromExcel, true);
|
||||||
res.data.userFields = parseUserFields(dataFromExcel);
|
res.data.userFields = parseUserFields(dataFromExcel);
|
||||||
res.message = 'success';
|
res.message = 'success';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { generateId } from 'ontime-utils';
|
|||||||
import {
|
import {
|
||||||
Alias,
|
Alias,
|
||||||
EndAction,
|
EndAction,
|
||||||
EventData,
|
|
||||||
OntimeRundown,
|
OntimeRundown,
|
||||||
OSCSettings,
|
OSCSettings,
|
||||||
OscSubscription,
|
OscSubscription,
|
||||||
OscSubscriptionOptions,
|
OscSubscriptionOptions,
|
||||||
|
ProjectData,
|
||||||
Settings,
|
Settings,
|
||||||
TimerLifeCycle,
|
TimerLifeCycle,
|
||||||
TimerType,
|
TimerType,
|
||||||
@@ -91,26 +91,26 @@ export const parseRundown = (data): OntimeRundown => {
|
|||||||
* @param {boolean} enforce - whether to create a definition if one is missing
|
* @param {boolean} enforce - whether to create a definition if one is missing
|
||||||
* @returns {object} - event object data
|
* @returns {object} - event object data
|
||||||
*/
|
*/
|
||||||
export const parseEventData = (data, enforce): EventData => {
|
export const parseProject = (data, enforce): ProjectData => {
|
||||||
let newEventData: Partial<EventData> = {};
|
let newProjectData: Partial<ProjectData> = {};
|
||||||
if ('eventData' in data) {
|
if ('project' in data) {
|
||||||
console.log('Found event data, importing...');
|
console.log('Found project data, importing...');
|
||||||
const e = data.eventData;
|
const project = data.project;
|
||||||
// filter known properties and write to db
|
// filter known properties and write to db
|
||||||
newEventData = {
|
newProjectData = {
|
||||||
...dbModel.eventData,
|
...dbModel.project,
|
||||||
title: e.title || dbModel.eventData.title,
|
title: project.title || dbModel.project.title,
|
||||||
description: e.description || dbModel.eventData.description,
|
description: project.description || dbModel.project.description,
|
||||||
publicUrl: e.publicUrl || dbModel.eventData.publicUrl,
|
publicUrl: project.publicUrl || dbModel.project.publicUrl,
|
||||||
publicInfo: e.publicInfo || dbModel.eventData.publicInfo,
|
publicInfo: project.publicInfo || dbModel.project.publicInfo,
|
||||||
backstageUrl: e.backstageUrl || dbModel.eventData.backstageUrl,
|
backstageUrl: project.backstageUrl || dbModel.project.backstageUrl,
|
||||||
backstageInfo: e.backstageInfo || dbModel.eventData.backstageInfo,
|
backstageInfo: project.backstageInfo || dbModel.project.backstageInfo,
|
||||||
};
|
};
|
||||||
} else if (enforce) {
|
} else if (enforce) {
|
||||||
newEventData = { ...dbModel.eventData };
|
newProjectData = { ...dbModel.project };
|
||||||
console.log('Created event object in db');
|
console.log('Created project object in db');
|
||||||
}
|
}
|
||||||
return newEventData as EventData;
|
return newProjectData as ProjectData;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -227,7 +227,7 @@
|
|||||||
"id": "1358"
|
"id": "1358"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"eventData": {
|
"project": {
|
||||||
"title": "All about Carlos demo event",
|
"title": "All about Carlos demo event",
|
||||||
"description": "Demo event for Ontime",
|
"description": "Demo event for Ontime",
|
||||||
"publicUrl": "www.getontime.no",
|
"publicUrl": "www.getontime.no",
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
"id": "da5b4"
|
"id": "da5b4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"eventData": {
|
"project": {
|
||||||
"title": "All about Carlos demo event",
|
"title": "All about Carlos demo event",
|
||||||
"description": "Demo event for Ontime",
|
"description": "Demo event for Ontime",
|
||||||
"publicUrl": "www.getontime.no",
|
"publicUrl": "www.getontime.no",
|
||||||
|
|||||||
+1
-1
@@ -389,7 +389,7 @@
|
|||||||
"id": "d3eb1"
|
"id": "d3eb1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"eventData": {
|
"project": {
|
||||||
"title": "Eurovision Song Contest",
|
"title": "Eurovision Song Contest",
|
||||||
"description": "Turin 2022",
|
"description": "Turin 2022",
|
||||||
"publicUrl": "www.getontime.no",
|
"publicUrl": "www.getontime.no",
|
||||||
|
|||||||
Vendored
+1
-1
@@ -93,7 +93,7 @@
|
|||||||
"id": "da5b4"
|
"id": "da5b4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"eventData": {
|
"project": {
|
||||||
"title": "All about Carlos demo event",
|
"title": "All about Carlos demo event",
|
||||||
"description": "Demo event for Ontime",
|
"description": "Demo event for Ontime",
|
||||||
"publicUrl": "www.getontime.no",
|
"publicUrl": "www.getontime.no",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Alias } from './core/Alias.type.js';
|
import { Alias } from './core/Alias.type.js';
|
||||||
import { EventData } from './core/EventData.type.js';
|
import { ProjectData } from './core/ProjectData.type.js';
|
||||||
import { OntimeRundown } from './core/Rundown.type.js';
|
import { OntimeRundown } from './core/Rundown.type.js';
|
||||||
import { OSCSettings } from './core/OscSettings.type.js';
|
import { OSCSettings } from './core/OscSettings.type.js';
|
||||||
import { Settings } from './core/Settings.type.js';
|
import { Settings } from './core/Settings.type.js';
|
||||||
@@ -8,7 +8,7 @@ import { ViewSettings } from './core/Views.type.js';
|
|||||||
|
|
||||||
export type DatabaseModel = {
|
export type DatabaseModel = {
|
||||||
rundown: OntimeRundown;
|
rundown: OntimeRundown;
|
||||||
eventData: EventData;
|
project: ProjectData;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
viewSettings: ViewSettings;
|
viewSettings: ViewSettings;
|
||||||
aliases: Alias[];
|
aliases: Alias[];
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export type EventData = {
|
export type ProjectData = {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
publicUrl: string;
|
publicUrl: string;
|
||||||
@@ -13,8 +13,8 @@ export {
|
|||||||
export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';
|
export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';
|
||||||
export { TimerType } from './definitions/TimerType.type.js';
|
export { TimerType } from './definitions/TimerType.type.js';
|
||||||
|
|
||||||
// ---> Event Data
|
// ---> Project Data
|
||||||
export type { EventData } from './definitions/core/EventData.type.js';
|
export type { ProjectData } from './definitions/core/ProjectData.type.js';
|
||||||
|
|
||||||
// ---> Settings
|
// ---> Settings
|
||||||
export type { Settings } from './definitions/core/Settings.type.js';
|
export type { Settings } from './definitions/core/Settings.type.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user