mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
force text display
This commit is contained in:
parent
dbdb50f796
commit
f775fbad29
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getAsImageSrc, safeJsonParse } from 'dbgate-tools';
|
import { getAsImageSrc, safeJsonParse, stringifyCellValue } from 'dbgate-tools';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import CellValue from '../datagrid/CellValue.svelte';
|
import CellValue from '../datagrid/CellValue.svelte';
|
||||||
@ -10,6 +10,13 @@
|
|||||||
export let rowData;
|
export let rowData;
|
||||||
export let columnIndex;
|
export let columnIndex;
|
||||||
export let displayType;
|
export let displayType;
|
||||||
|
|
||||||
|
function getValueAsText(value, force) {
|
||||||
|
if (force && value?.type == 'Buffer' && _.isArray(value.data)) {
|
||||||
|
return String.fromCharCode.apply(String, value.data);
|
||||||
|
}
|
||||||
|
return stringifyCellValue(value);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<td rowspan={rowSpan} data-column={columnIndex} class:isEmpty={value === undefined}>
|
<td rowspan={rowSpan} data-column={columnIndex} class:isEmpty={value === undefined}>
|
||||||
@ -23,6 +30,10 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<span class="null"> (no image)</span>
|
<span class="null"> (no image)</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
{:else if displayType == 'text'}
|
||||||
|
{getValueAsText(value, false)}
|
||||||
|
{:else if displayType == 'forceText'}
|
||||||
|
{getValueAsText(value, true)}
|
||||||
{:else if !value?.$oid && (_.isArray(value) || _.isPlainObject(value))}
|
{:else if !value?.$oid && (_.isArray(value) || _.isPlainObject(value))}
|
||||||
<JSONTree {value} slicedKeyCount={1} disableContextMenu />
|
<JSONTree {value} slicedKeyCount={1} disableContextMenu />
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -319,6 +319,14 @@
|
|||||||
text: 'Image',
|
text: 'Image',
|
||||||
onClick: () => setColumnDisplay('image'),
|
onClick: () => setColumnDisplay('image'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Text',
|
||||||
|
onClick: () => setColumnDisplay('text'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Force text',
|
||||||
|
onClick: () => setColumnDisplay('forceText'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user