mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 06:29:07 +00:00
fix: osc new project (#1032)
This commit is contained in:
committed by
GitHub
parent
3895b37572
commit
ec55236eb2
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
||||||
import { Button, IconButton, Input, Select, Switch } from '@chakra-ui/react';
|
import { Button, IconButton, Input, Select, Switch } from '@chakra-ui/react';
|
||||||
import { IoAdd } from '@react-icons/all-files/io5/IoAdd';
|
import { IoAdd } from '@react-icons/all-files/io5/IoAdd';
|
||||||
@@ -40,6 +41,13 @@ export default function OscIntegrations() {
|
|||||||
control,
|
control,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// update form if we get new data from server
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
reset(data);
|
||||||
|
}
|
||||||
|
}, [data, reset]);
|
||||||
|
|
||||||
const onSubmit = async (values: OSCSettings) => {
|
const onSubmit = async (values: OSCSettings) => {
|
||||||
if (values.portIn === values.portOut) {
|
if (values.portIn === values.portOut) {
|
||||||
setError('portIn', { message: 'OSC IN and OUT Ports cant be the same' });
|
setError('portIn', { message: 'OSC IN and OUT Ports cant be the same' });
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import * as projectService from '../../services/project-service/ProjectService.j
|
|||||||
import { ensureJsonExtension } from '../../utils/fileManagement.js';
|
import { ensureJsonExtension } from '../../utils/fileManagement.js';
|
||||||
import { generateUniqueFileName } from '../../utils/generateUniqueFilename.js';
|
import { generateUniqueFileName } from '../../utils/generateUniqueFilename.js';
|
||||||
import { appStateService } from '../../services/app-state-service/AppStateService.js';
|
import { appStateService } from '../../services/app-state-service/AppStateService.js';
|
||||||
|
import { oscIntegration } from '../../services/integration-service/OscIntegration.js';
|
||||||
|
import { httpIntegration } from '../../services/integration-service/HttpIntegration.js';
|
||||||
|
import { DataProvider } from '../../classes/data-provider/DataProvider.js';
|
||||||
|
|
||||||
export async function patchPartialProjectFile(req: Request, res: Response<DatabaseModel | ErrorResponse>) {
|
export async function patchPartialProjectFile(req: Request, res: Response<DatabaseModel | ErrorResponse>) {
|
||||||
// all fields are optional in validation
|
// all fields are optional in validation
|
||||||
@@ -32,6 +35,7 @@ export async function patchPartialProjectFile(req: Request, res: Response<Databa
|
|||||||
const patchDb: DatabaseModel = { rundown, project, settings, viewSettings, urlPresets, customFields, osc, http };
|
const patchDb: DatabaseModel = { rundown, project, settings, viewSettings, urlPresets, customFields, osc, http };
|
||||||
|
|
||||||
const newData = await projectService.applyDataModel(patchDb);
|
const newData = await projectService.applyDataModel(patchDb);
|
||||||
|
|
||||||
res.status(200).send(newData);
|
res.status(200).send(newData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = getErrorMessage(error);
|
const message = getErrorMessage(error);
|
||||||
@@ -125,6 +129,12 @@ export async function postProjectFile(req: Request, res: Response<MessageRespons
|
|||||||
await projectService.handleUploadedFile(path, filename);
|
await projectService.handleUploadedFile(path, filename);
|
||||||
await projectService.applyProjectFile(filename, options);
|
await projectService.applyProjectFile(filename, options);
|
||||||
|
|
||||||
|
const oscSettings = await DataProvider.getOsc();
|
||||||
|
const httpSettings = await DataProvider.getHttp();
|
||||||
|
|
||||||
|
oscIntegration.init(oscSettings);
|
||||||
|
httpIntegration.init(httpSettings);
|
||||||
|
|
||||||
res.status(201).send({
|
res.status(201).send({
|
||||||
message: `Loaded project ${filename}`,
|
message: `Loaded project ${filename}`,
|
||||||
});
|
});
|
||||||
@@ -159,6 +169,12 @@ export async function loadProject(req: Request, res: Response<MessageResponse |
|
|||||||
|
|
||||||
await projectService.applyProjectFile(name);
|
await projectService.applyProjectFile(name);
|
||||||
|
|
||||||
|
const oscSettings = await DataProvider.getOsc();
|
||||||
|
const httpSettings = await DataProvider.getHttp();
|
||||||
|
|
||||||
|
oscIntegration.init(oscSettings);
|
||||||
|
httpIntegration.init(httpSettings);
|
||||||
|
|
||||||
res.status(201).send({
|
res.status(201).send({
|
||||||
message: `Loaded project ${name}`,
|
message: `Loaded project ${name}`,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user