From 8aac9cf59d7c79f23d7465aae18dc23c31f34d16 Mon Sep 17 00:00:00 2001 From: "SPRINX0\\prochazka" Date: Fri, 20 Sep 2024 14:40:14 +0200 Subject: [PATCH] loading schemas indicator + error reporting --- .../api/src/proc/databaseConnectionProcess.js | 1 + .../web/src/appobj/DatabaseAppObject.svelte | 18 +++++++++++++++- .../web/src/impexp/FormSchemaSelect.svelte | 3 ++- packages/web/src/stores.ts | 1 + packages/web/src/utility/common.ts | 21 +++++++++++++++++-- packages/web/src/widgets/SqlObjectList.svelte | 4 ++-- .../dbgate-plugin-mssql/src/backend/driver.js | 2 ++ .../src/backend/drivers.js | 2 ++ 8 files changed, 46 insertions(+), 6 deletions(-) diff --git a/packages/api/src/proc/databaseConnectionProcess.js b/packages/api/src/proc/databaseConnectionProcess.js index 702b968d..7ca93323 100644 --- a/packages/api/src/proc/databaseConnectionProcess.js +++ b/packages/api/src/proc/databaseConnectionProcess.js @@ -214,6 +214,7 @@ async function handleDriverDataCore(msgid, callMethod) { } async function handleSchemaList({ msgid }) { + logger.debug('Loading schema list'); return handleDriverDataCore(msgid, driver => driver.listSchemas(dbhan)); } diff --git a/packages/web/src/appobj/DatabaseAppObject.svelte b/packages/web/src/appobj/DatabaseAppObject.svelte index 120577e7..7285f8b6 100644 --- a/packages/web/src/appobj/DatabaseAppObject.svelte +++ b/packages/web/src/appobj/DatabaseAppObject.svelte @@ -262,6 +262,17 @@ }); }; + const handleRefreshSchemas = () => { + const conid = connection._id; + const database = name; + apiCall('database-connections/dispatch-database-changed-event', { + event: 'schema-list-changed', + conid, + database, + }); + loadSchemaList(conid, database); + }; + async function handleConfirmSql(sql) { saveScriptToDatabase({ conid: connection._id, database: name }, sql, false); } @@ -290,6 +301,8 @@ onClick: handleNewPerspective, text: 'Design perspective query', }, + connection.useSeparateSchemas && { onClick: handleRefreshSchemas, text: 'Refresh schemas' }, + { divider: true }, isSqlOrDoc && !connection.isReadOnly && @@ -364,6 +377,7 @@ getCurrentDatabase, getExtensions, getOpenedTabs, + loadingSchemaLists, openedConnections, openedSingleDatabaseConnections, pinnedDatabases, @@ -391,7 +405,7 @@ import hasPermission from '../utility/hasPermission'; import { openImportExportTab } from '../utility/importExportTools'; import newTable from '../tableeditor/newTable'; - import { switchCurrentDatabase } from '../utility/common'; + import { loadSchemaList, switchCurrentDatabase } from '../utility/common'; export let data; export let passProps; @@ -409,6 +423,7 @@ $: isPinned = !!$pinnedDatabases.find(x => x?.name == data.name && x?.connection?._id == data.connection?._id); $: apps = useUsedApps(); + $: isLoadingSchemas = $loadingSchemaLists[`${data?.connection?._id}::${data?.name}`]; x.isNewQuery) .onClick(); }} + statusIcon={isLoadingSchemas ? 'icon loading' : ''} menu={createMenu} showPinnedInsteadOfUnpin={passProps?.showPinnedInsteadOfUnpin} onPin={isPinned ? null : () => pinnedDatabases.update(list => [...list, data])} diff --git a/packages/web/src/impexp/FormSchemaSelect.svelte b/packages/web/src/impexp/FormSchemaSelect.svelte index bcc6c757..049fdad7 100644 --- a/packages/web/src/impexp/FormSchemaSelect.svelte +++ b/packages/web/src/impexp/FormSchemaSelect.svelte @@ -1,4 +1,5 @@