mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-31 20:09:11 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { SecondarySource } from 'ontime-types';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import Button from '../../../common/components/buttons/Button';
|
|
import * as Editor from '../../../common/components/editor-utils/EditorUtils';
|
|
import Select from '../../../common/components/select/Select';
|
|
import { setMessage, useTimerViewControl } from '../../../common/hooks/useSocket';
|
|
import TimerPreview from './TimerPreview';
|
|
|
|
import style from './TimerViewControl.module.scss';
|
|
|
|
export default function TimerControlsPreview() {
|
|
const { blackout, blink } = useTimerViewControl();
|
|
|
|
return (
|
|
<div className={style.previewContainer}>
|
|
<TimerPreview />
|
|
<div className={style.options}>
|
|
<SecondarySourceControl />
|
|
|
|
<Editor.Separator orientation='horizontal' />
|
|
|
|
<Button
|
|
variant={blink ? 'primary' : 'subtle'}
|
|
fluid
|
|
onClick={() => setMessage.timerBlink(!blink)}
|
|
data-testid='toggle timer blink'
|
|
>
|
|
Blink
|
|
</Button>
|
|
<Button
|
|
variant={blackout ? 'primary' : 'subtle'}
|
|
fluid
|
|
onClick={() => setMessage.timerBlackout(!blackout)}
|
|
data-testid='toggle timer blackout'
|
|
>
|
|
Blackout screen
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function SecondarySourceControl() {
|
|
const { secondarySource } = useTimerViewControl();
|
|
const [value, setValue] = useState<SecondarySource>('aux1');
|
|
|
|
// sync secondary source with external changes
|
|
useEffect(() => {
|
|
if (secondarySource !== null) {
|
|
setValue(secondarySource);
|
|
}
|
|
}, [secondarySource]);
|
|
|
|
const toggleSecondary = () => {
|
|
if (secondarySource === value) {
|
|
setMessage.timerSecondarySource(null);
|
|
} else {
|
|
setMessage.timerSecondarySource(value);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Select
|
|
value={value}
|
|
options={[
|
|
{ value: 'aux1', label: 'Aux 1' },
|
|
{ value: 'aux2', label: 'Aux 2' },
|
|
{ value: 'aux3', label: 'Aux 3' },
|
|
{ value: 'secondary', label: 'Secondary message' },
|
|
]}
|
|
onValueChange={(value: SecondarySource | null) => {
|
|
if (value === null) return;
|
|
// we can only update the remote if it is enabled
|
|
if (secondarySource !== null) {
|
|
setMessage.timerSecondarySource(value);
|
|
}
|
|
setValue(value);
|
|
}}
|
|
/>
|
|
<Button
|
|
variant={secondarySource !== null ? 'primary' : 'subtle'}
|
|
fluid
|
|
onClick={toggleSecondary}
|
|
data-testid='toggle secondary'
|
|
>
|
|
Show secondary
|
|
</Button>
|
|
</>
|
|
);
|
|
}
|