From eed4180b709e0a1b89a07254f62ae9d7e93e26a3 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Sat, 23 May 2026 09:12:40 -0400 Subject: [PATCH] feat(data): fetch /auth/me on load, store ZAMPP_DATA.ME with name/initials/role --- services/web-ui/public/data.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/services/web-ui/public/data.jsx b/services/web-ui/public/data.jsx index 6b92630..b5e1429 100644 --- a/services/web-ui/public/data.jsx +++ b/services/web-ui/public/data.jsx @@ -11,6 +11,7 @@ window.ZAMPP_DATA = { USERS: [], BINS: [], COMMENTS: [], + ME: null, }; async function apiFetch(path, opts = {}) { @@ -111,7 +112,7 @@ function normalizeJob(j) { } async function loadData() { - const [projectsR, assetsR, recordersR, jobsR, clusterR, usersR, binsR] = await Promise.allSettled([ + const [projectsR, assetsR, recordersR, jobsR, clusterR, usersR, binsR, meR] = await Promise.allSettled([ apiFetch('/projects'), apiFetch('/assets?limit=500'), apiFetch('/recorders'), @@ -119,6 +120,7 @@ async function loadData() { apiFetch('/cluster'), apiFetch('/users'), apiFetch('/bins'), + apiFetch('/auth/me'), ]); const projectMap = {}; @@ -171,6 +173,17 @@ async function loadData() { icon: b.type || 'grid', })); } + + if (meR.status === 'fulfilled' && meR.value) { + const me = meR.value; + window.ZAMPP_DATA.ME = { + id: me.id, + username: me.username, + name: me.display_name || me.username || 'User', + initials: (me.display_name || me.username || 'U').slice(0, 2).toUpperCase(), + role: me.role || 'viewer', + }; + } } window.ZAMPP_API = { fetch: apiFetch, loadData, fmtDuration, fmtSize, fmtRelative };