mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 00:43:54 +00:00
de9a7a87fd
* refactor(project structure): UI * refactor(project structure): extract utilities * refactor(project structure): remove unused * refactor(project structure): electron * refactor(project structure): server refactor: migrate to vitest refactor: monorepo config * refactor: extract application menu * refactor: exit process * refactor: extract tray menu * chore: electron build * Added Seconds in studio clock #282 --------- Co-authored-by: Fabian Posenau <fabian@fphome.de> --------- Co-authored-by: Fabian Posenau <fabian.p99@gmx.de> Co-authored-by: Fabian Posenau <fabian@fphome.de>
100 lines
2.3 KiB
JavaScript
100 lines
2.3 KiB
JavaScript
import { DataProvider } from '../classes/data-provider/DataProvider.js';
|
|
import { failEmptyObjects } from '../utils/routerUtils.js';
|
|
import {
|
|
addEvent,
|
|
applyDelay,
|
|
deleteAllEvents,
|
|
deleteEvent,
|
|
editEvent,
|
|
reorderEvent,
|
|
} from '../services/RundownService.js';
|
|
|
|
// Create controller for GET request to '/eventlist'
|
|
// Returns -
|
|
export const rundownGetAll = async (req, res) => {
|
|
res.json(DataProvider.getRundown());
|
|
};
|
|
|
|
// Create controller for GET request to '/eventlist/:eventId'
|
|
// Returns -
|
|
export const getEventById = async (req, res) => {
|
|
res.json(DataProvider.getEventById(req.params?.eventId));
|
|
};
|
|
|
|
// Create controller for POST request to '/eventlist/'
|
|
// Returns -
|
|
export const rundownPost = async (req, res) => {
|
|
if (failEmptyObjects(req.body, res)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const newEvent = await addEvent(req.body);
|
|
res.status(201).send(newEvent);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|
|
|
|
// Create controller for PUT request to '/eventlist/'
|
|
// Returns -
|
|
export const rundownPut = async (req, res) => {
|
|
if (failEmptyObjects(req.body, res)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const event = await editEvent(req.body);
|
|
res.status(200).send(event);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|
|
|
|
export const rundownReorder = async (req, res) => {
|
|
if (failEmptyObjects(req.body, res)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const { eventId, from, to } = req.body;
|
|
const event = await reorderEvent(eventId, from, to);
|
|
res.status(200).send(event);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|
|
|
|
// Create controller for PATCH request to '/eventlist/applydelay/:eventId'
|
|
// Returns -
|
|
export const rundownApplyDelay = async (req, res) => {
|
|
try {
|
|
await applyDelay(req.params.eventId);
|
|
res.sendStatus(200);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|
|
|
|
// Create controller for DELETE request to '/eventlist/:eventId'
|
|
// Returns -
|
|
export const deleteEventById = async (req, res) => {
|
|
try {
|
|
await deleteEvent(req.params.eventId);
|
|
res.sendStatus(204);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|
|
|
|
// Create controller for DELETE request to '/eventlist/'
|
|
// Returns -
|
|
export const rundownDelete = async (req, res) => {
|
|
try {
|
|
await deleteAllEvents();
|
|
res.sendStatus(204);
|
|
} catch (error) {
|
|
res.status(400).send(error);
|
|
}
|
|
};
|