feat: mejoras al dashboard y selector de UUID
- Dashboard: agregar opciones de 50 pestañas deterministas (lotes 1-4) - Dashboard: botón para cerrar salas individuales y expulsar jugadores - Dashboard: selector de variante G por sala individual en tabla - Nuevo selector moderno de UUID en página principal - Mostrar nombres de jugadores en selector de UUID - Búsqueda por UUID o nombre de jugador - Redireccionar /missing-uuid a selector principal - Endpoints para obtener UUIDs con nombres y cerrar/cambiar variante de salas
This commit is contained in:
@@ -37,6 +37,10 @@
|
||||
<option :value="2">2</option>
|
||||
<option :value="6">6</option>
|
||||
<option :value="10">10</option>
|
||||
<option value="50-1">50 (Lote 1: UUIDs 1-50)</option>
|
||||
<option value="50-2">50 (Lote 2: UUIDs 51-100)</option>
|
||||
<option value="50-3">50 (Lote 3: UUIDs 101-150)</option>
|
||||
<option value="50-4">50 (Lote 4: UUIDs 151-200)</option>
|
||||
</select>
|
||||
<template v-if="openCount === 1">
|
||||
<label>UUID:</label>
|
||||
@@ -154,6 +158,8 @@
|
||||
:room-details="roomDetails"
|
||||
@refresh="fetchData"
|
||||
@view-room-modal="openRoomModal"
|
||||
@close-room="closeRoom"
|
||||
@change-variant="changeRoomVariant"
|
||||
/>
|
||||
|
||||
<!-- Cards View -->
|
||||
@@ -238,7 +244,7 @@ const isLoadingGlobal = ref(false);
|
||||
|
||||
// Open tabs UI state
|
||||
const allowedUuids = ref<string[]>([]);
|
||||
const openCount = ref<1|2|6|10>(1);
|
||||
const openCount = ref<1|2|6|10|'50-1'|'50-2'|'50-3'|'50-4'>(1);
|
||||
const selectedUuid = ref('');
|
||||
|
||||
const gameRooms = computed(() => rooms.value.filter(r => r.name === 'game'));
|
||||
@@ -248,14 +254,17 @@ const totalPlayers = computed(() => rooms.value.reduce((sum, room) => sum + room
|
||||
onMounted(async () => {
|
||||
// Try SSE first, fallback to polling if it fails
|
||||
initSSE();
|
||||
// Load allowed UUIDs
|
||||
// Load allowed UUIDs from API
|
||||
try {
|
||||
const list = await colyseusService.fetchAllowedUuids();
|
||||
allowedUuids.value = list || [];
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/admin/uuids`);
|
||||
const data = await response.json();
|
||||
allowedUuids.value = data.uuids || [];
|
||||
if (!selectedUuid.value && allowedUuids.value.length > 0) {
|
||||
selectedUuid.value = allowedUuids.value[0];
|
||||
}
|
||||
} catch {}
|
||||
} catch {
|
||||
console.error('Failed to load UUIDs from API');
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -329,6 +338,43 @@ async function kickPlayer(roomId: string, playerId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function closeRoom(roomId: string) {
|
||||
if (!confirm('¿Estás seguro de que quieres expulsar a todos los jugadores y cerrar esta sala?')) return;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/rooms/${roomId}/close`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Failed to close room');
|
||||
|
||||
console.log(`Room ${roomId} closed successfully`);
|
||||
await fetchData();
|
||||
} catch (error) {
|
||||
console.error('Failed to close room:', error);
|
||||
alert('Failed to close room. Check console for details.');
|
||||
}
|
||||
}
|
||||
|
||||
async function changeRoomVariant(roomId: string, variant: string) {
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/rooms/${roomId}/variant`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ variant })
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Failed to change room variant');
|
||||
|
||||
console.log(`Room ${roomId} variant changed to ${variant} successfully`);
|
||||
await fetchData();
|
||||
} catch (error) {
|
||||
console.error('Failed to change room variant:', error);
|
||||
alert('Failed to change room variant. Check console for details.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function refreshData() {
|
||||
fetchData();
|
||||
@@ -351,10 +397,24 @@ function openTabs() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Randomly select N distinct UUIDs
|
||||
const N = openCount.value as number;
|
||||
const pool = [...allowedUuids.value];
|
||||
if (pool.length === 0) return;
|
||||
|
||||
// Handle deterministic 50-UUID batches
|
||||
if (typeof openCount.value === 'string' && openCount.value.startsWith('50-')) {
|
||||
const batchNumber = parseInt(openCount.value.split('-')[1]);
|
||||
const startIndex = (batchNumber - 1) * 50;
|
||||
const endIndex = startIndex + 50;
|
||||
const batchUuids = pool.slice(startIndex, Math.min(endIndex, pool.length));
|
||||
|
||||
batchUuids.forEach(u => openOne(u));
|
||||
return;
|
||||
}
|
||||
|
||||
// For numeric counts, randomly select N distinct UUIDs
|
||||
const N = openCount.value as number;
|
||||
|
||||
// For other counts, use distinct UUIDs
|
||||
for (let i = pool.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[pool[i], pool[j]] = [pool[j], pool[i]];
|
||||
|
||||
Reference in New Issue
Block a user