Release v2.18.0: template default content
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 2m2s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s

This commit is contained in:
lzstealth committed 2026-10-24 18:03:38 +01:00
1 parent 48e8f3eb4b
commit 24f1603b43
54 files changed
+1421 -151

No files matched your search

+27 -4
View File
@@ -67,6 +67,25 @@ function normalizeTemplateRegionLockRatio(value) {
return rawRatio.replace(/\s+/g, '');
}
function normalizeTemplateRegionDefaultContent(value) {
let content = value;
if (typeof content === 'string') {
content = parseJsonSafe(content);
}
return content && typeof content === 'object' && !Array.isArray(content) ? content : {};
}
function normalizeTemplateRegionReadOnly(value) {
return value === true || value === 1 || String(value || '').trim().toLowerCase() === 'true' || String(value || '').trim() === '1';
}
function normalizeFetchedTemplateRegion(region) {
return Object.assign({}, region, {
default_content: normalizeTemplateRegionDefaultContent(region.default_content),
read_only: normalizeTemplateRegionReadOnly(region.read_only)
});
}
function normalizeTemplateRegionAnimation(value) {
if (animationPresets && typeof animationPresets.normalize === 'function') {
return animationPresets.normalize(value);
@@ -156,8 +175,8 @@ async function fetchTemplateById(pool, id) {
return null;
}
const template = templates[0];
const [regions] = await pool.query('SELECT id, template_id, region_key, region_type, label, lock_ratio, animation_json, x, y, width, height, z_index, created_at, modified_at, created_by, modified_by FROM c_template_regions WHERE template_id = ? ORDER BY z_index ASC, id ASC', [id]);
template.regions = regions;
const [regions] = await pool.query('SELECT id, template_id, region_key, region_type, label, lock_ratio, animation_json, default_content_json AS default_content, read_only, x, y, width, height, z_index, created_at, modified_at, created_by, modified_by FROM c_template_regions WHERE template_id = ? ORDER BY z_index ASC, id ASC', [id]);
template.regions = regions.map(normalizeFetchedTemplateRegion);
return template;
}
@@ -169,8 +188,8 @@ async function fetchTemplatesData(pool) {
LEFT JOIN c_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, lock_ratio, animation_json, x, y, width, height, z_index, created_at, modified_at, created_by, modified_by FROM c_template_regions ORDER BY template_id ASC, z_index ASC, id ASC');
return { templates, templateRegions };
const [templateRegions] = await pool.query('SELECT id, template_id, region_key, region_type, label, lock_ratio, animation_json, default_content_json AS default_content, read_only, x, y, width, height, z_index, created_at, modified_at, created_by, modified_by FROM c_template_regions ORDER BY template_id ASC, z_index ASC, id ASC');
return { templates, templateRegions: templateRegions.map(normalizeFetchedTemplateRegion) };
}
function extractTemplateRegions(body) {
@@ -186,6 +205,8 @@ function extractTemplateRegions(body) {
region_type: regionType,
label: regionName,
lock_ratio: normalizeTemplateRegionLockRatio(region.lock_ratio),
default_content: normalizeTemplateRegionDefaultContent(region.default_content),
read_only: normalizeTemplateRegionReadOnly(region.read_only),
animation_json: normalizeTemplateRegionAnimationConfig(region.animation_json),
x: Number(region.x || 0),
y: Number(region.y || 0),
@@ -222,6 +243,8 @@ function extractTemplateRegions(body) {
region_type: regionType,
label: name,
lock_ratio: normalizeTemplateRegionLockRatio(ratios[i]),
default_content: {},
read_only: false,
animation_json: normalizeTemplateRegionAnimationConfig(animationJsons[i]),
x: Number(xs[i] || 0),
y: Number(ys[i] || 0),