mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
feat: implement multiple aux timers
This commit is contained in:
committed by
Carlos Valente
parent
d1c58712ae
commit
bf8ed8d017
@@ -149,10 +149,10 @@ describe('parseOutput', () => {
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'aux',
|
||||
secondarySource: 'aux1',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'aux',
|
||||
secondarySource: 'aux1',
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
|
||||
@@ -189,13 +189,17 @@ function parseOntimeAction(maybeOntimeAction: object): OntimeAction {
|
||||
|
||||
// we know we have a valid action, deal with special cases
|
||||
|
||||
if (maybeOntimeAction.action === 'aux-set') {
|
||||
if (
|
||||
maybeOntimeAction.action === 'aux1-set' ||
|
||||
maybeOntimeAction.action === 'aux2-set' ||
|
||||
maybeOntimeAction.action === 'aux3-set'
|
||||
) {
|
||||
assert.hasKeys(maybeOntimeAction, ['time']);
|
||||
assert.isString(maybeOntimeAction.time);
|
||||
|
||||
return {
|
||||
type: 'ontime',
|
||||
action: 'aux-set',
|
||||
action: maybeOntimeAction.action,
|
||||
time: parseUserTime(maybeOntimeAction.time),
|
||||
};
|
||||
}
|
||||
@@ -253,7 +257,9 @@ function indeterminateBooleanString(value: string): boolean | undefined {
|
||||
* Helper function to validate the secondary source
|
||||
*/
|
||||
function chooseSecondarySource(value: string): SecondarySource {
|
||||
if (value === 'aux') return 'aux';
|
||||
if (value === 'aux1') return 'aux1';
|
||||
if (value === 'aux2') return 'aux2';
|
||||
if (value === 'aux3') return 'aux3';
|
||||
if (value === 'secondary') return 'secondary';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,18 +8,32 @@ export function toOntimeAction(action: OntimeAction) {
|
||||
const actionType = action.action;
|
||||
switch (actionType) {
|
||||
// Aux timer actions
|
||||
case 'aux-start':
|
||||
auxTimerService.start();
|
||||
break;
|
||||
case 'aux-stop':
|
||||
auxTimerService.stop();
|
||||
break;
|
||||
case 'aux-pause':
|
||||
auxTimerService.pause();
|
||||
break;
|
||||
case 'aux-set': {
|
||||
auxTimerService.setTime(action.time);
|
||||
break;
|
||||
case 'aux1-start':
|
||||
return auxTimerService.start(1);
|
||||
case 'aux1-stop':
|
||||
return auxTimerService.stop(1);
|
||||
case 'aux1-pause':
|
||||
return auxTimerService.pause(1);
|
||||
case 'aux1-set': {
|
||||
return auxTimerService.setTime(action.time, 1);
|
||||
}
|
||||
case 'aux2-start':
|
||||
return auxTimerService.start(2);
|
||||
case 'aux2-stop':
|
||||
return auxTimerService.stop(2);
|
||||
case 'aux2-pause':
|
||||
return auxTimerService.pause(2);
|
||||
case 'aux2-set': {
|
||||
return auxTimerService.setTime(action.time, 2);
|
||||
}
|
||||
case 'aux3-start':
|
||||
return auxTimerService.start(3);
|
||||
case 'aux3-stop':
|
||||
return auxTimerService.stop(3);
|
||||
case 'aux3-pause':
|
||||
return auxTimerService.pause(3);
|
||||
case 'aux3-set': {
|
||||
return auxTimerService.setTime(action.time, 3);
|
||||
}
|
||||
|
||||
// Message actions
|
||||
|
||||
Reference in New Issue
Block a user