← back to Marketing Command Center
public/panels/reels.js
29 lines
// Reels panel — embeds the dw-marketing-reels console through the module's
// same-origin proxy (/api/reels/ui/). The probe runs first so a down upstream
// shows a diagnosis banner instead of a grey dead iframe.
window.MCC_PANELS = window.MCC_PANELS || {};
window.MCC_PANELS['reels'] = {
async init(root) {
const $ = (sel) => root.querySelector(sel);
const banner = $('#reels-banner');
let st = null;
try {
const r = await fetch(location.origin + '/api/reels/status', { credentials: 'same-origin' });
st = await r.json();
} catch (e) { st = { ok: false, error: String(e) }; }
if (!st.ok) {
banner.innerHTML = `The reels console isn’t reachable (<code>${st.base || ''}</code> — ${st.error || 'HTTP ' + st.status}).
It runs as its own pm2 process (<code>dw-marketing-reels</code>); restart it and reload this panel.`;
return;
}
banner.style.display = 'none';
$('#reels-toolbar').style.display = '';
$('#reels-count').textContent = st.reels != null ? `${st.reels} reel${st.reels === 1 ? '' : 's'} in the gallery` : 'gallery live';
$('#reels-open-direct').href = location.origin + '/api/reels/ui/';
const frame = $('#reels-frame');
frame.src = location.origin + '/api/reels/ui/';
frame.style.display = '';
},
};