fix carga de UUIDs en dashboard
Aplica el mismo patrón que funciona en UuidSelector: intenta uuids-with-names con fallback a uuids, y mapea correctamente los datos para extraer solo los UUIDs.
This commit is contained in:
@@ -265,16 +265,26 @@ const totalPlayers = computed(() => rooms.value.reduce((sum, room) => sum + room
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Try SSE first, fallback to polling if it fails
|
// Try SSE first, fallback to polling if it fails
|
||||||
initSSE();
|
initSSE();
|
||||||
// Load allowed UUIDs from API
|
// Load allowed UUIDs from API (using same pattern as UuidSelector)
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/admin/uuids`);
|
const response = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/admin/uuids-with-names`);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
console.warn('Failed to fetch uuids-with-names, trying fallback...');
|
||||||
|
// Fallback to regular UUIDs endpoint
|
||||||
|
const fallbackResponse = await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3000/api'}/admin/uuids`);
|
||||||
|
const fallbackData = await fallbackResponse.json();
|
||||||
|
allowedUuids.value = fallbackData.uuids || [];
|
||||||
|
} else {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
allowedUuids.value = data.uuids || [];
|
allowedUuids.value = (data.uuids || []).map((uuidInfo: any) => uuidInfo.uuid || uuidInfo);
|
||||||
|
}
|
||||||
|
|
||||||
if (!selectedUuid.value && allowedUuids.value.length > 0) {
|
if (!selectedUuid.value && allowedUuids.value.length > 0) {
|
||||||
selectedUuid.value = allowedUuids.value[0];
|
selectedUuid.value = allowedUuids.value[0];
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (error) {
|
||||||
console.error('Failed to load UUIDs from API');
|
console.error('Failed to load UUIDs from API:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user