diff --git a/client/src/components/DashboardActions.vue b/client/src/components/DashboardActions.vue new file mode 100644 index 0000000..4bf37b8 --- /dev/null +++ b/client/src/components/DashboardActions.vue @@ -0,0 +1,112 @@ + + + + + + diff --git a/client/src/views/Dashboard.vue b/client/src/views/Dashboard.vue index e033606..69fb18e 100644 --- a/client/src/views/Dashboard.vue +++ b/client/src/views/Dashboard.vue @@ -123,6 +123,14 @@ > 🏠 Send All to Lobby + @@ -443,8 +451,8 @@ async function pauseAllGames() { console.error('Failed to pause all games:', error); alert('Failed to pause all games. Check console for details.'); } finally { - isLoadingGlobal.value = false; - } + isLoadingGlobal.value = false; +} } async function resumeAllGames() { @@ -561,6 +569,40 @@ async function sendAllToLobby() { } } +async function resetAllUuidProfiles() { + if (!confirm('¿Seguro que deseas resetear nombre, color y vergüenza de TODOS los UUIDs? Esta acción no se puede deshacer.')) return; + isLoadingGlobal.value = true; + try { + const response = await fetch(`${apiBase()}/admin/reset-uuid-profiles`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' } + }); + if (!response.ok) throw new Error('Failed to reset UUID profiles'); + const result = await response.json(); + console.log(result?.message || 'UUID profiles reset'); + alert(result?.message || 'UUID profiles reset'); + await fetchData(); + } catch (error) { + console.error('Failed to reset UUID profiles:', error); + alert('Failed to reset UUID profiles. Check console for details.'); + } finally { + isLoadingGlobal.value = false; + } +} + +// Build API base from env or current origin +function apiBase(): string { + try { + const raw = (import.meta.env as any)?.VITE_API_URL as string | undefined; + const env = (raw || '').trim(); + if (env) return env.replace(/\/$/, ''); + const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000'; + return `${origin.replace(/\/$/, '')}/api`; + } catch { + return 'http://localhost:3000/api'; + } +} + function initSSE() { try { console.log('[Dashboard] Initializing SSE connection...'); @@ -853,6 +895,11 @@ const selectedRoom = computed(() => { color: white; } +.btn-reset-profiles { + background: linear-gradient(135deg, #6b7280 0%, #374151 100%); + color: white; +} + .btn:disabled { opacity: 0.5; cursor: not-allowed; diff --git a/client/src/views/DemoGame.vue b/client/src/views/DemoGame.vue index bb96842..9e713f7 100644 --- a/client/src/views/DemoGame.vue +++ b/client/src/views/DemoGame.vue @@ -1,5 +1,20 @@