mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 20:26:00 +00:00
editing MySQL binary fiellds
This commit is contained in:
@@ -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)}
|
||||
<span class="null">({value.data.length} bytes)</span>
|
||||
{#if value.data.length <= 16}
|
||||
<span class="value">{arrayToHexString(value.data)}</span>
|
||||
{:else}
|
||||
<span class="null">({value.data.length} bytes)</span>
|
||||
{/if}
|
||||
{:else if _.isPlainObject(value)}
|
||||
<span class="null" title={JSON.stringify(value, undefined, 2)}>(JSON)</span>
|
||||
{:else if _.isArray(value)}
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
<script lang="ts" context="module">
|
||||
function getEditedValue(value) {
|
||||
if (value?.type == 'Buffer' && _.isArray(value.data)) return arrayToHexString(value.data);
|
||||
if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
function getStoredValue(originalValue, newString) {
|
||||
if (originalValue?.type == 'Buffer' && _.isArray(originalValue?.data)) {
|
||||
return {
|
||||
type: 'Buffer',
|
||||
data: hexStringToArray(newString),
|
||||
};
|
||||
}
|
||||
return newString;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -10,6 +21,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import createRef from '../utility/createRef';
|
||||
import _ from 'lodash';
|
||||
import { arrayToHexString, hexStringToArray } from 'dbgate-tools';
|
||||
|
||||
export let inplaceEditorState;
|
||||
export let dispatchInsplaceEditor;
|
||||
@@ -32,7 +44,7 @@
|
||||
case keycodes.enter:
|
||||
if (isChangedRef.get()) {
|
||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
||||
onSetValue(domEditor.value);
|
||||
onSetValue(getStoredValue(cellValue, domEditor.value));
|
||||
isChangedRef.set(false);
|
||||
}
|
||||
domEditor.blur();
|
||||
@@ -41,7 +53,7 @@
|
||||
case keycodes.s:
|
||||
if (event.ctrlKey) {
|
||||
if (isChangedRef.get()) {
|
||||
onSetValue(domEditor.value);
|
||||
onSetValue(getStoredValue(cellValue, domEditor.value));
|
||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
||||
isChangedRef.set(false);
|
||||
}
|
||||
@@ -54,7 +66,7 @@
|
||||
|
||||
function handleBlur() {
|
||||
if (isChangedRef.get()) {
|
||||
onSetValue(domEditor.value);
|
||||
onSetValue(getStoredValue(cellValue, domEditor.value));
|
||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
||||
isChangedRef.set(false);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { toHexString } from 'dbgate-tools';
|
||||
import { arrayToHexString } from 'dbgate-tools';
|
||||
|
||||
export function copyTextToClipboard(text) {
|
||||
const oldFocus = document.activeElement;
|
||||
@@ -67,7 +67,7 @@ export function extractRowCopiedValue(row, col) {
|
||||
if (value === undefined) value = _.get(row, col);
|
||||
if (value === null) return '(NULL)';
|
||||
if (value === undefined) return '(NoField)';
|
||||
if (value.type == 'Buffer' && _.isArray(value.data)) return toHexString(value.data);
|
||||
if (value.type == 'Buffer' && _.isArray(value.data)) return arrayToHexString(value.data);
|
||||
if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user