mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
Feat/173 (#177)
* feat/173: update dependencies * feat/173: migrate to playback requests to POST * feat/173: HTTP startById and startByIndex * feat/173: HTTP loadById and loadByIndex * feat/173: add tests * feat/173: OSC API * feat/173: Websocket API
This commit is contained in:
@@ -19,7 +19,23 @@ export const offAir = async (req, res) => {
|
||||
// Create controller for GET request to '/playback/start'
|
||||
// Starts timer object
|
||||
export const pbStart = async (req, res) => {
|
||||
global.timer.trigger('start') ? res.sendStatus(200) : res.sendStatus(400);
|
||||
const { eventId, eventIndex } = req.query;
|
||||
if (eventId) {
|
||||
global.timer.trigger('startById', eventId)
|
||||
? res.sendStatus(200)
|
||||
: res.status(400).send('Invalid event ID');
|
||||
} else if (eventIndex) {
|
||||
const index = Number(eventIndex);
|
||||
if (!isNaN(index)) {
|
||||
global.timer.trigger('startByIndex', index - 1)
|
||||
? res.sendStatus(200)
|
||||
: res.status(400).send('Invalid event index');
|
||||
} else {
|
||||
res.status(400).send('Invalid event index');
|
||||
}
|
||||
} else {
|
||||
global.timer.trigger('start') ? res.sendStatus(200) : res.sendStatus(400);
|
||||
}
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/pause'
|
||||
@@ -52,6 +68,28 @@ export const pbNext = async (req, res) => {
|
||||
global.timer.trigger('next') ? res.sendStatus(200) : res.sendStatus(400);
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/load'
|
||||
// Load requested event
|
||||
export const pbLoad = async (req, res) => {
|
||||
const { eventId, eventIndex } = req.query;
|
||||
if (eventId) {
|
||||
global.timer.trigger('loadById', eventId)
|
||||
? res.sendStatus(200)
|
||||
: res.status(400).send('Invalid event ID');
|
||||
} else if (eventIndex) {
|
||||
const index = Number(eventIndex);
|
||||
if (!isNaN(index)) {
|
||||
global.timer.trigger('loadByIndex', index - 1)
|
||||
? res.sendStatus(200)
|
||||
: res.status(400).send('Invalid event index');
|
||||
} else {
|
||||
res.status(400).send('Invalid event index');
|
||||
}
|
||||
} else {
|
||||
res.status(400).send('No event given');
|
||||
}
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/unload'
|
||||
// Unloads any events
|
||||
export const pbUnload = async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user