mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
Merge pull request #15 from cpvalente/chore/modal-manager
modal manager
This commit is contained in:
@@ -2,8 +2,8 @@ import { lazy, useEffect } from 'react';
|
|||||||
import { Box } from '@chakra-ui/layout';
|
import { Box } from '@chakra-ui/layout';
|
||||||
import { useDisclosure } from '@chakra-ui/hooks';
|
import { useDisclosure } from '@chakra-ui/hooks';
|
||||||
import styles from './Editor.module.css';
|
import styles from './Editor.module.css';
|
||||||
import SettingsModal from 'features/modals/SettingsModal';
|
|
||||||
import MenuBar from 'features/menu/MenuBar';
|
import MenuBar from 'features/menu/MenuBar';
|
||||||
|
import ModalManager from 'features/modals/ModalManager';
|
||||||
|
|
||||||
const EventListWrapper = lazy(() =>
|
const EventListWrapper = lazy(() =>
|
||||||
import('features/editors/list/EventListWrapper')
|
import('features/editors/list/EventListWrapper')
|
||||||
@@ -22,7 +22,7 @@ export default function Editor() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsModal isOpen={isOpen} onClose={onClose} />
|
<ModalManager isOpen={isOpen} onClose={onClose} />
|
||||||
|
|
||||||
<div className={styles.mainContainer}>
|
<div className={styles.mainContainer}>
|
||||||
<Box id='settings' className={styles.settings}>
|
<Box id='settings' className={styles.settings}>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { downloadEvents, uploadEvents } from 'app/api/ontimeApi';
|
|||||||
import { EVENTS_TABLE } from 'app/api/apiConstants';
|
import { EVENTS_TABLE } from 'app/api/apiConstants';
|
||||||
import DownloadIconBtn from './buttons/DownloadIconBtn';
|
import DownloadIconBtn from './buttons/DownloadIconBtn';
|
||||||
import SettingsIconBtn from './buttons/SettingsIconBtn';
|
import SettingsIconBtn from './buttons/SettingsIconBtn';
|
||||||
import InfoIconBtn from './buttons/InfoIconBtn';
|
|
||||||
import MaxIconBtn from './buttons/MaxIconBtn';
|
import MaxIconBtn from './buttons/MaxIconBtn';
|
||||||
import MinIconBtn from './buttons/MinIconBtn';
|
import MinIconBtn from './buttons/MinIconBtn';
|
||||||
import QuitIconBtn from './buttons/QuitIconBtn';
|
import QuitIconBtn from './buttons/QuitIconBtn';
|
||||||
@@ -84,13 +83,12 @@ export default function MenuBar(props) {
|
|||||||
size='lg'
|
size='lg'
|
||||||
clickhandler={() => handleIPC('help')}
|
clickhandler={() => handleIPC('help')}
|
||||||
/>
|
/>
|
||||||
<SettingsIconBtn style={{ fontSize: '1.5em' }} size='lg' disabled />
|
<SettingsIconBtn
|
||||||
<div className={style.gap} />
|
|
||||||
<InfoIconBtn
|
|
||||||
style={{ fontSize: '1.5em' }}
|
style={{ fontSize: '1.5em' }}
|
||||||
size='lg'
|
size='lg'
|
||||||
clickhandler={onOpen}
|
clickhandler={onOpen}
|
||||||
/>
|
/>
|
||||||
|
<div className={style.gap} />
|
||||||
<input
|
<input
|
||||||
type='file'
|
type='file'
|
||||||
style={{ display: 'none' }}
|
style={{ display: 'none' }}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { FiSettings } from 'react-icons/fi';
|
|||||||
export default function SettingsIconBtn(props) {
|
export default function SettingsIconBtn(props) {
|
||||||
const { clickhandler, ...rest } = props;
|
const { clickhandler, ...rest } = props;
|
||||||
return (
|
return (
|
||||||
<Tooltip label='Application Settings'>
|
<Tooltip label='Settings'>
|
||||||
<IconButton
|
<IconButton
|
||||||
size={props.size || 'xs'}
|
size={props.size || 'xs'}
|
||||||
icon={<FiSettings />}
|
icon={<FiSettings />}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import {
|
||||||
|
Modal,
|
||||||
|
ModalCloseButton,
|
||||||
|
ModalContent,
|
||||||
|
ModalHeader,
|
||||||
|
ModalOverlay,
|
||||||
|
} from '@chakra-ui/modal';
|
||||||
|
import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/tabs';
|
||||||
|
import SettingsModal from './SettingsModal';
|
||||||
|
|
||||||
|
export default function ModalManager(props) {
|
||||||
|
const { isOpen, onClose } = props;
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
isOpen={isOpen}
|
||||||
|
onClose={onClose}
|
||||||
|
closeOnOverlayClick={false}
|
||||||
|
motionPreset={'slideInBottom'}
|
||||||
|
>
|
||||||
|
<ModalOverlay />
|
||||||
|
<ModalContent>
|
||||||
|
<ModalHeader>Ontime Settings</ModalHeader>
|
||||||
|
<ModalCloseButton />
|
||||||
|
|
||||||
|
<Tabs size='sm' isLazy>
|
||||||
|
<TabList>
|
||||||
|
<Tab>Event Settings</Tab>
|
||||||
|
<Tab>Application Settings</Tab>
|
||||||
|
<Tab>URL Aliases</Tab>
|
||||||
|
</TabList>
|
||||||
|
<TabPanels>
|
||||||
|
<TabPanel>
|
||||||
|
<SettingsModal onClose={onClose} />
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel>
|
||||||
|
<p>Application settings will be here!</p>
|
||||||
|
<p>Set port</p>
|
||||||
|
<p>Set end message</p>
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel>
|
||||||
|
<p>You will be able to define URL aliases here!</p>
|
||||||
|
<p>List existing aliases</p>
|
||||||
|
<p>List existing aliases</p>
|
||||||
|
<p>List existing aliases</p>
|
||||||
|
<p>Add new alias input + button</p>
|
||||||
|
</TabPanel>
|
||||||
|
</TabPanels>
|
||||||
|
</Tabs>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModalManager.propTypes = {
|
||||||
|
isOpen: PropTypes.bool.isRequired,
|
||||||
|
onClose: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
@@ -1,12 +1,4 @@
|
|||||||
import {
|
import { ModalBody } from '@chakra-ui/modal';
|
||||||
Modal,
|
|
||||||
ModalBody,
|
|
||||||
ModalCloseButton,
|
|
||||||
ModalContent,
|
|
||||||
ModalFooter,
|
|
||||||
ModalHeader,
|
|
||||||
ModalOverlay,
|
|
||||||
} from '@chakra-ui/modal';
|
|
||||||
import {
|
import {
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -19,7 +11,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useFetch } from 'app/hooks/useFetch';
|
import { useFetch } from 'app/hooks/useFetch';
|
||||||
import { EVENT_TABLE } from 'app/api/apiConstants';
|
import { EVENT_TABLE } from 'app/api/apiConstants';
|
||||||
|
|
||||||
export default function SettingsModal(props) {
|
export default function SettingsModal() {
|
||||||
const { data, status, isError } = useFetch(EVENT_TABLE, fetchEvent);
|
const { data, status, isError } = useFetch(EVENT_TABLE, fetchEvent);
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
title: '',
|
title: '',
|
||||||
@@ -28,7 +20,6 @@ export default function SettingsModal(props) {
|
|||||||
backstageInfo: '',
|
backstageInfo: '',
|
||||||
});
|
});
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const { isOpen, onClose } = props;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
@@ -45,128 +36,112 @@ export default function SettingsModal(props) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
|
|
||||||
await postEvent(formData).then(setSubmitting(false)).then(onClose);
|
await postEvent(formData).then(setSubmitting(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<>
|
||||||
isOpen={isOpen}
|
<form onSubmit={submitHandler}>
|
||||||
onClose={onClose}
|
<ModalBody>
|
||||||
closeOnOverlayClick={false}
|
{status === 'success' && (
|
||||||
motionPreset={'slideInBottom'}
|
<>
|
||||||
>
|
<FormControl id='title'>
|
||||||
<ModalOverlay />
|
<FormLabel
|
||||||
<ModalContent>
|
style={{ fontWeight: 400, paddingTop: '1em' }}
|
||||||
<form onSubmit={submitHandler}>
|
htmlFor='title'
|
||||||
<ModalHeader>Event Main Info</ModalHeader>
|
>
|
||||||
<ModalCloseButton />
|
Event Title
|
||||||
<ModalBody>
|
</FormLabel>
|
||||||
{status === 'success' && (
|
<Input
|
||||||
<>
|
size='sm'
|
||||||
<FormControl id='title'>
|
name='title'
|
||||||
<FormLabel
|
placeholder='Event Title'
|
||||||
style={{ fontWeight: 400, paddingTop: '1em' }}
|
autoComplete='off'
|
||||||
htmlFor='title'
|
value={formData.title}
|
||||||
>
|
onChange={(event) =>
|
||||||
Event Title
|
setFormData({ ...formData, title: event.target.value })
|
||||||
</FormLabel>
|
}
|
||||||
<Input
|
isDisabled={submitting}
|
||||||
size='sm'
|
/>
|
||||||
name='title'
|
</FormControl>
|
||||||
placeholder='Event Title'
|
|
||||||
autoComplete='off'
|
|
||||||
value={formData.title}
|
|
||||||
onChange={(event) =>
|
|
||||||
setFormData({ ...formData, title: event.target.value })
|
|
||||||
}
|
|
||||||
isDisabled={submitting}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormControl id='url'>
|
<FormControl id='url'>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
style={{ fontWeight: 400, paddingTop: '1em' }}
|
style={{ fontWeight: 400, paddingTop: '1em' }}
|
||||||
htmlFor='url'
|
htmlFor='url'
|
||||||
>
|
>
|
||||||
Event URL
|
Event URL
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Input
|
<Input
|
||||||
size='sm'
|
size='sm'
|
||||||
name='url'
|
name='url'
|
||||||
placeholder='www.onsite.no'
|
placeholder='www.onsite.no'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
value={formData.url}
|
value={formData.url}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setFormData({ ...formData, url: event.target.value })
|
setFormData({ ...formData, url: event.target.value })
|
||||||
}
|
}
|
||||||
isDisabled={submitting}
|
isDisabled={submitting}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl id='pubInfo'>
|
<FormControl id='pubInfo'>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
style={{ fontWeight: 400, paddingTop: '1em' }}
|
style={{ fontWeight: 400, paddingTop: '1em' }}
|
||||||
htmlFor='pubInfo'
|
htmlFor='pubInfo'
|
||||||
>
|
>
|
||||||
Public Info
|
Public Info
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Textarea
|
<Textarea
|
||||||
size='sm'
|
size='sm'
|
||||||
name='pubInfo'
|
name='pubInfo'
|
||||||
placeholder='Information to be shown on public screens'
|
placeholder='Information to be shown on public screens'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
value={formData.publicInfo}
|
value={formData.publicInfo}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
publicInfo: event.target.value,
|
publicInfo: event.target.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
isDisabled={submitting}
|
isDisabled={submitting}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl id='backstageInfo'>
|
<FormControl id='backstageInfo'>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
style={{ fontWeight: 400, paddingTop: '1em' }}
|
style={{ fontWeight: 400, paddingTop: '1em' }}
|
||||||
htmlFor='backstageInfo'
|
htmlFor='backstageInfo'
|
||||||
>
|
>
|
||||||
Backstage Info
|
Backstage Info
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Textarea
|
<Textarea
|
||||||
size='sm'
|
size='sm'
|
||||||
name='backstageInfo'
|
name='backstageInfo'
|
||||||
placeholder='Information to be shown on backstage screens'
|
placeholder='Information to be shown on backstage screens'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
value={formData.backstageInfo}
|
value={formData.backstageInfo}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
backstageInfo: event.target.value,
|
backstageInfo: event.target.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
isDisabled={submitting}
|
isDisabled={submitting}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</ModalBody>
|
<Button
|
||||||
|
colorScheme='blue'
|
||||||
<ModalFooter>
|
mr={3}
|
||||||
<Button
|
isLoading={submitting}
|
||||||
colorScheme='blue'
|
type='submit'
|
||||||
mr={3}
|
>
|
||||||
isLoading={submitting}
|
Save
|
||||||
type='submit'
|
</Button>
|
||||||
>
|
</ModalBody>
|
||||||
Save
|
</form>
|
||||||
</Button>
|
</>
|
||||||
<Button variant='ghost' onClick={onClose} disabled={submitting}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</form>
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user