mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 19:53:57 +00:00
json row view
This commit is contained in:
@@ -4,13 +4,22 @@
|
|||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
|
|
||||||
export let selection;
|
export let selection;
|
||||||
|
export let showWholeRow = false;
|
||||||
|
|
||||||
let json = null;
|
let json = null;
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
$: try {
|
$: try {
|
||||||
const value = selection[0].value;
|
if (showWholeRow) {
|
||||||
json = _.isPlainObject(value) || _.isArray(value) ? value : JSON.parse(value);
|
if (selection?.length == 1) {
|
||||||
|
json = selection[0].rowData;
|
||||||
|
} else {
|
||||||
|
json = selection.map(x => x.rowData);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const value = selection[0].value;
|
||||||
|
json = _.isPlainObject(value) || _.isArray(value) ? value : JSON.parse(value);
|
||||||
|
}
|
||||||
error = null;
|
error = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err.message;
|
error = err.message;
|
||||||
|
|||||||
6
packages/web/src/celldata/JsonRowView.svelte
Normal file
6
packages/web/src/celldata/JsonRowView.svelte
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import JsonCellView from './JsonCellView.svelte';
|
||||||
|
export let selection;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<JsonCellView {selection} showWholeRow />
|
||||||
@@ -18,6 +18,12 @@
|
|||||||
component: JsonCellView,
|
component: JsonCellView,
|
||||||
single: true,
|
single: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'jsonRow',
|
||||||
|
title: 'Json - Row',
|
||||||
|
component: JsonRowView,
|
||||||
|
single: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function autodetect(selection) {
|
function autodetect(selection) {
|
||||||
@@ -41,6 +47,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
import JsonCellView from '../celldata/JsonCellView.svelte';
|
import JsonCellView from '../celldata/JsonCellView.svelte';
|
||||||
|
import JsonRowView from '../celldata/JsonRowView.svelte';
|
||||||
import TextCellViewNoWrap from '../celldata/TextCellViewNoWrap.svelte';
|
import TextCellViewNoWrap from '../celldata/TextCellViewNoWrap.svelte';
|
||||||
import TextCellViewWrap from '../celldata/TextCellViewWrap.svelte';
|
import TextCellViewWrap from '../celldata/TextCellViewWrap.svelte';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
|
|||||||
Reference in New Issue
Block a user