mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
Event trigger (#1557)
* crude UI * add server functionalety * better event trigger list * fix default value * remove log * add trigger to recalculate whitelist * use DTO type * fix rebase * one callback for delete and submit * refactor * add invalid description * clean up commits * cleanup * refactor: find event triggers in `triggerAutomations` * refactor: switch to flat array for event triggers * prevent deleting a automation that is in use * refactor * refactor: extract EventEditorCustom * move trigger options to separate file * move trigger edit down a file level * cleanup * spelling * refactor: ui review proposal * change default value * fix delete filter --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
committed by
GitHub
parent
6817263123
commit
a94b10cb0f
@@ -3,10 +3,10 @@ import {
|
||||
isOntimeAction,
|
||||
isOSCOutput,
|
||||
LogOrigin,
|
||||
TimerLifeCycle,
|
||||
type AutomationFilter,
|
||||
type AutomationOutput,
|
||||
type FilterRule,
|
||||
type TimerLifeCycle,
|
||||
} from 'ontime-types';
|
||||
import { getPropertyFromPath } from 'ontime-utils';
|
||||
|
||||
@@ -23,14 +23,21 @@ import { toOntimeAction } from './clients/ontime.client.js';
|
||||
/**
|
||||
* Exposes a method for triggering actions based on a TimerLifeCycle event
|
||||
*/
|
||||
export function triggerAutomations(event: TimerLifeCycle, state: RuntimeState) {
|
||||
export function triggerAutomations(cycle: TimerLifeCycle, state: RuntimeState) {
|
||||
if (!getAutomationsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const triggers = getAutomationTriggers();
|
||||
const triggerAutomations = triggers.filter((trigger) => trigger.trigger === event);
|
||||
if (triggerAutomations.length === 0) {
|
||||
let triggers = getAutomationTriggers();
|
||||
|
||||
// get triggers from event
|
||||
if (state.eventNow?.triggers) {
|
||||
triggers = triggers.concat(state.eventNow.triggers);
|
||||
}
|
||||
|
||||
// note: there are no onStop triggers in event
|
||||
const filteredTrigger = triggers.filter((trigger) => trigger.trigger === cycle);
|
||||
if (filteredTrigger.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,7 +46,7 @@ export function triggerAutomations(event: TimerLifeCycle, state: RuntimeState) {
|
||||
return;
|
||||
}
|
||||
|
||||
triggerAutomations.forEach((trigger) => {
|
||||
filteredTrigger.forEach((trigger) => {
|
||||
const automation = automations[trigger.automationId];
|
||||
if (!automation || automation.outputs.length === 0) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user