import { Controller, useForm } from 'react-hook-form'; import { Button, Input, Switch } from '@chakra-ui/react'; import { editAutomationSettings } from '../../../../common/api/automation'; import { maybeAxiosError } from '../../../../common/api/utils'; import Info from '../../../../common/components/info/Info'; import ExternalLink from '../../../../common/components/link/external-link/ExternalLink'; 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; } export default function AutomationSettingsForm(props: AutomationSettingsProps) { const { enabledAutomations, enabledOscIn, oscPortIn } = props; const { control, handleSubmit, reset, register, setError, formState: { errors, isSubmitting, isDirty, isValid }, } = useForm({ mode: 'onChange', defaultValues: { enabledAutomations, enabledOscIn, oscPortIn }, values: { enabledAutomations, enabledOscIn, oscPortIn }, resetOptions: { keepDirtyValues: true, }, }); const onSubmit = async (formData: AutomationSettingsProps) => { try { await editAutomationSettings(formData); } catch (error) { const message = maybeAxiosError(error); setError('root', { message }); } }; const onReset = () => { reset({ enabledAutomations, enabledOscIn, oscPortIn }); }; const canSubmit = !isSubmitting && isDirty && isValid; 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 ( )} /> OSC Input {isOntimeCloud && For security reasons OSC integrations are not available in the cloud service.} ( )} />
); }