Web changes: Split shared helpers, bootstrap logic, route groups, and upload-sync behavior out of web.js. Kept web.js focused on wiring and server startup. Fixed screen playlist reassignment so changing a screen’s playlist now triggers a refresh. Fixed single-slide playlist refresh behavior so updates do not get stuck behind the current slide. Player changes: Split websocket/runtime handling into runtime.js. Split playlist assembly and revision hashing into playlist.js. Split onboarding and player HTTP routes into dedicated modules. Split render utilities and template loading into render-helpers.js. Kept player.js mostly as startup/orchestration. Validation: Rebuilt both services with Docker Compose. Smoke-checked web and player routes after the refactor. Verified get_errors was clean on the touched modules.
39 lines
2.4 KiB
JavaScript
39 lines
2.4 KiB
JavaScript
async function fetchAdminData(pool) {
|
|
const [playlists] = await pool.query('SELECT id, name, fade_between_slides, created_at, modified_at, created_by, modified_by FROM playlists ORDER BY id DESC');
|
|
const [canvasSizes] = await pool.query('SELECT id, name, width, height, created_at, modified_at, created_by, modified_by FROM canvas_sizes ORDER BY width ASC, height ASC, name ASC');
|
|
const [templates] = await pool.query(`
|
|
SELECT st.id, st.name, st.canvas_size_id, st.background_image_path, st.background_color, st.created_at, st.modified_at,
|
|
cs.name AS canvas_size_name, cs.width AS canvas_size_width, cs.height AS canvas_size_height
|
|
FROM slide_templates st
|
|
LEFT JOIN canvas_sizes cs ON cs.id = st.canvas_size_id
|
|
ORDER BY st.id DESC
|
|
`);
|
|
const [templateRegions] = await pool.query('SELECT id, template_id, region_key, region_type, label, font_family, x, y, width, height, z_index, created_at, modified_at, created_by, modified_by FROM slide_template_regions ORDER BY template_id ASC, z_index ASC, id ASC');
|
|
const [slides] = await pool.query(`
|
|
SELECT s.id, s.title, s.body, s.template_id, s.content_json, s.media_path, s.media_type, s.created_at, s.modified_at, s.created_by, s.modified_by, st.name AS template_name, cs.width AS canvas_width, cs.height AS canvas_height
|
|
FROM slides s
|
|
LEFT JOIN slide_templates st ON st.id = s.template_id
|
|
LEFT JOIN canvas_sizes cs ON cs.id = st.canvas_size_id
|
|
ORDER BY s.id DESC
|
|
`);
|
|
const [screens] = await pool.query(`
|
|
SELECT s.id, s.name, s.slug, s.playlist_id, s.created_at, s.modified_at, s.created_by, s.modified_by, p.name AS playlist_name
|
|
FROM screens s
|
|
LEFT JOIN playlists p ON p.id = s.playlist_id
|
|
ORDER BY s.id DESC
|
|
`);
|
|
const [playlistSlides] = await pool.query(`
|
|
SELECT ps.id, ps.playlist_id, ps.position, ps.duration_seconds, ps.schedule_mode, ps.schedule_start_datetime, ps.schedule_end_datetime, ps.schedule_start_time, ps.schedule_end_time, ps.schedule_days_json, sl.id AS slide_id, sl.title, sl.media_path, sl.media_type, cs.width AS canvas_width, cs.height AS canvas_height
|
|
FROM playlist_slides ps
|
|
JOIN slides sl ON sl.id = ps.slide_id
|
|
LEFT JOIN slide_templates st ON st.id = sl.template_id
|
|
LEFT JOIN canvas_sizes cs ON cs.id = st.canvas_size_id
|
|
ORDER BY ps.playlist_id ASC, ps.position ASC, ps.id ASC
|
|
`);
|
|
return { playlists, canvasSizes, templates, templateRegions, slides, screens, playlistSlides };
|
|
}
|
|
|
|
module.exports = {
|
|
fetchAdminData
|
|
};
|