fix(plugin-data-viewer): CB-1500 remove extra generic

This commit is contained in:
Naumov Alexey
2022-04-14 16:31:42 +02:00
parent acb605b81a
commit 2ae7649919
7 changed files with 38 additions and 25 deletions
@@ -359,15 +359,17 @@
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.7214 22.053L25.5024 22.055L22.4454 22.058L21.5954 23.453L21.5024 23.397L21.5054 26.587L21.5074 29.635H22.2054L29.0844 29.63L29.0904 22.053H28.7214Z" fill="#D7351F"/>
</symbol>
<symbol id="img-fit-size" viewBox="0 0 32 32">
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.2267 1.00043L24.9117 4.68543L20.2817 9.28443L22.5557 11.5584L27.1547 6.92843L30.8397 10.6134V1.00043H21.2267Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.2817 21.5564L24.9117 26.1544L21.2267 29.8404H30.8397V20.2274L27.1547 23.9114L22.5557 19.2814L20.2817 21.5564Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.68551 23.9117L1.99951 20.2267V29.8397H11.6125L7.92851 26.1547L12.5585 21.5567L10.2835 19.2807L5.68551 23.9117Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 1.00043V10.6134L5.686 6.92843L10.284 11.5584L12.559 9.28443L7.928 4.68543L11.613 1.00043H2Z" fill="#338ECC"/>
<g clip-path="url(#clip0_3722_1285)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 12.0001L3 5.82851L9.8996 12.7281L12.728 9.89968L5.82835 3L12.0001 3V0H0.000105858V8.2016e-05H0V12.0001H3ZM20 3.00206L26.1714 3.00206L19.2719 9.90155L22.1003 12.73L29 5.8303L29 12.0021H32V3.00206V0.00205817L29.1714 0.00205814L29 0.00205813L20 0.00205707V3.00206Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M29 20L29 26.1714L22.1005 19.2719L19.2721 22.1003L26.1718 29L20 29L20 32L29 32L32 32L32 29.1714L32 29L32 20L29 20ZM12.0001 28.9981L5.8287 28.9981L12.7282 22.0986L9.89976 19.2702L3.00008 26.1699L3.00008 19.9981L8.30652e-05 19.9981L8.22784e-05 28.9981L8.20162e-05 31.9981L2.8287 31.9981L3.00008 31.9981L12.0001 31.9981L12.0001 28.9981Z" fill="#338ECC"/>
</g>
<defs>
<clipPath id="clip0_3722_1285">
<rect width="32" height="32" fill="white"/>
</clipPath>
</defs>
</symbol>
<symbol id="img-original-size" viewBox="0 0 32 32">
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.7776 -0.000427246L22.9696 4.84157L19.1156 0.988573V11.0406H29.1686L25.3156 7.18657L30.1576 2.37957L27.7776 -0.000427246Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.988183 19.1165L4.84218 22.9695L0.000183105 27.7785L2.37818 30.1565L7.18718 25.3145L11.0402 29.1685V19.1165H0.988183Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.37869 -0.000427246L-0.000305176 2.37957L4.84169 7.18657L0.988695 11.0406H11.0407V0.988573L7.18769 4.84157L2.37869 -0.000427246Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.116 19.1165V29.1685L22.97 25.3145L27.778 30.1565L30.157 27.7785L25.315 22.9695L29.168 19.1165H19.116Z" fill="#338ECC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.00049 9.9977L7.17187 9.9977L0.27238 3.0982L3.10081 0.269775L10.0005 7.16946L10.0005 0.997697L13.0005 0.997697V9.9977V12.9977H10.1719H10.0005L1.00049 12.9977L1.00049 9.9977ZM22 0.999838L22 7.17122L28.8995 0.27173L31.7279 3.10016L24.8282 9.99984L31 9.99984V12.9998H22H19V10.1712V9.99984V0.999838L22 0.999838ZM22.0002 30.9998L22.0002 24.8284L28.8997 31.7279L31.7281 28.8995L24.8284 21.9998H31.0002V18.9998H22.0002H19.0002V21.8284V21.9998V30.9998H22.0002ZM7.17147 21.9999L1.00008 21.9999L1.00008 18.9999H10.0001H10.1715H13.0001V21.9999V30.9999H10.0001L10.0001 24.8281L3.1004 31.7278L0.271973 28.8994L7.17147 21.9999Z" fill="#338ECC"/>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

