mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-11 09:09:34 +00:00
refactor: remove frozen implementation
This commit is contained in:
committed by
Carlos Valente
parent
55d349877b
commit
29e682ee06
@@ -19,7 +19,6 @@ import {
|
|||||||
deleteEvent,
|
deleteEvent,
|
||||||
editEvent,
|
editEvent,
|
||||||
reorderEvent,
|
reorderEvent,
|
||||||
setFrozenState,
|
|
||||||
swapEvents,
|
swapEvents,
|
||||||
} from '../../services/rundown-service/RundownService.js';
|
} from '../../services/rundown-service/RundownService.js';
|
||||||
import {
|
import {
|
||||||
@@ -127,17 +126,6 @@ export async function rundownBatchPut(req: Request, res: Response<MessageRespons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function rundownFrozenPost(req: Request, res: Response<MessageResponse | ErrorResponse>) {
|
|
||||||
try {
|
|
||||||
const { frozen } = req.body;
|
|
||||||
setFrozenState(frozen);
|
|
||||||
res.status(200).send({ message: 'Rundown frozen state updated.' });
|
|
||||||
} catch (error) {
|
|
||||||
const message = getErrorMessage(error);
|
|
||||||
res.status(400).send({ message });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function rundownReorder(req: Request, res: Response<OntimeRundownEntry | ErrorResponse>) {
|
export async function rundownReorder(req: Request, res: Response<OntimeRundownEntry | ErrorResponse>) {
|
||||||
if (failEmptyObjects(req.body, res)) {
|
if (failEmptyObjects(req.body, res)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { eventStore } from '../../stores/EventStore.js';
|
|
||||||
|
|
||||||
export const preventIfFrozen = function (req, res, next) {
|
|
||||||
if (eventStore.get('frozen')) {
|
|
||||||
res.status(403).send({ message: 'Rundown is frozen' });
|
|
||||||
} else {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
rundownApplyDelay,
|
rundownApplyDelay,
|
||||||
rundownBatchPut,
|
rundownBatchPut,
|
||||||
rundownDelete,
|
rundownDelete,
|
||||||
rundownFrozenPost,
|
|
||||||
rundownGetAll,
|
rundownGetAll,
|
||||||
rundownGetById,
|
rundownGetById,
|
||||||
rundownGetNormalised,
|
rundownGetNormalised,
|
||||||
@@ -19,14 +18,12 @@ import {
|
|||||||
paramsMustHaveEventId,
|
paramsMustHaveEventId,
|
||||||
rundownArrayOfIds,
|
rundownArrayOfIds,
|
||||||
rundownBatchPutValidator,
|
rundownBatchPutValidator,
|
||||||
rundownFrozenPostValidator,
|
|
||||||
rundownGetPaginatedQueryParams,
|
rundownGetPaginatedQueryParams,
|
||||||
rundownPostValidator,
|
rundownPostValidator,
|
||||||
rundownPutValidator,
|
rundownPutValidator,
|
||||||
rundownReorderValidator,
|
rundownReorderValidator,
|
||||||
rundownSwapValidator,
|
rundownSwapValidator,
|
||||||
} from './rundown.validation.js';
|
} from './rundown.validation.js';
|
||||||
import { preventIfFrozen } from './rundown.middleware.js';
|
|
||||||
|
|
||||||
export const router = express.Router();
|
export const router = express.Router();
|
||||||
|
|
||||||
@@ -36,14 +33,13 @@ router.get('/normalised', rundownGetNormalised);
|
|||||||
router.get('/:eventId', paramsMustHaveEventId, rundownGetById); // not used in Ontime frontend
|
router.get('/:eventId', paramsMustHaveEventId, rundownGetById); // not used in Ontime frontend
|
||||||
|
|
||||||
router.post('/', rundownPostValidator, rundownPost);
|
router.post('/', rundownPostValidator, rundownPost);
|
||||||
router.post('/frozen', rundownFrozenPostValidator, rundownFrozenPost);
|
|
||||||
|
|
||||||
router.put('/', rundownPutValidator, rundownPut);
|
router.put('/', rundownPutValidator, rundownPut);
|
||||||
router.put('/batch', rundownBatchPutValidator, rundownBatchPut);
|
router.put('/batch', rundownBatchPutValidator, rundownBatchPut);
|
||||||
|
|
||||||
router.patch('/reorder/', rundownReorderValidator, preventIfFrozen, rundownReorder);
|
router.patch('/reorder/', rundownReorderValidator, rundownReorder);
|
||||||
router.patch('/swap', rundownSwapValidator, preventIfFrozen, rundownSwap);
|
router.patch('/swap', rundownSwapValidator, rundownSwap);
|
||||||
router.patch('/applydelay/:eventId', paramsMustHaveEventId, rundownApplyDelay);
|
router.patch('/applydelay/:eventId', paramsMustHaveEventId, rundownApplyDelay);
|
||||||
|
|
||||||
router.delete('/', rundownArrayOfIds, preventIfFrozen, deletesEventById);
|
router.delete('/', rundownArrayOfIds, deletesEventById);
|
||||||
router.delete('/all', preventIfFrozen, rundownDelete);
|
router.delete('/all', rundownDelete);
|
||||||
|
|||||||
@@ -21,15 +21,6 @@ export const rundownPutValidator = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const rundownFrozenPostValidator = [
|
|
||||||
body('frozen').isBoolean().exists(),
|
|
||||||
(req: Request, res: Response, next: NextFunction) => {
|
|
||||||
const errors = validationResult(req);
|
|
||||||
if (!errors.isEmpty()) return res.status(422).json({ errors: errors.array() });
|
|
||||||
next();
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export const rundownBatchPutValidator = [
|
export const rundownBatchPutValidator = [
|
||||||
body('data').isObject().exists(),
|
body('data').isObject().exists(),
|
||||||
body('ids').isArray().exists(),
|
body('ids').isArray().exists(),
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ export const startServer = async (
|
|||||||
playback: SimplePlayback.Stop,
|
playback: SimplePlayback.Stop,
|
||||||
direction: SimpleDirection.CountDown,
|
direction: SimpleDirection.CountDown,
|
||||||
},
|
},
|
||||||
frozen: false,
|
|
||||||
ping: -1,
|
ping: -1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { runtimeService } from '../runtime-service/RuntimeService.js';
|
|||||||
|
|
||||||
import * as cache from './rundownCache.js';
|
import * as cache from './rundownCache.js';
|
||||||
import { getPlayableEvents, getTimedEvents } from './rundownUtils.js';
|
import { getPlayableEvents, getTimedEvents } from './rundownUtils.js';
|
||||||
import { eventStore } from '../../stores/EventStore.js';
|
|
||||||
|
|
||||||
type PatchWithId = (Partial<OntimeEvent> | Partial<OntimeBlock> | Partial<OntimeDelay>) & { id: string };
|
type PatchWithId = (Partial<OntimeEvent> | Partial<OntimeBlock> | Partial<OntimeDelay>) & { id: string };
|
||||||
|
|
||||||
@@ -275,7 +274,3 @@ export async function initRundown(rundown: Readonly<OntimeRundown>, customFields
|
|||||||
// notify timer of change
|
// notify timer of change
|
||||||
notifyChanges({ timer: true, external: true, reload: true });
|
notifyChanges({ timer: true, external: true, reload: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setFrozenState(state: boolean) {
|
|
||||||
eventStore.set('frozen', state);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -51,6 +51,5 @@ export const runtimeStorePlaceholder: RuntimeStore = {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
playback: SimplePlayback.Stop,
|
playback: SimplePlayback.Stop,
|
||||||
},
|
},
|
||||||
frozen: false,
|
|
||||||
ping: -1,
|
ping: -1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export type RuntimeStore = {
|
|||||||
// extra timers
|
// extra timers
|
||||||
auxtimer1: SimpleTimerState;
|
auxtimer1: SimpleTimerState;
|
||||||
|
|
||||||
// flags
|
// utils
|
||||||
frozen: boolean;
|
|
||||||
ping: number;
|
ping: number;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user