Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e65a43b13c |
@@ -1,5 +1,6 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
uploads/
|
uploads/
|
||||||
|
docker-compose.dev.yml
|
||||||
.env
|
.env
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|||||||
+13
-8
@@ -396,27 +396,32 @@ async function start() {
|
|||||||
if (!command) {
|
if (!command) {
|
||||||
return res.status(400).json({ error: 'Command is required' });
|
return res.status(400).json({ error: 'Command is required' });
|
||||||
}
|
}
|
||||||
if (['refresh', 'reload', 'pause', 'blackout', 'previous', 'next', 'left', 'right'].indexOf(command) === -1) {
|
if (['refresh', 'reload', 'redirect', 'pause', 'blackout', 'previous', 'next', 'left', 'right'].indexOf(command) === -1) {
|
||||||
return res.status(400).json({ error: 'Unsupported command' });
|
return res.status(400).json({ error: 'Unsupported command' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const [screenRows] = await pool.query('SELECT id, name, slug FROM screens WHERE slug = ?', [req.params.slug]);
|
const isRedirectCommand = command === 'redirect';
|
||||||
|
let screenRows = [];
|
||||||
|
if (!isRedirectCommand) {
|
||||||
|
[screenRows] = await pool.query('SELECT id, name, slug FROM screens WHERE slug = ?', [req.params.slug]);
|
||||||
if (!screenRows.length) {
|
if (!screenRows.length) {
|
||||||
return res.status(404).json({ error: 'Screen not found' });
|
return res.status(404).json({ error: 'Screen not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandPayload = command === 'blackout' && blackoutValue !== undefined
|
|
||||||
? {
|
|
||||||
command: command,
|
|
||||||
blackout: blackoutValue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const commandPayload = req.body && typeof req.body === 'object' && !Array.isArray(req.body)
|
||||||
|
? Object.assign({}, req.body, { command: command })
|
||||||
: command;
|
: command;
|
||||||
|
if (command === 'blackout' && blackoutValue !== undefined && commandPayload && typeof commandPayload === 'object') {
|
||||||
|
commandPayload.blackout = blackoutValue;
|
||||||
|
}
|
||||||
|
|
||||||
const sent = connectionId
|
const sent = connectionId
|
||||||
? sendCommandToConnection(req.params.slug, connectionId, commandPayload)
|
? sendCommandToConnection(req.params.slug, connectionId, commandPayload)
|
||||||
: broadcastCommand(req.params.slug, commandPayload);
|
: broadcastCommand(req.params.slug, commandPayload);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
screen: screenRows[0],
|
screen: screenRows[0] || null,
|
||||||
screenSlug: req.params.slug,
|
screenSlug: req.params.slug,
|
||||||
command: command,
|
command: command,
|
||||||
connectionId: connectionId || null,
|
connectionId: connectionId || null,
|
||||||
|
|||||||
@@ -488,6 +488,11 @@
|
|||||||
case 'refresh':
|
case 'refresh':
|
||||||
refresh();
|
refresh();
|
||||||
return;
|
return;
|
||||||
|
case 'redirect':
|
||||||
|
if (payload.url) {
|
||||||
|
window.location.replace(String(payload.url));
|
||||||
|
}
|
||||||
|
return;
|
||||||
case 'pause':
|
case 'pause':
|
||||||
setPaused(!isPaused);
|
setPaused(!isPaused);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1481,7 +1481,14 @@ async function start() {
|
|||||||
const slugInput = String(req.body.slug || '').trim();
|
const slugInput = String(req.body.slug || '').trim();
|
||||||
const playlistId = req.body.playlist_id ? Number(req.body.playlist_id) : null;
|
const playlistId = req.body.playlist_id ? Number(req.body.playlist_id) : null;
|
||||||
const slug = await common.uniqueScreenSlug(pool, common.slugify(slugInput || name), screen.id);
|
const slug = await common.uniqueScreenSlug(pool, common.slugify(slugInput || name), screen.id);
|
||||||
|
const previousSlug = String(screen.slug || '').trim();
|
||||||
await pool.query('UPDATE screens SET name = ?, slug = ?, playlist_id = ?, modified_by = ? WHERE id = ?', [name, slug, playlistId, getAuditUserId(req), screen.id]);
|
await pool.query('UPDATE screens SET name = ?, slug = ?, playlist_id = ?, modified_by = ? WHERE id = ?', [name, slug, playlistId, getAuditUserId(req), screen.id]);
|
||||||
|
if (previousSlug && previousSlug !== slug) {
|
||||||
|
await forwardPlayerCommand(previousSlug, {
|
||||||
|
command: 'redirect',
|
||||||
|
url: `${PLAYER_PUBLIC_BASE_URL}/screen/${encodeURIComponent(slug)}`
|
||||||
|
});
|
||||||
|
}
|
||||||
res.redirect('/admin/screens?edit=' + screen.id + '&message=' + encodeURIComponent('Screen updated.'));
|
res.redirect('/admin/screens?edit=' + screen.id + '&message=' + encodeURIComponent('Screen updated.'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user