+5 -1
View File
@@ -6,11 +6,15 @@
* you may not use this file except in compliance with the License.
*/
export function download(content: Blob | string, fileName = ''): void {
export function download(content: Blob | string, fileName = '', blank?: boolean): void {
const saveLink = document.createElement('a');
saveLink.tabIndex = -1;
saveLink.download = fileName;
if (blank) {
saveLink.target = '_blank';
saveLink.rel = 'noopener';
}
saveLink.style.display = 'none';
document.body.appendChild(saveLink);
@@ -39,11 +39,11 @@ export class DataGridContextMenuSaveContentService {
onClick: async context => {
try {
await context.data.model.source.dataManager.downloadFileData(context.data.key, context.data.resultIndex);
} catch (exception) {
this.notificationService.logException(exception as any, 'data_grid_table_context_menu_save_value_error');
} catch (exception: any) {
this.notificationService.logException(exception, 'data_grid_table_context_menu_save_value_error');
}
},
isHidden: context => !context.data.model.source.dataManager.canDownload(
isHidden: context => !context.data.model.source.dataManager.isContent(
context.data.key,
context.data.resultIndex
),
@@ -23,7 +23,7 @@ import type { IDatabaseResultSet } from './IDatabaseResultSet';
const RESULT_VALUE_PATH = 'sql-result-value';
export class DatabaseDataManager<TSource extends IDatabaseDataSource<any, any>> implements IDatabaseDataManager {
export class DatabaseDataManager implements IDatabaseDataManager {
private readonly cache: Map<string, string>;
activeElement: IResultSetElementKey | null;
@@ -34,13 +34,13 @@ export class DatabaseDataManager<TSource extends IDatabaseDataSource<any, any>>
this.cache = new Map();
this.activeElement = null;
makeObservable<DatabaseDataManager<TSource>, 'cache'>(this, {
makeObservable<this, 'cache'>(this, {
cache: observable,
activeElement: observable.ref,
});
}
canDownload(element: IResultSetElementKey, resultIndex: number) {
isContent(element: IResultSetElementKey, resultIndex: number) {
const view = this.source.getAction(resultIndex, ResultSetViewAction);
const cellValue = view.getCellValue(element);
@@ -10,7 +10,7 @@ import type { IResultSetElementKey } from './Actions/ResultSet/IResultSetDataKey
export interface IDatabaseDataManager {
activeElement: IResultSetElementKey | null;
canDownload: (element: IResultSetElementKey, resultIndex: number) => boolean;
isContent: (element: IResultSetElementKey, resultIndex: number) => boolean;
getFileDataUrl: (element: IResultSetElementKey, resultIndex: number) => Promise<string>;
resolveFileDataUrl: (element: IResultSetElementKey, resultIndex: number) => Promise<string>;
retrieveFileDataUrlFromCache: (element: IResultSetElementKey, resultIndex: number) => string | undefined;
@@ -16,7 +16,7 @@ import { NotificationService } from '@cloudbeaver/core-events';
import { useTranslate } from '@cloudbeaver/core-localization';
import { useStyles } from '@cloudbeaver/core-theming';
import type { TabContainerPanelComponent } from '@cloudbeaver/core-ui';
import { getMIME, isImageFormat, isValidUrl } from '@cloudbeaver/core-utils';
import { download, getMIME, isImageFormat, isValidUrl } from '@cloudbeaver/core-utils';
import { isResultSetContentValue, isResultSetContentValueTruncated } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetContentValue';
import { ResultSetDataKeysUtils } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetDataKeysUtils';
@@ -138,8 +138,11 @@ export const ImageValuePresentation: TabContainerPanelComponent<IDataValuePanelP
get savedSrc() {
return this.model.source.dataManager.retrieveFileDataUrlFromCache(this.selectedCell, this.resultIndex);
},
get content() {
return this.model.source.dataManager.isContent(this.selectedCell, this.resultIndex);
},
get canSave() {
return this.model.source.dataManager.canDownload(this.selectedCell, this.resultIndex);
return this.content || !!this.src;
},
get truncated() {
return isResultSetContentValue(this.cellValue) && isResultSetContentValueTruncated(this.cellValue);
@@ -150,9 +153,13 @@ export const ImageValuePresentation: TabContainerPanelComponent<IDataValuePanelP
},
async save() {
try {
await this.model.source.dataManager.downloadFileData(this.selectedCell, this.resultIndex);
} catch (exception) {
this.notificationService.logException(exception as any, 'data_viewer_presentation_value_content_download_error');
if (!this.content) {
download(this.src, '', true);
} else {
await this.model.source.dataManager.downloadFileData(this.selectedCell, this.resultIndex);
}
} catch (exception: any) {
this.notificationService.logException(exception, 'data_viewer_presentation_value_content_download_error');
}
},
}), {
@@ -170,12 +177,12 @@ export const ImageValuePresentation: TabContainerPanelComponent<IDataValuePanelP
const save = state.canSave ? state.save : undefined;
const loading = model.isLoading();
if (state.truncated && state.canSave && !state.savedSrc) {
if (state.truncated && !state.savedSrc) {
const load = async () => {
try {
await model.source.dataManager.resolveFileDataUrl(state.selectedCell, resultIndex);
} catch (exception) {
notificationService.logException(exception as any, 'data_viewer_presentation_value_content_download_error');
} catch (exception: any) {
notificationService.logException(exception, 'data_viewer_presentation_value_content_download_error');
}
};
@@ -155,7 +155,7 @@ export const TextValuePresentation: TabContainerPanelComponent<IDataValuePanelPr
const useCodeEditor = state.currentContentType !== 'text/plain';
const autoFormat = firstSelectedCell && !editor.isElementEdited(firstSelectedCell);
const canSave = firstSelectedCell && model.source.dataManager.canDownload(firstSelectedCell, resultIndex);
const canSave = firstSelectedCell && model.source.dataManager.isContent(firstSelectedCell, resultIndex);
return styled(style)(
<container>