mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 12:03:58 +00:00
fixed grid performance problem - limited length of cell string
This commit is contained in:
@@ -10,6 +10,8 @@ import _omitBy from 'lodash/omitBy';
|
|||||||
import { DataEditorTypesBehaviour } from 'dbgate-types';
|
import { DataEditorTypesBehaviour } from 'dbgate-types';
|
||||||
import isPlainObject from 'lodash/isPlainObject';
|
import isPlainObject from 'lodash/isPlainObject';
|
||||||
|
|
||||||
|
export const MAX_GRID_TEXT_LENGTH = 1000; // maximum length of text in grid cell, longer text is truncated
|
||||||
|
|
||||||
export type EditorDataType =
|
export type EditorDataType =
|
||||||
| 'null'
|
| 'null'
|
||||||
| 'objectid'
|
| 'objectid'
|
||||||
@@ -297,7 +299,9 @@ export function stringifyCellValue(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { value: highlightSpecialCharacters(value), gridStyle: 'textCellStyle' };
|
const valueLimited =
|
||||||
|
value.length > MAX_GRID_TEXT_LENGTH ? value.substring(0, MAX_GRID_TEXT_LENGTH) + '...' : value;
|
||||||
|
return { value: highlightSpecialCharacters(valueLimited), gridStyle: 'textCellStyle' };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return { value: value };
|
return { value: value };
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { SeriesSizes } from './SeriesSizes';
|
|||||||
import type { CellAddress } from './selection';
|
import type { CellAddress } from './selection';
|
||||||
import type { GridDisplay } from 'dbgate-datalib';
|
import type { GridDisplay } from 'dbgate-datalib';
|
||||||
import type Grider from './Grider';
|
import type Grider from './Grider';
|
||||||
import { isJsonLikeLongString, safeJsonParse } from 'dbgate-tools';
|
import { isJsonLikeLongString, MAX_GRID_TEXT_LENGTH, safeJsonParse } from 'dbgate-tools';
|
||||||
|
|
||||||
export function countColumnSizes(grider: Grider, columns, containerWidth, display: GridDisplay) {
|
export function countColumnSizes(grider: Grider, columns, containerWidth, display: GridDisplay) {
|
||||||
// console.log('COUNT SIZES');
|
// console.log('COUNT SIZES');
|
||||||
@@ -74,7 +74,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa
|
|||||||
else if (value?.$oid) text = `ObjectId("${value.$oid}")`;
|
else if (value?.$oid) text = `ObjectId("${value.$oid}")`;
|
||||||
else if (value?.$bigint) text = value.$bigint;
|
else if (value?.$bigint) text = value.$bigint;
|
||||||
else if (isJsonLikeLongString(value) && safeJsonParse(value)) text = '(JSON)';
|
else if (isJsonLikeLongString(value) && safeJsonParse(value)) text = '(JSON)';
|
||||||
const width = context.measureText(text).width + 8;
|
const width = context.measureText(typeof text == 'string' ? text.slice(0, MAX_GRID_TEXT_LENGTH) : text).width + 8;
|
||||||
// console.log('colName', colName, text, width);
|
// console.log('colName', colName, text, width);
|
||||||
columnSizes.putSizeOverride(colIndex, width);
|
columnSizes.putSizeOverride(colIndex, width);
|
||||||
// let colName = this.columns[colIndex].uniquePath;
|
// let colName = this.columns[colIndex].uniquePath;
|
||||||
|
|||||||
Reference in New Issue
Block a user