Fix ontime aux actions (#1684)

* switch to base ui

* ensure all action types is part of the valitation

* update test

* atempt to do it in the base-ui way

* fix fixing

* allow undefide visible on set timer message

* fix set time not showing

* correct time data for aux set automation

---------

Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
Alex Christoffer Rasmussen
2025-07-09 13:14:23 +02:00
committed by GitHub
parent 8d68a4554d
commit 4d359445a7
12 changed files with 141 additions and 89 deletions
@@ -8,7 +8,6 @@ import {
SecondarySource,
timerLifecycleValues,
} from 'ontime-types';
import { parseUserTime } from 'ontime-utils';
import { body, oneOf, param } from 'express-validator';
@@ -200,20 +199,24 @@ function parseOntimeAction(maybeOntimeAction: object): OntimeAction {
return {
type: 'ontime',
action: maybeOntimeAction.action,
time: parseUserTime(maybeOntimeAction.time),
time: maybeOntimeAction.time, //TODO:(automation set aux) not sure what way around to have the string and where to have the ms value
};
}
if (maybeOntimeAction.action === 'message-set') {
assert.hasKeys(maybeOntimeAction, ['text', 'visible']);
assert.hasKeys(maybeOntimeAction, ['text']);
assert.isString(maybeOntimeAction.text);
assert.isString(maybeOntimeAction.visible);
let visible: boolean | undefined = undefined;
if ('visible' in maybeOntimeAction) {
assert.isBoolean(maybeOntimeAction.visible);
visible = maybeOntimeAction.visible;
}
return {
type: 'ontime',
action: 'message-set',
text: indeterminateText(maybeOntimeAction.text),
visible: indeterminateBooleanString(maybeOntimeAction.visible),
visible,
};
}
@@ -243,16 +246,6 @@ function indeterminateText(value: string): string | undefined {
return value === '' ? undefined : value;
}
/**
* Helper function to parse boolean values in transit
* "true" -> true
* "false" -> false
* "" | "null" -> undefined
*/
function indeterminateBooleanString(value: string): boolean | undefined {
return value === '' ? undefined : value === 'true';
}
/**
* Helper function to validate the secondary source
*/