Display ... when large array
This commit is contained in:
parent
a7859f7fd8
commit
ec5e533063
|
@ -1,7 +1,17 @@
|
||||||
<script>
|
<script>
|
||||||
export let data
|
export let data
|
||||||
|
export let maxRowsToDisplay = 5
|
||||||
|
|
||||||
$: string = JSON.stringify(data || {}, null, 2)
|
let string
|
||||||
|
$: {
|
||||||
|
string = JSON.stringify(data || {}, null, 2)
|
||||||
|
if (Array.isArray(data) && data.length > maxRowsToDisplay) {
|
||||||
|
string = JSON.stringify(data.slice(0, maxRowsToDisplay) || {}, null, 2)
|
||||||
|
|
||||||
|
// Display '...' at the end of the array
|
||||||
|
string = string.replace(/(}\n])/, "},\n ...\n]")
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<textarea class="json" disabled value={string} />
|
<textarea class="json" disabled value={string} />
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{#if activeTab === "JSON"}
|
{#if activeTab === "JSON"}
|
||||||
<JSONPanel data={rows || {}} />
|
<JSONPanel data={rows?.length === 1 ? rows[0] : rows || {}} />
|
||||||
{:else if activeTab === "Schema"}
|
{:else if activeTab === "Schema"}
|
||||||
<SchemaPanel {onSchemaChange} {schema} />
|
<SchemaPanel {onSchemaChange} {schema} />
|
||||||
{:else}
|
{:else}
|
||||||
|
|
Loading…
Reference in New Issue