diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index 5845468a9..b9fac3880 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -14,3 +14,4 @@ export * from './filterName'; export * from './diffTools'; export * from './schemaEditorTools'; export * from './yamlModelConv'; +export * from './stringTools'; diff --git a/packages/tools/src/stringTools.ts b/packages/tools/src/stringTools.ts new file mode 100644 index 000000000..d3a44c5a5 --- /dev/null +++ b/packages/tools/src/stringTools.ts @@ -0,0 +1,12 @@ +export function arrayToHexString(byteArray) { + return byteArray.reduce((output, elem) => output + ('0' + elem.toString(16)).slice(-2), ''); +} + +export function hexStringToArray(inputString) { + var hex = inputString.toString(); + var res = []; + for (var n = 0; n < hex.length; n += 2) { + res.push(parseInt(hex.substr(n, 2), 16)); + } + return res; +} diff --git a/packages/web/src/datagrid/DataGridCell.svelte b/packages/web/src/datagrid/DataGridCell.svelte index ee7bf99af..57fcc169f 100644 --- a/packages/web/src/datagrid/DataGridCell.svelte +++ b/packages/web/src/datagrid/DataGridCell.svelte @@ -37,6 +37,7 @@ import _ from 'lodash'; import ShowFormButton from '../formview/ShowFormButton.svelte'; import { getBoolSettingsValue } from '../settings/settingsTools'; + import { arrayToHexString } from 'dbgate-tools'; export let rowIndex; export let col; @@ -99,7 +100,11 @@ {highlightSpecialCharacters(value)} {/if} {:else if value.type == 'Buffer' && _.isArray(value.data)} - ({value.data.length} bytes) + {#if value.data.length <= 16} + {arrayToHexString(value.data)} + {:else} + ({value.data.length} bytes) + {/if} {:else if _.isPlainObject(value)} (JSON) {:else if _.isArray(value)} diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index 5af89e44b..45bae5a19 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -192,14 +192,6 @@ return `Rows: ${allRowCount.toLocaleString()}`; } - function extractCopiedValue(row, col) { - let value = row[col]; - if (value === undefined) value = _.get(row, col); - if (value === null) return '(NULL)'; - if (value === undefined) return '(NoField)'; - if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value); - return value; - }