mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
feat: automation service
This commit is contained in:
committed by
Carlos Valente
parent
a8fe4c8e68
commit
05e61e7bf8
@@ -8,6 +8,7 @@ import {
|
||||
CustomFields,
|
||||
HttpSettings,
|
||||
URLPreset,
|
||||
AutomationSettings,
|
||||
} from 'ontime-types';
|
||||
|
||||
import type { Low } from 'lowdb';
|
||||
@@ -56,6 +57,8 @@ export function getDataProvider() {
|
||||
setViewSettings,
|
||||
setOsc,
|
||||
setHttp,
|
||||
getAutomation,
|
||||
setAutomation,
|
||||
getRundown,
|
||||
mergeIntoData,
|
||||
};
|
||||
@@ -137,10 +140,21 @@ async function setOsc(newData: OSCSettings): ReadonlyPromise<OSCSettings> {
|
||||
|
||||
async function setHttp(newData: HttpSettings): ReadonlyPromise<HttpSettings> {
|
||||
db.data.http = { ...newData };
|
||||
|
||||
await persist();
|
||||
return db.data.http;
|
||||
}
|
||||
|
||||
function getAutomation(): Readonly<AutomationSettings> {
|
||||
return db.data.automation;
|
||||
}
|
||||
|
||||
async function setAutomation(newData: AutomationSettings): ReadonlyPromise<AutomationSettings> {
|
||||
db.data.automation = { ...newData };
|
||||
await persist();
|
||||
return db.data.automation;
|
||||
}
|
||||
|
||||
function getRundown(): Readonly<OntimeRundown> {
|
||||
return db.data.rundown;
|
||||
}
|
||||
@@ -150,6 +164,7 @@ async function mergeIntoData(newData: Partial<DatabaseModel>): ReadonlyPromise<D
|
||||
db.data.project = mergedData.project;
|
||||
db.data.settings = mergedData.settings;
|
||||
db.data.viewSettings = mergedData.viewSettings;
|
||||
db.data.automation = mergedData.automation;
|
||||
db.data.osc = mergedData.osc;
|
||||
db.data.http = mergedData.http;
|
||||
db.data.urlPresets = mergedData.urlPresets;
|
||||
|
||||
@@ -13,6 +13,7 @@ export function safeMerge(existing: DatabaseModel, newData: Partial<DatabaseMode
|
||||
customFields = existing.customFields,
|
||||
osc = {},
|
||||
http = {},
|
||||
automation = existing.automation,
|
||||
} = newData;
|
||||
|
||||
return {
|
||||
@@ -23,7 +24,6 @@ export function safeMerge(existing: DatabaseModel, newData: Partial<DatabaseMode
|
||||
viewSettings: { ...existing.viewSettings, ...viewSettings },
|
||||
urlPresets: urlPresets ?? existing.urlPresets,
|
||||
customFields: customFields ?? existing.customFields,
|
||||
osc: { ...existing.osc, ...osc },
|
||||
http: { ...existing.http, ...http },
|
||||
automation: { ...existing.automation, ...automation },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ describe('safeMerge', () => {
|
||||
enabledOut: false,
|
||||
subscriptions: [],
|
||||
},
|
||||
automation: {
|
||||
enabledAutomations: false,
|
||||
enabledOscIn: false,
|
||||
oscPortIn: 8000,
|
||||
automations: [],
|
||||
blueprints: {},
|
||||
},
|
||||
} as DatabaseModel;
|
||||
|
||||
it('returns existing data if new data is not provided', () => {
|
||||
|
||||
Reference in New Issue
Block a user