diff --git a/public/control.html b/public/control.html index 0cc2fed..3b892a5 100644 --- a/public/control.html +++ b/public/control.html @@ -129,14 +129,8 @@
- - -
-
-
-
- - + +
diff --git a/public/js/app_control.js b/public/js/app_control.js index 81062fd..b5ade3a 100644 --- a/public/js/app_control.js +++ b/public/js/app_control.js @@ -42,8 +42,7 @@ window.onload = async function () { const saveActiveYearBtn = document.getElementById('save-active-year'); // Player UI (settings tab): show/hide admin status blocks in player.html - const playerUiShowSourceEl = document.getElementById('player_ui_show_source'); - const playerUiShowProgressEl = document.getElementById('player_ui_show_progress'); + const playerUiShowStatusEl = document.getElementById('player_ui_show_status'); const playerUiReloadBtn = document.getElementById('player_ui_reload'); const playerUiSaveBtn = document.getElementById('player_ui_save'); @@ -193,21 +192,22 @@ window.onload = async function () { } function setPlayerUiForm(value) { - if (!playerUiShowSourceEl || !playerUiShowProgressEl) return; - playerUiShowSourceEl.checked = !!value.showSource; - playerUiShowProgressEl.checked = !!value.showProgress; + if (!playerUiShowStatusEl) return; + // Single checkbox controls both flags. + playerUiShowStatusEl.checked = !!value.showSource && !!value.showProgress; } function getPlayerUiFormValue() { + const enabled = !!playerUiShowStatusEl?.checked; return normalizePlayerUi({ - showSource: !!playerUiShowSourceEl?.checked, - showProgress: !!playerUiShowProgressEl?.checked, + showSource: enabled, + showProgress: enabled, }); } async function loadPlayerUiIntoUi() { // If the section isn't present (older HTML), skip gracefully. - if (!playerUiShowSourceEl) return; + if (!playerUiShowStatusEl) return; try { const value = await fetchPlayerUi(); setPlayerUiForm(value); diff --git a/public/js/app_player.js b/public/js/app_player.js index de77bbc..99d9381 100644 --- a/public/js/app_player.js +++ b/public/js/app_player.js @@ -139,6 +139,20 @@ async function fetchActiveOscarYear() { } } +async function fetchPlayerAdminStatusUi() { + try { + const res = await fetch('/api/settings/player-admin-status-ui', { method: 'GET' }); + if (!res.ok) return { showSource: true, showProgress: true }; + const data = await res.json().catch(() => ({})); + return { + showSource: data?.showSource === undefined ? true : !!data.showSource, + showProgress: data?.showProgress === undefined ? true : !!data.showProgress, + }; + } catch (_) { + return { showSource: true, showProgress: true }; + } +} + async function fetchPlaybackProgress(movieId, token) { try { const res = await fetch(`/api/movies/${encodeURIComponent(movieId)}/progress`, { @@ -868,8 +882,9 @@ window.onload = async function () { } pageLoader.setProgress(14); - // Load the active Oscar year in parallel with the movie fetch. + // Load the active Oscar year (and player UI flags) in parallel with the movie fetch. const activeYearPromise = fetchActiveOscarYear(); + const playerUiPromise = fetchPlayerAdminStatusUi(); let decoded = null; try { @@ -889,8 +904,6 @@ window.onload = async function () { if (decoded.admin) { const adminLink = document.getElementById('admin-control-link'); if (adminLink) adminLink.classList.remove('d-none'); - const adminStatus = document.getElementById('player-admin-status'); - if (adminStatus) adminStatus.classList.remove('d-none'); } const logoffBtn = document.getElementById('log-off'); @@ -927,10 +940,20 @@ window.onload = async function () { return; } - const activeYear = await activeYearPromise; + const [activeYear, playerUi] = await Promise.all([activeYearPromise, playerUiPromise]); setHeader(movie, { activeYear }); pageLoader.setProgress(58); + // Admin-only status block (Source + Progress) can be globally disabled via settings. + if (decoded?.admin) { + const enabled = !!playerUi?.showSource && !!playerUi?.showProgress; + const adminStatus = document.getElementById('player-admin-status'); + if (adminStatus) { + if (enabled) adminStatus.classList.remove('d-none'); + else adminStatus.classList.add('d-none'); + } + } + const resolved = resolveMovieSource(movie); if (!resolved?.src) { setSourceLabel('—');