diff --git a/webapp/packages/core-localization/src/locales/en.ts b/webapp/packages/core-localization/src/locales/en.ts index 14498d138d..8984ff2217 100644 --- a/webapp/packages/core-localization/src/locales/en.ts +++ b/webapp/packages/core-localization/src/locales/en.ts @@ -92,6 +92,7 @@ export default [ ['ui_close_all_to_the_left', 'Close all to the Left'], ['ui_or', 'Or'], ['ui_download', 'Download'], + ['ui_download_file', 'Download file'], ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], @@ -103,6 +104,7 @@ export default [ ['ui_upload_file', 'Upload file'], ['ui_upload_files', 'Upload files'], ['ui_upload_files_duplicate_error', 'Files with the same name already exist'], + ['ui_upload_file_fail', 'Failed to upload file'], ['root_permission_denied', "You don't have permissions"], ['root_permission_no_permission', "You don't have permission for this action"], diff --git a/webapp/packages/core-localization/src/locales/it.ts b/webapp/packages/core-localization/src/locales/it.ts index 2c8a057faf..e960f7d9b9 100644 --- a/webapp/packages/core-localization/src/locales/it.ts +++ b/webapp/packages/core-localization/src/locales/it.ts @@ -76,6 +76,7 @@ export default [ ['ui_close_all_to_the_left', 'Close all to the Left'], ['ui_or', 'Or'], ['ui_download', 'Download'], + ['ui_download_file', 'Download file'], ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], @@ -87,6 +88,7 @@ export default [ ['ui_upload_file', 'Upload file'], ['ui_upload_files', 'Upload files'], ['ui_upload_files_duplicate_error', 'Files with the same name already exist'], + ['ui_upload_file_fail', 'Failed to upload file'], ['root_permission_denied', 'Non hai i permessi'], ['app_root_session_expire_warning_title', 'La sessione sta per scadere'], diff --git a/webapp/packages/core-localization/src/locales/ru.ts b/webapp/packages/core-localization/src/locales/ru.ts index a61d30fd4f..398af43e6b 100644 --- a/webapp/packages/core-localization/src/locales/ru.ts +++ b/webapp/packages/core-localization/src/locales/ru.ts @@ -88,6 +88,7 @@ export default [ ['ui_close_all_to_the_left', 'Закрыть все слева'], ['ui_or', 'Или'], ['ui_download', 'Cкачать'], + ['ui_download_file', 'Скачать файл'], ['ui_upload', 'Загрузить'], ['ui_import', 'Импортировать'], ['ui_view', 'Смотреть'], @@ -99,6 +100,7 @@ export default [ ['ui_upload_file', 'Загрузить файл'], ['ui_upload_files', 'Загрузить файлы'], ['ui_upload_files_duplicate_error', 'Файлы с такими именами уже существуют'], + ['ui_upload_file_fail', 'Не удалось загрузить файл'], ['root_permission_denied', 'Отказано в доступе'], ['root_permission_no_permission', 'У вас нет разрешения на это действие'], diff --git a/webapp/packages/core-localization/src/locales/zh.ts b/webapp/packages/core-localization/src/locales/zh.ts index dcd8b9e5a2..45b9f506ce 100644 --- a/webapp/packages/core-localization/src/locales/zh.ts +++ b/webapp/packages/core-localization/src/locales/zh.ts @@ -89,6 +89,7 @@ export default [ ['ui_close_all_to_the_left', 'Close all to the Left'], ['ui_or', 'Or'], ['ui_download', 'Download'], + ['ui_download_file', 'Download file'], ['ui_upload', 'Upload'], ['ui_import', 'Import'], ['ui_view', 'View'], @@ -100,6 +101,7 @@ export default [ ['ui_upload_file', 'Upload file'], ['ui_upload_files', 'Upload files'], ['ui_upload_files_duplicate_error', 'Files with the same name already exist'], + ['ui_upload_file_fail', 'Failed to upload file'], ['root_permission_denied', '您没有权限'], ['root_permission_no_permission', '您没有权限执行此操作'], diff --git a/webapp/packages/core-sdk/src/Extensions/uploadFileSystemEntityExtension.ts b/webapp/packages/core-sdk/src/Extensions/uploadFileSystemEntityExtension.ts new file mode 100644 index 0000000000..736719d23c --- /dev/null +++ b/webapp/packages/core-sdk/src/Extensions/uploadFileSystemEntityExtension.ts @@ -0,0 +1,32 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2023 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 { GlobalConstants } from '@cloudbeaver/core-utils'; + +import type { CustomGraphQLClient, UploadProgressEvent } from '../CustomGraphQLClient'; + +export interface IUploadFileSystemEntityExtension { + uploadFileSystemEntity: ( + parentURI: string, + projectId: string, + files: FileList, + onUploadProgress?: (event: UploadProgressEvent) => void, + ) => Promise; +} + +export function uploadFileSystemEntityExtension(client: CustomGraphQLClient): IUploadFileSystemEntityExtension { + return { + uploadFileSystemEntity( + parentURI: string, + projectId: string, + files: FileList, + onUploadProgress?: (event: UploadProgressEvent) => void, + ): Promise { + return client.uploadFiles(GlobalConstants.absoluteServiceUrl('fs-data'), files, undefined, { parentURI, projectId }, onUploadProgress); + }, + }; +} diff --git a/webapp/packages/core-sdk/src/GraphQLService.ts b/webapp/packages/core-sdk/src/GraphQLService.ts index b8eb8e9d7e..1ac629e5fc 100644 --- a/webapp/packages/core-sdk/src/GraphQLService.ts +++ b/webapp/packages/core-sdk/src/GraphQLService.ts @@ -11,6 +11,7 @@ import { CustomGraphQLClient } from './CustomGraphQLClient'; import { EnvironmentService } from './EnvironmentService'; import { uploadBlobResultSetExtension } from './Extensions/uploadBlobResultSetExtension'; import { uploadDriverLibraryExtension } from './Extensions/uploadDriverLibraryExtension'; +import { uploadFileSystemEntityExtension } from './Extensions/uploadFileSystemEntityExtension'; import type { IResponseInterceptor } from './IResponseInterceptor'; import { getSdk } from './sdk'; @@ -21,6 +22,7 @@ function extendedSDK(client: CustomGraphQLClient) { ...sdk, ...uploadDriverLibraryExtension(client), ...uploadBlobResultSetExtension(client), + ...uploadFileSystemEntityExtension(client), }; } diff --git a/webapp/packages/core-view/src/Action/Actions/ACTION_DOWNLOAD.ts b/webapp/packages/core-view/src/Action/Actions/ACTION_DOWNLOAD.ts new file mode 100644 index 0000000000..931afffec5 --- /dev/null +++ b/webapp/packages/core-view/src/Action/Actions/ACTION_DOWNLOAD.ts @@ -0,0 +1,13 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2023 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 { createAction } from '../createAction'; + +export const ACTION_DOWNLOAD = createAction('download', { + label: 'ui_download', + icon: '/icons/export.svg', +}); diff --git a/webapp/packages/core-view/src/Action/Actions/ACTION_UPLOAD.ts b/webapp/packages/core-view/src/Action/Actions/ACTION_UPLOAD.ts new file mode 100644 index 0000000000..437a5671a8 --- /dev/null +++ b/webapp/packages/core-view/src/Action/Actions/ACTION_UPLOAD.ts @@ -0,0 +1,13 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2023 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 { createAction } from '../createAction'; + +export const ACTION_UPLOAD = createAction('upload', { + label: 'ui_upload', + icon: '/icons/import.svg', +}); diff --git a/webapp/packages/core-view/src/index.ts b/webapp/packages/core-view/src/index.ts index 197185f995..ce0e214a88 100644 --- a/webapp/packages/core-view/src/index.ts +++ b/webapp/packages/core-view/src/index.ts @@ -16,6 +16,8 @@ export * from './Action/Actions/ACTION_SETTINGS'; export * from './Action/Actions/ACTION_UNDO'; export * from './Action/Actions/ACTION_ZOOM_IN'; export * from './Action/Actions/ACTION_ZOOM_OUT'; +export * from './Action/Actions/ACTION_DOWNLOAD'; +export * from './Action/Actions/ACTION_UPLOAD'; export * from './Action/KeyBinding/Bindings/KEY_BINDING_OPEN_IN_TAB'; export * from './Action/KeyBinding/Bindings/KEY_BINDING_REDO'; export * from './Action/KeyBinding/Bindings/KEY_BINDING_UNDO';