From 02d17b816b9f48ab12155acf0986953cf9cabe3c Mon Sep 17 00:00:00 2001 From: josedario87 Date: Tue, 14 Oct 2025 03:10:53 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20agregar=20par=C3=A1metros=20por=20defect?= =?UTF-8?q?o=20y=20estado=20vac=C3=ADo=20amigable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Soluciona dos problemas en la ejecución de queries de Metabase: 1. Error de parámetros faltantes: - Las queries requieren parámetros (incluir_anulados, fecha_desde, fecha_hasta) - Agregado valores por defecto a todas las llamadas POST: * incluir_anulados: false * fecha_desde: null (sin filtro) * fecha_hasta: null (sin filtro) 2. Estado vacío poco amigable: - Cuando rows y cols están vacíos mostraba solo JSON - Agregado EmptyState visual con: * Icono de tabla vacía * Mensaje "No hay datos" * Descripción explicativa Cambios en: - MetabaseCardDisplay.vue: executeQuery() con parámetros y EmptyState - MetabaseCardsTable.vue: executeCard() con parámetros y EmptyState en modal --- .../metabase/MetabaseCardDisplay.vue | 23 +++++++++++++++++-- .../metabase/MetabaseCardsTable.vue | 23 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue b/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue index 6e8cb05..90cdc04 100644 --- a/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue +++ b/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue @@ -87,7 +87,19 @@ -
+ +
+
+ + + +
+

No hay datos

+

La consulta se ejecutó correctamente pero no devolvió resultados.

+
+ + +
{{ JSON.stringify(queryResult.data, null, 2) }}
@@ -155,7 +167,14 @@ async function executeQuery() { try { const result = await $fetch(`/api/metabase/cards/${props.card.id}/query`, { - method: 'POST' + method: 'POST', + body: { + parameters: [ + { type: 'category', target: ['variable', ['template-tag', 'incluir_anulados']], value: [false] }, + { type: 'date/single', target: ['variable', ['template-tag', 'fecha_desde']], value: null }, + { type: 'date/single', target: ['variable', ['template-tag', 'fecha_hasta']], value: null } + ] + } }) queryResult.value = result } catch (e: any) { diff --git a/nuxt4-app/app/components/metabase/MetabaseCardsTable.vue b/nuxt4-app/app/components/metabase/MetabaseCardsTable.vue index 0a8bd78..9b4311e 100644 --- a/nuxt4-app/app/components/metabase/MetabaseCardsTable.vue +++ b/nuxt4-app/app/components/metabase/MetabaseCardsTable.vue @@ -113,7 +113,19 @@ -
+ +
+
+ + + +
+

No hay datos

+

La consulta se ejecutó correctamente pero no devolvió resultados.

+
+ + +
{{ JSON.stringify(currentResult.data, null, 2) }}
@@ -210,7 +222,14 @@ async function executeCard(card: any) { try { const result = await $fetch(`/api/metabase/cards/${card.id}/query`, { - method: 'POST' + method: 'POST', + body: { + parameters: [ + { type: 'category', target: ['variable', ['template-tag', 'incluir_anulados']], value: [false] }, + { type: 'date/single', target: ['variable', ['template-tag', 'fecha_desde']], value: null }, + { type: 'date/single', target: ['variable', ['template-tag', 'fecha_hasta']], value: null } + ] + } }) currentResult.value = result showResults.value = true