diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3650502..357f269 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,22 @@
# Changelog
+## v1.1.4 โ 2026-07-22
+
+Admin dashboard for self-hosters (opt-in โ off by default).
+
+- ๐ ๏ธ **Admin dashboard** (Settings โ Admin dashboard) for whoever runs the instance: a users
+ overview with workout counts and last-active times, plus a per-user drill-down into their full
+ workout history and body-weight log.
+- ๐ข **Live "training now"** โ see who's mid-workout in real time, with their current exercise and
+ set progress, updated by a lightweight heartbeat while a workout is on screen.
+- ๐ซ **Disable / enable accounts** โ a disabled account is signed out and locked out everywhere
+ until you re-enable it.
+- ๐ **Invite-only signup** (optional) โ require an invite code to create a profile; generate and
+ revoke codes from the dashboard. Existing accounts are unaffected.
+- โ๏ธ Configured via environment: `ADMIN_UIDS` (comma-separated user ids who are admins) and
+ `INVITE_ONLY=1`; both default off, so a fresh instance stays open with no admin. See
+ `.env.example`. Admin access is gated by your passkey and enforced server-side.
+
## v1.1.3 โ 2026-07-22
- ๐ **Minimize the exercise animation during a workout** (#12). A โคก Minimize / โคข Expand button
diff --git a/api/server.js b/api/server.js
index d8c6839..7a01862 100644
--- a/api/server.js
+++ b/api/server.js
@@ -223,6 +223,19 @@ function readBody(req) {
}
const b64uToBuf = s => Buffer.from(s, 'base64url');
+/* ---------- live presence (in-memory) ---------- */
+// Clients heartbeat /api/activity while a workout is on screen; the admin dashboard reads who's
+// live. Purely ephemeral โ never persisted. Expires shortly after the last ping.
+const presence = new Map(); // uid -> { name, exIdx, exTotal, setsDone, setsTotal, startedAt, updatedAt }
+const PRESENCE_TTL = 70000; // ~3.5ร the 20s client heartbeat
+function livePresence(uid) {
+ const p = presence.get(uid);
+ if (!p) return null;
+ if (Date.now() - p.updatedAt > PRESENCE_TTL) { presence.delete(uid); return null; }
+ return p;
+}
+setInterval(() => { for (const [k, v] of presence) if (Date.now() - v.updatedAt > PRESENCE_TTL) presence.delete(k); }, 30000).unref();
+
/* ---------- routes ---------- */
const routes = {
'GET /api/health': async (req, res) => json(res, 200, { ok: true, users: db.users.length }),
@@ -398,6 +411,23 @@ const routes = {
json(res, 200, { ok: true });
},
+ // Live-workout heartbeat: client pings while a workout is on screen; { active:false } drops it.
+ 'POST /api/activity': async (req, res) => {
+ const user = readSession(req);
+ if (!user) return json(res, 401, { error: 'not signed in' });
+ const body = await readBody(req);
+ if (body.active) {
+ presence.set(user.id, {
+ name: String(body.name || '').slice(0, 60),
+ exIdx: +body.exIdx || 0, exTotal: +body.exTotal || 0,
+ setsDone: +body.setsDone || 0, setsTotal: +body.setsTotal || 0,
+ startedAt: +body.startedAt || Date.now(),
+ updatedAt: Date.now()
+ });
+ } else presence.delete(user.id);
+ json(res, 200, { ok: true });
+ },
+
/* ---------- admin dashboard ---------- */
// One row per user, cheap enough for a personal instance (reads each state file once).
'GET /api/admin/users': async (req, res) => {
@@ -412,10 +442,11 @@ const routes = {
workouts: workouts.length,
lastWorkout: last ? last.d : null,
lastSync: S._ts || null,
- hasPush: db.subs.some(s => s.userId === u.id)
+ hasPush: db.subs.some(s => s.userId === u.id),
+ live: livePresence(u.id)
};
});
- json(res, 200, { users, invite_only: INVITE_ONLY });
+ json(res, 200, { users, invite_only: INVITE_ONLY, now: Date.now() });
},
// Drill-down: full workout history + body-weight log for one user.
@@ -442,6 +473,7 @@ const routes = {
if (!u) return json(res, 404, { error: 'no such user' });
if (isAdmin(u)) return json(res, 400, { error: 'cannot disable an admin' });
u.disabled = !!body.disabled;
+ if (u.disabled) presence.delete(u.id); // drop them off "training now" at once
saveDb();
json(res, 200, { ok: true, id: u.id, disabled: u.disabled });
},
diff --git a/frontend/package.json b/frontend/package.json
index 2517c82..c3383c9 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "opengym-frontend",
"private": true,
- "version": "1.1.3",
+ "version": "1.1.4",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx
index 7c72ad8..6f69adb 100644
--- a/frontend/src/views/Admin.jsx
+++ b/frontend/src/views/Admin.jsx
@@ -19,6 +19,7 @@ const rel = ts => {
if (s < 86400) return Math.floor(s / 3600) + 'h ago'
return Math.floor(s / 86400) + 'd ago'
}
+const dur = ms => { const m = Math.max(0, Math.floor(ms / 60000)); return m < 60 ? m + 'm' : Math.floor(m / 60) + 'h' + (m % 60) + 'm' }
function UserDetail({ id, onChanged, close }) {
const [d, setD] = useState(null)
@@ -96,10 +97,12 @@ export default function Admin() {
const loadUsers = () => api('/api/admin/users').then(d => { setUsers(d.users); setInviteOnly(d.invite_only) }).catch(e => toast(e.message || 'Failed to load'))
const loadInvites = () => api('/api/admin/invites').then(d => setInvites(d.invites)).catch(() => {})
- useEffect(() => { if (user?.admin) { loadUsers(); loadInvites() } }, [])
+ // poll every 15s so the "training now" section stays live without a manual refresh
+ useEffect(() => { if (!user?.admin) return; loadUsers(); loadInvites(); const iv = setInterval(loadUsers, 15000); return () => clearInterval(iv) }, [])
if (!user?.admin) return null
const openUser = id => openSheet(close =>