import { useForm } from 'react-hook-form'; import { editAutomationSettings } from '../../../../common/api/automation'; import { maybeAxiosError } from '../../../../common/api/utils'; import Button from '../../../../common/components/buttons/Button'; import Info from '../../../../common/components/info/Info'; import Input from '../../../../common/components/input/input/Input'; import ExternalLink from '../../../../common/components/link/external-link/ExternalLink'; import Switch from '../../../../common/components/switch/Switch'; import Tag from '../../../../common/components/tag/Tag'; import { preventEscape } from '../../../../common/utils/keyEvent'; import { isOnlyNumbers } from '../../../../common/utils/regex'; import { isOntimeCloud } from '../../../../externals'; import * as Panel from '../../panel-utils/PanelUtils'; const oscApiDocsUrl = 'https://docs.getontime.no/api/protocols/osc/'; interface AutomationSettingsProps { enabledAutomations: boolean; enabledOscIn: boolean; oscPortIn: number; automationState?: boolean; oscInputState?: boolean; } export default function AutomationSettingsForm({ enabledAutomations, enabledOscIn, oscPortIn, automationState, oscInputState, }: AutomationSettingsProps) { const { handleSubmit, reset, register, setError, watch, setValue, formState: { errors, isSubmitting, isDirty, isValid }, } = useForm({ mode: 'onChange', defaultValues: { enabledAutomations, enabledOscIn, oscPortIn }, resetOptions: { keepDirtyValues: false, }, }); const onSubmit = async (formData: AutomationSettingsProps) => { try { await editAutomationSettings(formData); reset(formData); } catch (error) { const message = maybeAxiosError(error); setError('root', { message }); } }; const onReset = () => { reset({ enabledAutomations, enabledOscIn, oscPortIn }); }; const canSubmit = !isSubmitting && isDirty && isValid; const automationsEnabled = watch('enabledAutomations'); const oscInputEnabled = watch('enabledOscIn'); return ( Automation settings {errors?.root && {errors.root.message}}

Control Ontime and share its data with external systems in your workflow.

- Automations allow Ontime to send its data on lifecycle triggers.

- OSC Input tells Ontime to listen to messages on the specific port.


See the docs
preventEscape(event, onReset)} > Automation Enable automations {automationState === false && OFF} } description={ automationState === false ? 'Automations are OFF. Triggers stay configured, but Ontime will not send messages.' : 'Allow Ontime to send messages on lifecycle triggers' } descriptionTone={automationState === false ? 'warning' : 'default'} error={errors.enabledAutomations?.message} /> setValue('enabledAutomations', value, { shouldDirty: true, shouldValidate: true }) } /> OSC Input {isOntimeCloud && For security reasons OSC integrations are not available in the cloud service.} OSC input {oscInputState === false && OFF} } description={ oscInputState === false ? 'OSC input is OFF. Ontime will not listen for incoming OSC control messages.' : 'Allow control of Ontime through OSC' } descriptionTone={oscInputState === false ? 'warning' : 'default'} error={errors.enabledOscIn?.message} /> setValue('enabledOscIn', value, { shouldDirty: true, shouldValidate: true }) } />
); }