mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 01:13:55 +00:00
eslint
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
+10
-10
@@ -2,26 +2,26 @@ import { lazy, Suspense } from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import './App.css';
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
import SocketProvider from './app/context/socketContext';
|
||||
import withSocket from './features/viewers/ViewWrapper';
|
||||
import SocketProvider from 'app/context/socketContext';
|
||||
import withSocket from 'features/viewers/ViewWrapper';
|
||||
import { ReactQueryDevtools } from 'react-query/devtools';
|
||||
import Empty from './common/state/Empty';
|
||||
import Empty from 'common/state/Empty';
|
||||
|
||||
const Editor = lazy(() => import('./features/editors/Editor'));
|
||||
const Editor = lazy(() => import('features/editors/Editor'));
|
||||
const PresenterView = lazy(() =>
|
||||
import('./features/viewers/presenter/PresenterView')
|
||||
import('features/viewers/presenter/PresenterView')
|
||||
);
|
||||
const PresenterSimple = lazy(() =>
|
||||
import('./features/viewers/presenter/PresenterSimple')
|
||||
import('features/viewers/presenter/PresenterSimple')
|
||||
);
|
||||
const StageManager = lazy(() =>
|
||||
import('./features/viewers/backstage/StageManager')
|
||||
import('features/viewers/backstage/StageManager')
|
||||
);
|
||||
const Public = lazy(() => import('./features/viewers/foh/Public'));
|
||||
const Public = lazy(() => import('features/viewers/foh/Public'));
|
||||
const Lower = lazy(() =>
|
||||
import('./features/viewers/production/lower/LowerWrapper')
|
||||
import('features/viewers/production/lower/LowerWrapper')
|
||||
);
|
||||
const Pip = lazy(() => import('./features/viewers/production/Pip'));
|
||||
const Pip = lazy(() => import('features/viewers/production/Pip'));
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
// Seemed to cause issues
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { memo } from 'react';
|
||||
import { formatDisplay } from '../../dateConfig';
|
||||
import { formatDisplay } from 'common/dateConfig';
|
||||
import styles from './Countdown.module.css';
|
||||
|
||||
const Countdown = ({ time, small, negative, hideZeroHours }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import EditableTimer from '../../input/EditableTimer';
|
||||
import { showWarningToast } from '../../helpers/toastManager';
|
||||
import EditableTimer from 'common/input/EditableTimer';
|
||||
import { showWarningToast } from 'common/helpers/toastManager';
|
||||
|
||||
export default function EventTimes(props) {
|
||||
const { actionHandler, delay, timeStart, timeEnd } = props;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import EditableTimer from '../../input/EditableTimer';
|
||||
import { showWarningToast } from '../../helpers/toastManager';
|
||||
import { stringFromMillis } from '../../dateConfig';
|
||||
import EditableTimer from 'common/input/EditableTimer';
|
||||
import { showWarningToast } from 'common/helpers/toastManager';
|
||||
import { stringFromMillis } from 'common/dateConfig';
|
||||
|
||||
const label = {
|
||||
fontSize: '0.75em',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { clamp } from '../../../app/utils';
|
||||
import { clamp } from 'app/utils';
|
||||
import styles from './MyProgressBar.module.css';
|
||||
|
||||
export default function MyProgressBar(props) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Image } from '@chakra-ui/react';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { useState, useEffect } from 'react';
|
||||
import tinykeys from 'tinykeys';
|
||||
import navlogo from '../../../assets/images/logos/LOGO-72.png';
|
||||
import navlogo from 'assets/images/logos/LOGO-72.png';
|
||||
import style from './NavLogo.module.css';
|
||||
|
||||
export default function NavLogo() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import TodayItem from './TodayItem';
|
||||
import style from './Paginator.module.css';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useInterval } from '../../../app/hooks/useInterval';
|
||||
import { useInterval } from 'app/hooks/useInterval';
|
||||
|
||||
export default function Paginator(props) {
|
||||
const { events, selectedId } = props;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { stringFromMillis } from '../../../common/dateConfig';
|
||||
import { stringFromMillis } from 'common/dateConfig';
|
||||
import style from './Paginator.module.css';
|
||||
export default function TodayItem(props) {
|
||||
const { selected, timeStart, timeEnd, title } = props;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ReactComponent as Emptyimage } from '../../assets/images/empty.svg';
|
||||
import { ReactComponent as Emptyimage } from 'assets/images/empty.svg';
|
||||
import style from './Empty.module.css';
|
||||
|
||||
export default function Empty(props) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Editable, EditableInput, EditablePreview } from '@chakra-ui/editable';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSocket } from '../../app/context/socketContext';
|
||||
import VisibleIconBtn from '../../common/components/buttons/VisibleIconBtn';
|
||||
import { useSocket } from 'app/context/socketContext';
|
||||
import VisibleIconBtn from 'common/components/buttons/VisibleIconBtn';
|
||||
import style from './MessageControl.module.css';
|
||||
|
||||
const inputProps = {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { memo } from 'react';
|
||||
import style from './PlaybackControl.module.css';
|
||||
import StartIconBtn from '../../common/components/buttons/StartIconBtn';
|
||||
import PauseIconBtn from '../../common/components/buttons/PauseIconBtn';
|
||||
import PrevIconBtn from '../../common/components/buttons/PrevIconBtn';
|
||||
import NextIconBtn from '../../common/components/buttons/NextIconBtn';
|
||||
import RollIconBtn from '../../common/components/buttons/RollIconBtn';
|
||||
import UnloadIconBtn from '../../common/components/buttons/UnloadIconBtn';
|
||||
import ReloadIconButton from '../../common/components/buttons/ReloadIconBtn';
|
||||
import StartIconBtn from 'common/components/buttons/StartIconBtn';
|
||||
import PauseIconBtn from 'common/components/buttons/PauseIconBtn';
|
||||
import PrevIconBtn from 'common/components/buttons/PrevIconBtn';
|
||||
import NextIconBtn from 'common/components/buttons/NextIconBtn';
|
||||
import RollIconBtn from 'common/components/buttons/RollIconBtn';
|
||||
import UnloadIconBtn from 'common/components/buttons/UnloadIconBtn';
|
||||
import ReloadIconButton from 'common/components/buttons/ReloadIconBtn';
|
||||
|
||||
const areEqual = (prevProps, nextProps) => {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import style from './PlaybackControl.module.css';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSocket } from '../../app/context/socketContext';
|
||||
import { useSocket } from 'app/context/socketContext';
|
||||
import PlaybackButtons from './PlaybackButtons';
|
||||
import PlaybackTimer from './PlaybackTimer';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import style from './PlaybackControl.module.css';
|
||||
import Countdown from '../../common/components/countdown/Countdown';
|
||||
import { stringFromMillis } from '../../common/dateConfig';
|
||||
import Countdown from 'common/components/countdown/Countdown';
|
||||
import { stringFromMillis } from 'common/dateConfig';
|
||||
import { Button } from '@chakra-ui/button';
|
||||
import { memo } from 'react';
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Heading } from '@chakra-ui/layout';
|
||||
import { Box } from '@chakra-ui/layout';
|
||||
import NumberedText from '../../common/components/text/NumberedText';
|
||||
import NumberedText from 'common/components/text/NumberedText';
|
||||
import PlaybackControl from '../control/PlaybackControl';
|
||||
import MessageControl from '../control/MessageControl';
|
||||
import styles from './Editor.module.css';
|
||||
import EventListWrapper from './list/EventListWrapper';
|
||||
import { useDisclosure } from '@chakra-ui/hooks';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import SettingsIconBtn from '../../common/components/buttons/SettingsIconBtn';
|
||||
import SettingsIconBtn from 'common/components/buttons/SettingsIconBtn';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function Editor() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Draggable } from 'react-beautiful-dnd';
|
||||
import { FiMoreVertical } from 'react-icons/fi';
|
||||
import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn';
|
||||
import DeleteIconBtn from 'common/components/buttons/DeleteIconBtn';
|
||||
import ActionButtons from './ActionButtons';
|
||||
import style from './BlockBlock.module.css';
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Draggable } from 'react-beautiful-dnd';
|
||||
import { FiMoreVertical } from 'react-icons/fi';
|
||||
import { millisToMinutes } from '../../../common/dateConfig';
|
||||
import { millisToMinutes } from 'common/dateConfig';
|
||||
import ActionButtons from './ActionButtons';
|
||||
import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn';
|
||||
import ApplyIconBtn from '../../../common/components/buttons/ApplyIconBtn';
|
||||
import DelayInput from '../../../common/input/DelayInput';
|
||||
import DeleteIconBtn from 'common/components/buttons/DeleteIconBtn';
|
||||
import ApplyIconBtn from 'common/components/buttons/ApplyIconBtn';
|
||||
import DelayInput from 'common/input/DelayInput';
|
||||
import style from './DelayBlock.module.css';
|
||||
|
||||
export default function DelayBlock(props) {
|
||||
|
||||
@@ -2,13 +2,13 @@ import Icon from '@chakra-ui/icon';
|
||||
import { FiChevronDown, FiChevronUp, FiMoreVertical } from 'react-icons/fi';
|
||||
import { useState } from 'react';
|
||||
import { Draggable } from 'react-beautiful-dnd';
|
||||
import EventTimes from '../../../common/components/eventTimes/EventTimes';
|
||||
import EventTimesVertical from '../../../common/components/eventTimes/EventTimesVertical';
|
||||
import EditableText from '../../../common/input/EditableText';
|
||||
import EventTimes from 'common/components/eventTimes/EventTimes';
|
||||
import EventTimesVertical from 'common/components/eventTimes/EventTimesVertical';
|
||||
import EditableText from 'common/input/EditableText';
|
||||
import ActionButtons from './ActionButtons';
|
||||
import VisibleIconBtn from '../../../common/components/buttons/VisibleIconBtn';
|
||||
import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn';
|
||||
import { millisToMinutes } from '../../../common/dateConfig';
|
||||
import VisibleIconBtn from 'common/components/buttons/VisibleIconBtn';
|
||||
import DeleteIconBtn from 'common/components/buttons/DeleteIconBtn';
|
||||
import { millisToMinutes } from 'common/dateConfig';
|
||||
import style from './EventBlock.module.css';
|
||||
|
||||
const ExpandedBlock = (props) => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import style from './List.module.css';
|
||||
import { Fragment, useEffect, useState } from 'react';
|
||||
import { useSocket } from '../../../app/context/socketContext';
|
||||
import { useSocket } from 'app/context/socketContext';
|
||||
import tinykeys from 'tinykeys';
|
||||
import Empty from '../../../common/state/Empty';
|
||||
import Empty from 'common/state/Empty';
|
||||
import EventListItem from './EventListItem';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
||||
@@ -45,7 +45,7 @@ export default function EventList(props) {
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, [cursor, events, eventsHandler]);
|
||||
}, [cursor, events.length, eventsHandler]);
|
||||
|
||||
// handle incoming messages
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import DelayBlock from './DelayBlock';
|
||||
import BlockBlock from './BlockBlock';
|
||||
import EventBlock from './EventBlock';
|
||||
import { showErrorToast } from '../../../common/helpers/toastManager';
|
||||
import { showErrorToast } from 'common/helpers/toastManager';
|
||||
import { memo } from 'react';
|
||||
|
||||
const areEqual = (prevProps, nextProps) => {
|
||||
|
||||
@@ -9,12 +9,12 @@ import {
|
||||
requestDelete,
|
||||
requestReorder,
|
||||
requestApplyDelay,
|
||||
} from '../../../app/api/eventsApi.js';
|
||||
} from 'app/api/eventsApi.js';
|
||||
import EventList from './EventList';
|
||||
import EventListMenu from '../../menu/EventListMenu.jsx';
|
||||
import { showErrorToast } from '../../../common/helpers/toastManager';
|
||||
import { useFetch } from '../../../app/hooks/useFetch.js';
|
||||
import Empty from '../../../common/state/Empty';
|
||||
import EventListMenu from 'features/menu/EventListMenu.jsx';
|
||||
import { showErrorToast } from 'common/helpers/toastManager';
|
||||
import { useFetch } from 'app/hooks/useFetch.js';
|
||||
import Empty from 'common/state/Empty';
|
||||
|
||||
export default function EventListWrapper() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export const sortByDate = (arr) => {
|
||||
const sorter = (a, b) => {
|
||||
return new Date(a.timeStart).getTime() - new Date(b.timeStart).getTime();
|
||||
};
|
||||
return arr.sort(sorter);
|
||||
};
|
||||
@@ -1,112 +0,0 @@
|
||||
import { Skeleton } from '@chakra-ui/skeleton';
|
||||
|
||||
import style from '../list/List.module.css';
|
||||
|
||||
export default function EventListSkeleton() {
|
||||
return (
|
||||
<div className={style.eventContainer}>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='1.2'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='1.6'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.0'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.4'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.8'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='3.2'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='3.6'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='4.0'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='4.4'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='4.0'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='3.6'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='3.2'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.8'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.4'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='2.0'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='1.6'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
<Skeleton
|
||||
height='4vh'
|
||||
speed='1.2'
|
||||
startColor='#333333'
|
||||
endColor='#202020'
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -14,9 +14,9 @@ import {
|
||||
Button,
|
||||
Textarea,
|
||||
} from '@chakra-ui/react';
|
||||
import { fetchEvent, postEvent, eventNamespace } from '../../app/api/eventApi';
|
||||
import { fetchEvent, postEvent, eventNamespace } from 'app/api/eventApi';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useFetch } from '../../app/hooks/useFetch';
|
||||
import { useFetch } from 'app/hooks/useFetch';
|
||||
|
||||
export default function SettingsModal(props) {
|
||||
const { data, status, isError } = useFetch(eventNamespace, fetchEvent);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { eventsNamespace, fetchAllEvents } from '../../app/api/eventsApi';
|
||||
import { fetchEvent, eventNamespace } from '../../app/api/eventApi';
|
||||
import { useSocket } from '../../app/context/socketContext';
|
||||
import { stringFromMillis } from '../../common/dateConfig';
|
||||
import { useFetch } from '../../app/hooks/useFetch';
|
||||
import { eventsNamespace, fetchAllEvents } from 'app/api/eventsApi';
|
||||
import { fetchEvent, eventNamespace } from 'app/api/eventApi';
|
||||
import { useSocket } from 'app/context/socketContext';
|
||||
import { stringFromMillis } from 'common/dateConfig';
|
||||
import { useFetch } from 'app/hooks/useFetch';
|
||||
|
||||
const withSocket = (Component) => {
|
||||
const WrappedComponent = (props) => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import QRCode from 'react-qr-code';
|
||||
import { formatDisplay } from '../../../common/dateConfig';
|
||||
import { formatDisplay } from 'common/dateConfig';
|
||||
import style from './StageManager.module.css';
|
||||
import Paginator from '../../../common/components/views/Paginator';
|
||||
import NavLogo from '../../../common/components/nav/NavLogo';
|
||||
import Paginator from 'common/components/views/Paginator';
|
||||
import NavLogo from 'common/components/nav/NavLogo';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import TitleSide from '../../../common/components/views/TitleSide';
|
||||
import TitleSide from 'common/components/views/TitleSide';
|
||||
|
||||
export default function StageManager(props) {
|
||||
const { publ, title, time, backstageEvents, selectedId, general } = props;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import QRCode from 'react-qr-code';
|
||||
import style from './Public.module.css';
|
||||
import Paginator from '../../../common/components/views/Paginator';
|
||||
import NavLogo from '../../../common/components/nav/NavLogo';
|
||||
import Paginator from 'common/components/views/Paginator';
|
||||
import NavLogo from 'common/components/nav/NavLogo';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import TitleSide from '../../../common/components/views/TitleSide';
|
||||
import TitleSide from 'common/components/views/TitleSide';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function Public(props) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { useEffect } from 'react';
|
||||
import Countdown from '../../../common/components/countdown/Countdown';
|
||||
import MyProgressBar from '../../../common/components/myProgressBar/MyProgressBar';
|
||||
import NavLogo from '../../../common/components/nav/NavLogo';
|
||||
import TitleCard from '../../../common/components/views/TitleCard';
|
||||
import Countdown from 'common/components/countdown/Countdown';
|
||||
import MyProgressBar from 'common/components/myProgressBar/MyProgressBar';
|
||||
import NavLogo from 'common/components/nav/NavLogo';
|
||||
import TitleCard from 'common/components/views/TitleCard';
|
||||
import style from './PresenterView.module.css';
|
||||
|
||||
export default function PresenterView(props) {
|
||||
@@ -14,7 +14,7 @@ export default function PresenterView(props) {
|
||||
document.title = 'ontime - Speaker Screen';
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
|
||||
const showOverlay = pres.text !== '' && pres.visible;
|
||||
const isPlaying = time.playstate === 'start';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import QRCode from 'react-qr-code';
|
||||
import style from './Pip.module.css';
|
||||
import Paginator from '../../../common/components/views/Paginator';
|
||||
import NavLogo from '../../../common/components/nav/NavLogo';
|
||||
import Paginator from 'common/components/views/Paginator';
|
||||
import NavLogo from 'common/components/nav/NavLogo';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { formatDisplay } from '../../../common/dateConfig';
|
||||
import { ReactComponent as Emptyimage } from '../../../assets/images/empty.svg';
|
||||
import { formatDisplay } from 'common/dateConfig';
|
||||
import { ReactComponent as Emptyimage } from 'assets/images/empty.svg';
|
||||
|
||||
export default function Pip(props) {
|
||||
const { time, backstageEvents, selectedId, general } = props;
|
||||
|
||||
+14
-14
@@ -4,23 +4,20 @@ const config = require('./config.json');
|
||||
// init database
|
||||
const low = require('lowdb');
|
||||
const FileSync = require('lowdb/adapters/FileSync');
|
||||
|
||||
const adapter = new FileSync(config.database.filename);
|
||||
const db = low(adapter);
|
||||
|
||||
// TODO: move defaults to config file
|
||||
db.defaults({
|
||||
events: [],
|
||||
event: { title: '', url: '', publicInfo: '', backstageInfo: '' },
|
||||
settings: {},
|
||||
}).write();
|
||||
|
||||
// export db
|
||||
module.exports.db = db;
|
||||
|
||||
// dependencies
|
||||
const express = require('express');
|
||||
const http = require('http');
|
||||
const cors = require('cors');
|
||||
const dataModel = require('./data/dataModel.js');
|
||||
|
||||
db.defaults(dataModel).write();
|
||||
|
||||
// export db
|
||||
module.exports.db = db;
|
||||
|
||||
// Import Routes
|
||||
const eventsRouter = require('./routes/eventsRouter.js');
|
||||
@@ -52,7 +49,7 @@ app.use('/events', eventsRouter);
|
||||
app.use('/event', eventRouter);
|
||||
|
||||
// implement general router
|
||||
app.get('/', function (req, res) {
|
||||
app.get('/', (req, res) => {
|
||||
res.send('ontime API');
|
||||
});
|
||||
|
||||
@@ -70,11 +67,14 @@ const eventlist = db.get('events').value();
|
||||
|
||||
// init timer
|
||||
global.timer = new EventTimer(server, config);
|
||||
timer.setupWithEventList(eventlist);
|
||||
global.timer.setupWithEventList(eventlist);
|
||||
|
||||
// Start server
|
||||
server.listen(port, () => console.log(`HTTP Server is listening on port ${port}`));
|
||||
server.listen(port, () =>
|
||||
console.log(`HTTP Server is listening on port ${port}`)
|
||||
);
|
||||
|
||||
// Start OSC server
|
||||
const initiateOSC = require('./controllers/OscController.js').initiateOSC;
|
||||
const { initiateOSC } = require('./controllers/OscController.js');
|
||||
|
||||
initiateOSC(config.osc);
|
||||
|
||||
@@ -51,12 +51,20 @@ const initiateOSC = (config) => {
|
||||
break;
|
||||
case 'delay':
|
||||
console.log('calling delay with', args);
|
||||
let t = parseInt(args);
|
||||
if (!isNaN(t)) global.timer.increment(t * 1000 * 60);
|
||||
try {
|
||||
let t = parseInt(args);
|
||||
if (!isNaN(t)) global.timer.increment(t * 1000 * 60);
|
||||
} catch (error) {
|
||||
console.log('error parsing: ', error);
|
||||
}
|
||||
break;
|
||||
case 'goto':
|
||||
console.log('calling goto with', args);
|
||||
global.timer.loadEventById(args.toLowerCase());
|
||||
try {
|
||||
global.timer.loadEventById(args.toLowerCase());
|
||||
} catch (error) {
|
||||
console.log('error calling goto: ', error);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// get database
|
||||
const db = require('../app.js').db;
|
||||
const { db } = require('../app.js');
|
||||
|
||||
const table = 'event';
|
||||
|
||||
function getSettings() {
|
||||
@@ -18,7 +19,7 @@ exports.getAll = async (req, res) => {
|
||||
// Returns ACK message
|
||||
exports.post = async (req, res) => {
|
||||
if (!req.body) {
|
||||
res.status(400).send(`No object found in request`);
|
||||
res.status(400).send('No object found in request');
|
||||
return;
|
||||
}
|
||||
// TODO: validate data
|
||||
@@ -45,7 +46,7 @@ exports.titleGet = async (req, res) => {
|
||||
// Returns ACK message
|
||||
exports.titlePost = async (req, res) => {
|
||||
if (!req.body) {
|
||||
res.status(400).send(`No object found in request`);
|
||||
res.status(400).send('No object found in request');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ exports.titlePost = async (req, res) => {
|
||||
// Create controller for GET request to '/event/url'
|
||||
// Returns ACK message
|
||||
exports.urlGet = async (req, res) => {
|
||||
let event = getEventOptions();
|
||||
const event = getSettings();
|
||||
|
||||
if (event) res.json(event.url);
|
||||
else res.sendStatus(400);
|
||||
@@ -71,7 +72,7 @@ exports.urlGet = async (req, res) => {
|
||||
// Returns ACK message
|
||||
exports.urlPost = async (req, res) => {
|
||||
if (!req.body) {
|
||||
res.status(400).send(`No object found in request`);
|
||||
res.status(400).send('No object found in request');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ exports.publicInfoGet = async (req, res) => {
|
||||
// Returns ACK message
|
||||
exports.publicInfoPost = async (req, res) => {
|
||||
if (!req.body) {
|
||||
res.status(400).send(`No object found in request`);
|
||||
res.status(400).send('No object found in request');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ exports.backstageInfoGet = async (req, res) => {
|
||||
// Returns ACK message
|
||||
exports.backstageInfoPost = async (req, res) => {
|
||||
if (!req.body) {
|
||||
res.status(400).send(`No object found in request`);
|
||||
res.status(400).send('No object found in request');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const dbModel = {
|
||||
events: [],
|
||||
event: {
|
||||
title: '',
|
||||
url: '',
|
||||
publicInfo: '',
|
||||
backStageInfo: '',
|
||||
},
|
||||
settings: {
|
||||
app: 'ontime',
|
||||
version: 1,
|
||||
osc_enabled: false,
|
||||
osc_port: 8888,
|
||||
lock: false,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { dbModel };
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"events": [],
|
||||
"event": {
|
||||
"title": "",
|
||||
"url": "",
|
||||
"publicInfo": "",
|
||||
"backStageInfo": ""
|
||||
},
|
||||
"settings": {
|
||||
"app": "ontime",
|
||||
"version": 1,
|
||||
"osc_enabled": false,
|
||||
"osc_port": 8008,
|
||||
"lock": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user