From 9c82f841552fa68e2597340823f5f3a5ccc41969 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 8 Feb 2024 14:22:22 +0100 Subject: [PATCH] Limit results on preview --- .../QueryViewerSidePanel/PreviewPanel.svelte | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/integration/QueryViewerSidePanel/PreviewPanel.svelte b/packages/builder/src/components/integration/QueryViewerSidePanel/PreviewPanel.svelte index 3873669b63..7a57ae3009 100644 --- a/packages/builder/src/components/integration/QueryViewerSidePanel/PreviewPanel.svelte +++ b/packages/builder/src/components/integration/QueryViewerSidePanel/PreviewPanel.svelte @@ -4,13 +4,27 @@ export let schema = {} export let rows = [] + export let maxRowsToDisplay = 5 - $: rowsCopy = cloneDeep(rows) + let rowsToDisplay + $: { + rowsToDisplay = [ + ...cloneDeep(rows).slice(0, maxRowsToDisplay), + // { [Object.keys(schema)[0]]: "1" }, + ] + if (rows.length - maxRowsToDisplay) { + rowsToDisplay.push({ + [Object.keys(schema)[0]]: `...${ + rows.length - maxRowsToDisplay + } further items`, + }) + } + } // Cast field in query preview response to number if specified by schema $: { - for (let i = 0; i < rowsCopy.length; i++) { - let row = rowsCopy[i] + for (let i = 0; i < rowsToDisplay.length; i++) { + let row = rowsToDisplay[i] for (let fieldName of Object.keys(schema)) { if (schema[fieldName] === "number" && !isNaN(Number(row[fieldName]))) { row[fieldName] = Number(row[fieldName]) @@ -23,7 +37,7 @@
- +