Settings: hidden Admin entry (opens /admin in the app window); admin page keeps a back link on phones
This commit is contained in:
@@ -1074,6 +1074,15 @@ async function renderSettings() {
|
||||
</span>
|
||||
<span id="aboutBuildTime" class="about-version">…</span>
|
||||
</div>
|
||||
<div class="set-row hidden" id="aboutAdminRow">
|
||||
<span>
|
||||
Admin
|
||||
<small>Lyrics studio, reports, library and server tools. Needs the admin password.</small>
|
||||
</span>
|
||||
<div class="set-actions" style="margin:0">
|
||||
<a class="btn" href="/admin" id="aboutAdminLink" style="text-decoration:none;display:inline-flex;align-items:center">Open admin</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
c.appendChild(wrap);
|
||||
@@ -1456,6 +1465,34 @@ async function renderSettings() {
|
||||
});
|
||||
updateProfileStatus();
|
||||
|
||||
// ---- About: Admin entry. Shown once this device has signed in as admin,
|
||||
// or after a long-press / five taps on the version (then remembered). It
|
||||
// opens /admin inside the app window, which has no address bar on iPhone.
|
||||
if (WEB) {
|
||||
const ADMIN_KEY = 'ytpAdminEntry';
|
||||
const revealAdmin = (remember) => {
|
||||
const row = $('aboutAdminRow');
|
||||
if (row) row.classList.remove('hidden');
|
||||
if (remember) { try { localStorage.setItem(ADMIN_KEY, '1'); } catch {} }
|
||||
};
|
||||
try { if (localStorage.getItem(ADMIN_KEY) === '1') revealAdmin(false); } catch {}
|
||||
fetch('/api/admin/me', { cache: 'no-store', credentials: 'same-origin' })
|
||||
.then((r) => (r.ok ? r.json() : null)).then((me) => { if (me && me.admin) revealAdmin(true); }).catch(() => {});
|
||||
const ver = $('aboutVersion');
|
||||
if (ver) {
|
||||
let taps = 0, tapTimer = null, holdTimer = null;
|
||||
const unlock = () => { if ($('aboutAdminRow')?.classList.contains('hidden')) { revealAdmin(true); toast('Admin entry shown in About'); } };
|
||||
ver.addEventListener('pointerdown', () => { clearTimeout(holdTimer); holdTimer = setTimeout(unlock, 700); });
|
||||
for (const n of ['pointerup', 'pointerleave', 'pointercancel']) ver.addEventListener(n, () => clearTimeout(holdTimer));
|
||||
ver.addEventListener('click', () => {
|
||||
taps++; clearTimeout(tapTimer); tapTimer = setTimeout(() => { taps = 0; }, 1500);
|
||||
if (taps >= 5) { taps = 0; unlock(); }
|
||||
});
|
||||
ver.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||
ver.style.webkitUserSelect = 'none'; ver.style.userSelect = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// ---- About: append server build tag + build time (WEB mode only) ----
|
||||
if (WEB) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user