diff --git a/webapp/packages/core-localization/src/locales/en.ts b/webapp/packages/core-localization/src/locales/en.ts index ba648f7bcb..579789ec34 100644 --- a/webapp/packages/core-localization/src/locales/en.ts +++ b/webapp/packages/core-localization/src/locales/en.ts @@ -98,6 +98,7 @@ export default [ ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], + ['ui_show_more', 'Show more'], ['ui_limit', 'Limit'], ['ui_file_size', 'File size'], ['ui_processing_synchronization', 'Synchronization...'], diff --git a/webapp/packages/core-localization/src/locales/it.ts b/webapp/packages/core-localization/src/locales/it.ts index 300505612f..a25238f52a 100644 --- a/webapp/packages/core-localization/src/locales/it.ts +++ b/webapp/packages/core-localization/src/locales/it.ts @@ -82,6 +82,7 @@ export default [ ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], + ['ui_show_more', 'Show more'], ['ui_limit', 'Limit'], ['ui_file_size', 'File size'], ['ui_processing_synchronization', 'Synchronization...'], diff --git a/webapp/packages/core-localization/src/locales/ru.ts b/webapp/packages/core-localization/src/locales/ru.ts index 88fc70484f..d72791ff8e 100644 --- a/webapp/packages/core-localization/src/locales/ru.ts +++ b/webapp/packages/core-localization/src/locales/ru.ts @@ -94,6 +94,7 @@ export default [ ['ui_upload', 'Загрузить'], ['ui_import', 'Импортировать'], ['ui_view', 'Смотреть'], + ['ui_show_more', 'Показать больше'], ['ui_limit', 'Лимит'], ['ui_file_size', 'Размер файла'], ['ui_processing_synchronization', 'Синхронизация...'], diff --git a/webapp/packages/core-localization/src/locales/zh.ts b/webapp/packages/core-localization/src/locales/zh.ts index c7b5d28e39..86042dae8d 100644 --- a/webapp/packages/core-localization/src/locales/zh.ts +++ b/webapp/packages/core-localization/src/locales/zh.ts @@ -95,6 +95,7 @@ export default [ ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], + ['ui_show_more', 'Show more'], ['ui_limit', 'Limit'], ['ui_file_size', 'File size'], ['ui_processing_synchronization', 'Synchronization...'], diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryFileValue.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryValue.ts similarity index 55% rename from webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryFileValue.ts rename to webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryValue.ts index 84d282ac20..1cf8f3888a 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryFileValue.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetBinaryValue.ts @@ -1,5 +1,5 @@ import type { IResultSetContentValue } from './IResultSetContentValue'; -export interface IResultSetBinaryFileValue extends IResultSetContentValue { +export interface IResultSetBinaryValue extends IResultSetContentValue { binary: string; } diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts index 3f7d069e99..6a6c53cbca 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts @@ -5,12 +5,12 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import type { IResultSetContentValue } from './IResultSetContentValue'; import type { IResultSetElementKey } from './IResultSetDataKey'; export interface IResultSetDataContentAction { activeElement: IResultSetElementKey | null; - isContentTruncated: (content: IResultSetContentValue) => boolean; + isBlobTruncated: (element: IResultSetElementKey) => boolean; + isTextTruncated: (element: IResultSetElementKey) => boolean; isDownloadable: (element: IResultSetElementKey) => boolean; getFileDataUrl: (element: IResultSetElementKey) => Promise; resolveFileDataUrl: (element: IResultSetElementKey) => Promise; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts index 3d254d940e..b59d45de85 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts @@ -9,13 +9,12 @@ import { makeObservable, observable } from 'mobx'; import { QuotasService } from '@cloudbeaver/core-root'; import { GraphQLService, ResultDataFormat } from '@cloudbeaver/core-sdk'; -import { download, GlobalConstants } from '@cloudbeaver/core-utils'; +import { bytesToSize, download, GlobalConstants, isNotNullDefined } from '@cloudbeaver/core-utils'; import { DatabaseDataAction } from '../../DatabaseDataAction'; import type { IDatabaseDataSource } from '../../IDatabaseDataSource'; import type { IDatabaseResultSet } from '../../IDatabaseResultSet'; import { databaseDataAction } from '../DatabaseDataActionDecorator'; -import type { IResultSetContentValue } from './IResultSetContentValue'; import type { IResultSetDataContentAction } from './IResultSetDataContentAction'; import type { IResultSetElementKey } from './IResultSetDataKey'; import { isResultSetContentValue } from './isResultSetContentValue'; @@ -57,8 +56,53 @@ export class ResultSetDataContentAction extends DatabaseDataAction this.quotasService.getQuota('sqlBinaryPreviewMaxLength'); + getLimitInfo(elementKey: IResultSetElementKey) { + const isTextColumn = this.format.isText(elementKey); + const isBlob = this.format.isBinary(elementKey); + const result = { + limit: undefined as number | undefined, + limitWithSize: undefined as string | undefined, + }; + + if (isTextColumn) { + result.limit = this.quotasService.getQuota('sqlTextPreviewMaxLength'); + } + + if (isBlob) { + result.limit = this.quotasService.getQuota('sqlBinaryPreviewMaxLength'); + } + + if (result.limit) { + result.limitWithSize = bytesToSize(result.limit); + } + + return result; + } + + isBlobTruncated(elementKey: IResultSetElementKey) { + const limit = this.getLimitInfo(elementKey).limit; + const content = this.format.get(elementKey); + const cachedBlobUrl = this.retrieveFileDataUrlFromCache(elementKey); + const isLoadedFullBlob = Boolean(cachedBlobUrl) && this.format.isBinary(elementKey); + + if (!isNotNullDefined(limit) || !isResultSetContentValue(content) || isLoadedFullBlob || !this.format.isBinary(elementKey)) { + return false; + } + + return (content.contentLength ?? 0) > limit; + } + + isTextTruncated(elementKey: IResultSetElementKey) { + const limit = this.getLimitInfo(elementKey).limit; + const content = this.format.get(elementKey); + const cachedFullText = this.retrieveFileFullTextFromCache(elementKey); + const isLoadedFullText = Boolean(cachedFullText) && this.format.isText(elementKey); + + if (!isNotNullDefined(limit) || !isResultSetContentValue(content) || isLoadedFullText) { + return false; + } + + return (content.contentLength ?? 0) > limit; } isDownloadable(element: IResultSetElementKey) { diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction.ts index 6f3f31c87e..4c819c2c09 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction.ts @@ -102,6 +102,16 @@ export class ResultSetFormatAction return false; } + isText(key: IResultSetPartialKey): boolean { + if (!key?.column) { + return false; + } + + const column = this.view.getColumn(key.column); + + return column?.dataKind?.toLocaleLowerCase() === 'string'; + } + getHeaders(): string[] { return this.view.columns.map(column => column.name!).filter(name => name !== undefined); } diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue.ts deleted file mode 100644 index ae85c5deba..0000000000 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { IResultSetBinaryFileValue } from './IResultSetBinaryFileValue'; - -export function isResultSetBinaryFileValue(value: any): value is IResultSetBinaryFileValue { - return value?.contentType === 'application/octet-stream' && Boolean(value?.binary); -} diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue.ts new file mode 100644 index 0000000000..2301c3eea5 --- /dev/null +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue.ts @@ -0,0 +1,13 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import type { IResultSetBinaryValue } from './IResultSetBinaryValue'; +import { isResultSetContentValue } from './isResultSetContentValue'; + +export function isResultSetBinaryValue(value: any): value is IResultSetBinaryValue { + return isResultSetContentValue(value) && 'binary' in value; +} diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultActions.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultSetActions.ts similarity index 96% rename from webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultActions.ts rename to webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultSetActions.ts index 0126441793..36da10e1dc 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultActions.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/useResultSetActions.ts @@ -17,7 +17,7 @@ interface IResultActionsArgs { model: IDatabaseDataModel; } -export function useResultActions({ model, resultIndex }: IResultActionsArgs) { +export function useResultSetActions({ model, resultIndex }: IResultActionsArgs) { return useObservableRef( () => ({ get dataAction(): ResultSetDataAction { diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx index 93cc494403..f92f970dfc 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx @@ -12,12 +12,12 @@ import { ActionIconButton, Button, Container, Fill, s, useObservableRef, useS, u import { selectFiles } from '@cloudbeaver/core-browser'; import { useService } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; -import { QuotasService } from '@cloudbeaver/core-root'; import { type TabContainerPanelComponent, useTabLocalState } from '@cloudbeaver/core-ui'; import { bytesToSize, download, getMIME, isImageFormat, isValidUrl } from '@cloudbeaver/core-utils'; import { createResultSetBlobValue } from '../../DatabaseDataModel/Actions/ResultSet/createResultSetBlobValue'; import type { IResultSetElementKey } from '../../DatabaseDataModel/Actions/ResultSet/IResultSetDataKey'; +import { isResultSetBinaryValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue'; import { isResultSetBlobValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetBlobValue'; import { isResultSetContentValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetContentValue'; import { isResultSetFileValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetFileValue'; @@ -66,7 +66,6 @@ export const ImageValuePresentation: TabContainerPanelComponent @@ -123,7 +122,7 @@ export const ImageValuePresentation: TabContainerPanelComponent { + if (!data.selectedCell) { + return; + } - const load = async () => { - if (!data.selectedCell) { - return; - } + try { + await data.contentAction.resolveFileDataUrl(data.selectedCell); + } catch (exception: any) { + notificationService.logException(exception, 'data_viewer_presentation_value_content_download_error'); + } + }; - try { - await data.contentAction.resolveFileDataUrl(data.selectedCell); - } catch (exception: any) { - notificationService.logException(exception, 'data_viewer_presentation_value_content_download_error'); - } - }; + const valueSize = bytesToSize(isResultSetContentValue(value) ? value.contentLength ?? 0 : 0); + const isDownloadable = data.selectedCell && data.contentAction.isDownloadable(data.selectedCell); - return ( - - - - {data.selectedCell && data.contentAction.isDownloadable(data.selectedCell) && ( + return ( + + + {data.shouldShowImage && } + {data.truncated ? ( + + {isDownloadable && ( )} - - - - ); - } - - return ( - - - + ) : null} diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.m.css b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.m.css new file mode 100644 index 0000000000..6b0da42e73 --- /dev/null +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.m.css @@ -0,0 +1,7 @@ +.link { + margin-left: 4px; +} + +.limitWord { + text-transform: lowercase; +} diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx index dd95cf78a4..88c39b8b8a 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx @@ -6,64 +6,62 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import styled, { css } from 'reshadow'; -import { Link, usePermission, useTranslate } from '@cloudbeaver/core-blocks'; +import { Container, Link, s, usePermission, useS, useTranslate } from '@cloudbeaver/core-blocks'; import { EAdminPermission } from '@cloudbeaver/core-root'; +import type { IResultSetElementKey } from '../DatabaseDataModel/Actions/ResultSet/IResultSetDataKey'; +import { useResultSetActions } from '../DatabaseDataModel/Actions/ResultSet/useResultSetActions'; +import type { IDatabaseDataModel } from '../DatabaseDataModel/IDatabaseDataModel'; +import type { IDatabaseResultSet } from '../DatabaseDataModel/IDatabaseResultSet'; +import styles from './QuotaPlaceholder.m.css'; + interface Props { - limit?: string; - size?: string; className?: string; + elementKey: IResultSetElementKey | undefined; + model: IDatabaseDataModel; + resultIndex: number; + keepSize?: boolean; } -const style = css` - container { - margin: auto; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - } - p { - composes: theme-typography--body2 from global; - text-align: center; - margin: 0; - } - reason { - display: flex; - white-space: pre; - } - limit-word { - text-transform: lowercase; - } -`; - -export const QuotaPlaceholder: React.FC> = observer(function QuotaPlaceholder({ limit, size, className, children }) { +export const QuotaPlaceholder: React.FC> = observer(function QuotaPlaceholder({ + className, + children, + keepSize = false, + elementKey, + model, + resultIndex, +}) { const translate = useTranslate(); const admin = usePermission(EAdminPermission.admin); + const style = useS(styles); + const { contentAction } = useResultSetActions({ model, resultIndex }); + const limitInfo = elementKey ? contentAction.getLimitInfo(elementKey) : null; - return styled(style)( - -

+ return ( + + {translate('data_viewer_presentation_value_content_was_truncated')} - - {translate('data_viewer_presentation_value_content_truncated_placeholder') + ' '} - + + {translate('data_viewer_presentation_value_content_truncated_placeholder')} + {admin ? ( - + {translate('ui_limit')} ) : ( translate('ui_limit') )} - - - {limit && `${translate('ui_limit')}: ${limit}`} -
- {size && `${translate('data_viewer_presentation_value_content_value_size')}: ${size}`} -

- {children} -
, +
+
+ + {children} + ); }); diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx index 7d261c020e..739402f509 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx @@ -13,14 +13,13 @@ import styled, { css } from 'reshadow'; import { ActionIconButton, Button, Container, Fill, Group, useStyles, useTranslate } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; -import { QuotasService } from '@cloudbeaver/core-root'; import { BASE_TAB_STYLES, TabContainerPanelComponent, TabList, TabsState, UNDERLINE_TAB_STYLES, useTabLocalState } from '@cloudbeaver/core-ui'; import { bytesToSize, isNotNullDefined } from '@cloudbeaver/core-utils'; import { EditorLoader, useCodemirrorExtensions } from '@cloudbeaver/plugin-codemirror6'; import { isResultSetContentValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetContentValue'; import { ResultSetSelectAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetSelectAction'; -import { useResultActions } from '../../DatabaseDataModel/Actions/ResultSet/useResultActions'; +import { useResultSetActions } from '../../DatabaseDataModel/Actions/ResultSet/useResultSetActions'; import type { IDatabaseResultSet } from '../../DatabaseDataModel/IDatabaseResultSet'; import type { IDataValuePanelProps } from '../../TableViewer/ValuePanel/DataValuePanelService'; import { QuotaPlaceholder } from '../QuotaPlaceholder'; @@ -55,18 +54,17 @@ export const TextValuePresentation: TabContainerPanelComponent getTypeExtension(contentType!) ?? [], [contentType]); const extensions = useCodemirrorExtensions(undefined, typeExtension); @@ -180,18 +178,24 @@ export const TextValuePresentation: TabContainerPanelComponent - {isTruncated && ( - - - - )} + {firstSelectedCell && contentAction.isTextTruncated(firstSelectedCell) ? ( + + {shouldShowPasteButton && ( + + + + )} + + ) : null} {canSave && ( @@ -204,13 +208,6 @@ export const TextValuePresentation: TabContainerPanelComponent - {shouldShowPasteButton && ( - - - - )} , ); diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/isTextValuePresentationAvailable.ts b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/isTextValuePresentationAvailable.ts index 00fa9e9bc8..578bacb05e 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/isTextValuePresentationAvailable.ts +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/isTextValuePresentationAvailable.ts @@ -5,7 +5,7 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { isResultSetBinaryFileValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue'; +import { isResultSetBinaryValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue'; import { isResultSetContentValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetContentValue'; import { ResultSetSelectAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetSelectAction'; import { ResultSetViewAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetViewAction'; @@ -28,7 +28,7 @@ export function isBlobPresentationAvailable(context: IDataValuePanelProps; currentContentType: string; + elementKey?: IResultSetElementKey; } interface IUseTextValue { textValue: string; - isTruncated: boolean; isTextColumn: boolean; pasteFullText(): Promise; } -export function useTextValue({ model, resultIndex, currentContentType }: IUseTextValueArgs): IUseTextValue { - const { formatAction, editAction, contentAction, dataAction } = useResultActions({ model, resultIndex }); - const selection = model.source.getAction(resultIndex, ResultSetSelectAction); - const activeElements = selection.getActiveElements(); - const firstSelectedCell = activeElements?.[0]; +export function useTextValue({ model, resultIndex, currentContentType, elementKey }: IUseTextValueArgs): IUseTextValue { + const { formatAction, editAction, contentAction } = useResultSetActions({ model, resultIndex }); const formatter = useAutoFormat(); - const columnType = firstSelectedCell ? dataAction.getColumn(firstSelectedCell.column)?.dataKind : ''; - const isTextColumn = columnType?.toLocaleLowerCase() === 'string'; - const contentValue = firstSelectedCell ? formatAction.get(firstSelectedCell) : null; - const cachedFullText = firstSelectedCell ? contentAction.retrieveFileFullTextFromCache(firstSelectedCell) : ''; - const blob = firstSelectedCell ? formatAction.get(firstSelectedCell) : null; + const isTextColumn = elementKey ? formatAction.isText(elementKey) : false; + const contentValue = elementKey ? formatAction.get(elementKey) : null; + const isBinary = elementKey ? formatAction.isBinary(elementKey) : false; + const cachedFullText = elementKey ? contentAction.retrieveFileFullTextFromCache(elementKey) : ''; const notificationService = useService(NotificationService); const result: IUseTextValue = { textValue: '', - isTruncated: false, isTextColumn, async pasteFullText() { - if (!firstSelectedCell) { + if (!elementKey) { return; } try { - await contentAction.getFileFullText(firstSelectedCell); + await contentAction.getFileFullText(elementKey); } catch (exception) { notificationService.logException(exception as any, 'data_viewer_presentation_value_content_paste_error'); } }, }; - if (!isNotNullDefined(firstSelectedCell)) { + if (!isNotNullDefined(elementKey)) { return result; } - if (isResultSetContentValue(contentValue)) { - result.isTruncated = contentAction.isContentTruncated(contentValue); - } - if (isTextColumn && cachedFullText) { result.textValue = cachedFullText; - result.isTruncated = false; } - if (editAction.isElementEdited(firstSelectedCell)) { - result.textValue = formatAction.getText(firstSelectedCell); + if (editAction.isElementEdited(elementKey)) { + result.textValue = formatAction.getText(elementKey); } - if (isResultSetBinaryFileValue(blob)) { - const value = formatter.formatBlob(currentContentType, blob); + if (isBinary && isResultSetContentValue(contentValue)) { + const value = formatter.formatBlob(currentContentType, contentValue); if (value) { result.textValue = value; @@ -86,7 +75,7 @@ export function useTextValue({ model, resultIndex, currentContentType }: IUseTex } if (!result.textValue) { - result.textValue = formatter.format(currentContentType, formatAction.getText(firstSelectedCell)); + result.textValue = formatter.format(currentContentType, formatAction.getText(elementKey)); } return result; diff --git a/webapp/packages/plugin-data-viewer/src/index.ts b/webapp/packages/plugin-data-viewer/src/index.ts index cd93e62665..f42d855e6c 100644 --- a/webapp/packages/plugin-data-viewer/src/index.ts +++ b/webapp/packages/plugin-data-viewer/src/index.ts @@ -17,8 +17,8 @@ export * from './DatabaseDataModel/Actions/ResultSet/IResultSetComplexValue'; export * from './DatabaseDataModel/Actions/ResultSet/IResultSetFileValue'; export * from './DatabaseDataModel/Actions/ResultSet/IResultSetContentValue'; export * from './DatabaseDataModel/Actions/ResultSet/IResultSetGeometryValue'; -export * from './DatabaseDataModel/Actions/ResultSet/IResultSetBinaryFileValue'; -export * from './DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue'; +export * from './DatabaseDataModel/Actions/ResultSet/IResultSetBinaryValue'; +export * from './DatabaseDataModel/Actions/ResultSet/isResultSetBinaryValue'; export * from './DatabaseDataModel/Actions/ResultSet/isResultSetBlobValue'; export * from './DatabaseDataModel/Actions/ResultSet/isResultSetComplexValue'; export * from './DatabaseDataModel/Actions/ResultSet/isResultSetContentValue'; diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index 32151dc4ec..c60ea5c054 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -39,10 +39,8 @@ export default [ ['data_viewer_presentation_value_boolean_placeholder', "Can't show current value as boolean"], ['data_viewer_presentation_value_content_truncated_placeholder', 'The size of the value exceeds the'], ['data_viewer_presentation_value_content_was_truncated', 'The value was truncated'], - ['data_viewer_presentation_value_content_value_size', 'Value size'], ['data_viewer_presentation_value_content_download_error', 'Download failed'], ['data_viewer_presentation_value_content_paste_error', 'Cannot load full text'], - ['data_viewer_presentation_value_content_full_text_button', 'View full text'], ['data_viewer_script_preview', 'Script'], ['data_viewer_script_preview_dialog_title', 'Preview changes'], ['data_viewer_script_preview_error_title', "Can't get the script"], diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index f6fe83d731..a3c3507d82 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -35,10 +35,8 @@ export default [ ['data_viewer_presentation_value_boolean_placeholder', 'Non posso rappresentare il valore corrente come booleano'], ['data_viewer_presentation_value_content_truncated_placeholder', 'The size of the value exceeds the'], ['data_viewer_presentation_value_content_was_truncated', 'The value was truncated'], - ['data_viewer_presentation_value_content_value_size', 'Value size'], ['data_viewer_presentation_value_content_download_error', 'Download failed'], ['data_viewer_presentation_value_content_paste_error', 'Cannot load full text'], - ['data_viewer_presentation_value_content_full_text_button', 'View full text'], ['data_viewer_refresh_result_set', 'Refresh result set'], ['data_viewer_total_count_tooltip', 'Get total count'], ['data_viewer_total_count_failed', 'Failed to get total count'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/ru.ts b/webapp/packages/plugin-data-viewer/src/locales/ru.ts index 14fd9bfed4..ee4b0ae5f3 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -33,10 +33,8 @@ export default [ ['data_viewer_presentation_value_boolean_placeholder', 'Не удалось отобразить текущее значение как boolean'], ['data_viewer_presentation_value_content_truncated_placeholder', 'Размер значения превышает'], ['data_viewer_presentation_value_content_was_truncated', 'Значение было обрезано'], - ['data_viewer_presentation_value_content_value_size', 'Размер значения'], ['data_viewer_presentation_value_content_download_error', 'Не удалось загрузить файл'], ['data_viewer_presentation_value_content_paste_error', 'Не удалось загрузить весь текст'], - ['data_viewer_presentation_value_content_full_text_button', 'Посмотреть весь текст'], ['data_viewer_script_preview', 'Скрипт'], ['data_viewer_script_preview_dialog_title', 'Предпросмотр изменений'], ['data_viewer_script_preview_error_title', 'Не удалось получить скрипт'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/zh.ts b/webapp/packages/plugin-data-viewer/src/locales/zh.ts index 7a54e578aa..f069ac67db 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -39,10 +39,8 @@ export default [ ['data_viewer_presentation_value_boolean_placeholder', '无法将当前值显示为布尔值'], ['data_viewer_presentation_value_content_truncated_placeholder', 'The size of the value exceeds the'], ['data_viewer_presentation_value_content_was_truncated', 'The value was truncated'], - ['data_viewer_presentation_value_content_value_size', 'Value size'], ['data_viewer_presentation_value_content_download_error', 'Download failed'], ['data_viewer_presentation_value_content_paste_error', 'Cannot load full text'], - ['data_viewer_presentation_value_content_full_text_button', 'View full text'], ['data_viewer_script_preview', '脚本'], ['data_viewer_script_preview_dialog_title', '预览更改'], ['data_viewer_script_preview_error_title', '无法获取脚本'],