.
This commit is contained in:
@@ -24,7 +24,7 @@ const Display = (() => {
|
||||
|
||||
gridEl.className = `display-video-grid panes-${count}`;
|
||||
gridEl.innerHTML = slots.slice(0, 4).map(slot => {
|
||||
const streamSrc = (!isPreview && slot.video.streamUrl)
|
||||
const streamSrc = slot.video.streamUrl
|
||||
? `${slot.video.streamUrl}?token=${encodeURIComponent(jwt || '')}${orgParam}`
|
||||
: '';
|
||||
return `
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
<div id="tab-users" style="display:none;">
|
||||
<div class="page-header" style="margin-bottom:var(--space-4);">
|
||||
<h2 class="card-title">Users</h2>
|
||||
<button class="btn btn-primary btn-sm" id="invite-btn">Invite User</button>
|
||||
<button class="btn btn-primary btn-sm" id="invite-btn">Add User</button>
|
||||
</div>
|
||||
<div id="user-list">
|
||||
<div class="empty-state"><p class="empty-state-text">Loading…</p></div>
|
||||
@@ -224,15 +224,15 @@
|
||||
<div class="modal-overlay" id="invite-modal" style="display:none;">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title">Invite User</h2>
|
||||
<h2 class="modal-title">Add User</h2>
|
||||
<button class="modal-close" id="invite-modal-close">×</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="invite-name">Name</label>
|
||||
<input class="form-input" type="text" id="invite-name" maxlength="80">
|
||||
<label class="form-label" for="invite-username">Username <span style="font-weight:400;opacity:0.6;">(letters, numbers, _ . -)</span></label>
|
||||
<input class="form-input" type="text" id="invite-username" maxlength="64" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="invite-email">Email</label>
|
||||
<label class="form-label" for="invite-email">Email <span style="font-weight:400;opacity:0.6;">(optional — used for password reset)</span></label>
|
||||
<input class="form-input" type="email" id="invite-email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -244,7 +244,11 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="invite-password">Temporary Password</label>
|
||||
<input class="form-input" type="text" id="invite-password" autocomplete="off">
|
||||
<input class="form-input" type="password" id="invite-password" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="invite-password-confirm">Confirm Temporary Password</label>
|
||||
<input class="form-input" type="password" id="invite-password-confirm" autocomplete="new-password">
|
||||
</div>
|
||||
<div id="invite-error" class="form-error" style="display:none;"></div>
|
||||
<button class="btn btn-primary" id="invite-confirm-btn">Create User</button>
|
||||
@@ -438,16 +442,22 @@
|
||||
});
|
||||
document.getElementById('invite-modal-close').addEventListener('click', () => {
|
||||
document.getElementById('invite-modal').style.display = 'none';
|
||||
document.getElementById('invite-username').value = '';
|
||||
document.getElementById('invite-password').value = '';
|
||||
document.getElementById('invite-password-confirm').value = '';
|
||||
});
|
||||
document.getElementById('invite-confirm-btn').addEventListener('click', async () => {
|
||||
const errEl = document.getElementById('invite-error'); errEl.style.display = 'none';
|
||||
const name = document.getElementById('invite-name').value.trim();
|
||||
const username = document.getElementById('invite-username').value.trim();
|
||||
const email = document.getElementById('invite-email').value.trim();
|
||||
const role = document.getElementById('invite-role').value;
|
||||
const password = document.getElementById('invite-password').value;
|
||||
if (!name || !email || !password) { errEl.textContent = 'All fields required.'; errEl.style.display = 'block'; return; }
|
||||
const confirm = document.getElementById('invite-password-confirm').value;
|
||||
if (!username || !password) { errEl.textContent = 'Username and password are required.'; errEl.style.display = 'block'; return; }
|
||||
if (password.length < 8) { errEl.textContent = 'Password must be at least 8 characters.'; errEl.style.display = 'block'; return; }
|
||||
if (password !== confirm) { errEl.textContent = 'Passwords do not match.'; errEl.style.display = 'block'; return; }
|
||||
try {
|
||||
const res = await Api.post('/api/v1/users', { name, email, role, password });
|
||||
const res = await Api.post('/api/v1/users', { username, ...(email && { email }), role, password });
|
||||
if (res.ok) {
|
||||
toast('User created.', 'success');
|
||||
document.getElementById('invite-modal').style.display = 'none';
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div class="card" style="margin-top:var(--space-6);">
|
||||
<h2 class="card-title" style="margin-bottom:var(--space-4);">TV Preview</h2>
|
||||
<div style="position:relative;width:100%;padding-top:56.25%;background:#000;border-radius:var(--radius-md);overflow:hidden;">
|
||||
<iframe id="display-preview" src="about:blank" style="position:absolute;inset:0;width:100%;height:100%;border:none;" allowfullscreen></iframe>
|
||||
<div id="display-preview" style="position:absolute;inset:0;width:100%;height:100%;background:#000;border-radius:var(--radius-md);overflow:hidden;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
@@ -79,6 +79,31 @@
|
||||
|
||||
function esc(s) { return String(s ?? '').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); }
|
||||
|
||||
function renderPreview() {
|
||||
const el = document.getElementById('display-preview');
|
||||
if (!el) return;
|
||||
const jwt = Auth.getJwt();
|
||||
const selectedOrg = Auth.getSelectedOrg();
|
||||
const orgParam = selectedOrg ? `&orgId=${selectedOrg.id}` : '';
|
||||
const active = _slots.filter(s => s.videoId && s.streamUrl);
|
||||
const count = Math.min(active.length, 4);
|
||||
if (!count) {
|
||||
el.innerHTML = '<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:rgba(255,255,255,0.4);font-size:14px;">No exercises assigned.</div>';
|
||||
return;
|
||||
}
|
||||
const cols = count === 1 ? '1fr' : '1fr 1fr';
|
||||
const rows = count <= 2 ? '1fr' : '1fr 1fr';
|
||||
el.innerHTML = `<div style="display:grid;gap:3px;background:#000;width:100%;height:100%;grid-template-columns:${cols};grid-template-rows:${rows};">
|
||||
${active.slice(0, 4).map(s => {
|
||||
const src = `${s.streamUrl}?token=${encodeURIComponent(jwt || '')}${orgParam}`;
|
||||
return `<div style="position:relative;background:#111;overflow:hidden;min-height:0;">
|
||||
<video src="${src}" style="width:100%;height:100%;object-fit:cover;display:block;" autoplay loop muted playsinline></video>
|
||||
${s.reps != null ? `<div style="position:absolute;bottom:8px;right:12px;font-size:clamp(24px,4vw,72px);font-weight:900;color:#fff;text-shadow:0 2px 12px rgba(0,0,0,.9);line-height:1;">${s.reps}</div>` : ''}
|
||||
</div>`;
|
||||
}).join('')}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderTitle() {
|
||||
document.getElementById('title-area').innerHTML = `<h1 class="page-title" style="margin:0;">${esc(_workout.name)}</h1>`;
|
||||
document.title = `${_workout.name} — VitFit`;
|
||||
@@ -187,7 +212,16 @@
|
||||
if (res.ok) {
|
||||
const { data } = await res.json();
|
||||
_workout = data;
|
||||
document.getElementById('display-preview').src = `/workout-display.html?id=${_workout.id}&preview=1`;
|
||||
_slots = (data.videos || []).filter(s => s.video).map(s => ({
|
||||
videoId: s.video.id,
|
||||
desc: s.video.description || '',
|
||||
streamUrl: s.video.streamUrl || '',
|
||||
reps: s.reps ?? null,
|
||||
pendingId: null,
|
||||
pendingDesc: null,
|
||||
}));
|
||||
renderSlots();
|
||||
renderPreview();
|
||||
toast('Saved.', 'success');
|
||||
} else {
|
||||
const b = await res.json().catch(() => ({}));
|
||||
@@ -252,7 +286,6 @@
|
||||
if (!id) { window.location.href = '/workouts.html'; return; }
|
||||
|
||||
document.getElementById('display-link').href = `/workout-display.html?id=${id}`;
|
||||
document.getElementById('display-preview').src = `/workout-display.html?id=${id}&preview=1`;
|
||||
|
||||
const workoutRes = await Api.get(`/api/v1/workouts/${id}`);
|
||||
if (!workoutRes.ok) { window.location.href = '/workouts.html'; return; }
|
||||
@@ -262,6 +295,7 @@
|
||||
_slots = (w.videos || []).filter(s => s.video).map(s => ({
|
||||
videoId: s.video.id,
|
||||
desc: s.video.description || '',
|
||||
streamUrl: s.video.streamUrl || '',
|
||||
reps: s.reps ?? null,
|
||||
pendingId: null,
|
||||
pendingDesc: null,
|
||||
@@ -270,6 +304,7 @@
|
||||
renderTitle();
|
||||
renderMeta();
|
||||
renderSlots();
|
||||
renderPreview();
|
||||
|
||||
// Load categories for modal filter
|
||||
try {
|
||||
@@ -288,7 +323,7 @@
|
||||
// Add slot
|
||||
document.getElementById('add-slot-btn').addEventListener('click', () => {
|
||||
if (_slots.length >= 4) return;
|
||||
_slots.push({ videoId: null, desc: '', reps: null, pendingId: null, pendingDesc: null });
|
||||
_slots.push({ videoId: null, desc: '', streamUrl: '', reps: null, pendingId: null, pendingDesc: null });
|
||||
_editingIdx = _slots.length - 1;
|
||||
renderSlots();
|
||||
openPicker(_editingIdx);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user