-
-
+
+
-
+
@@ -244,7 +244,11 @@
-
+
+
+
+
+
@@ -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';
diff --git a/V2/app/public/workout-view.html b/V2/app/public/workout-view.html
index fae5e80..2f54afd 100644
--- a/V2/app/public/workout-view.html
+++ b/V2/app/public/workout-view.html
@@ -43,7 +43,7 @@
@@ -79,6 +79,31 @@
function esc(s) { return String(s ?? '').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 = '
No exercises assigned.
';
+ return;
+ }
+ const cols = count === 1 ? '1fr' : '1fr 1fr';
+ const rows = count <= 2 ? '1fr' : '1fr 1fr';
+ el.innerHTML = `
+ ${active.slice(0, 4).map(s => {
+ const src = `${s.streamUrl}?token=${encodeURIComponent(jwt || '')}${orgParam}`;
+ return `
+
+ ${s.reps != null ? `
${s.reps}
` : ''}
+
`;
+ }).join('')}
+
`;
+ }
+
function renderTitle() {
document.getElementById('title-area').innerHTML = `
${esc(_workout.name)}
`;
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);
diff --git a/V2/app/vitfit.sqlite-shm b/V2/app/vitfit.sqlite-shm
index 548b269..9244051 100644
Binary files a/V2/app/vitfit.sqlite-shm and b/V2/app/vitfit.sqlite-shm differ
diff --git a/V2/app/vitfit.sqlite-wal b/V2/app/vitfit.sqlite-wal
index f0c26ce..b8510d5 100644
Binary files a/V2/app/vitfit.sqlite-wal and b/V2/app/vitfit.sqlite-wal differ