mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 05:26:00 +00:00
refresh schema list
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
return res;
|
||||
}
|
||||
|
||||
$: schemaList = _.uniq(
|
||||
$: realSchemaList = _.uniq(
|
||||
_.compact([selectedSchema, ...Object.keys(countBySchema), ...(schemaList?.map(x => x.schemaName) ?? [])])
|
||||
);
|
||||
$: countBySchema = computeCountBySchema(objectList ?? []);
|
||||
@@ -54,10 +54,14 @@
|
||||
label: 'Schema name',
|
||||
onConfirm: async name => {
|
||||
const dbid = { conid, database };
|
||||
await runOperationOnDatabase(dbid, {
|
||||
type: 'createSchema',
|
||||
schemaName: name,
|
||||
});
|
||||
await runOperationOnDatabase(
|
||||
dbid,
|
||||
{
|
||||
type: 'createSchema',
|
||||
schemaName: name,
|
||||
},
|
||||
'schema-list-changed'
|
||||
);
|
||||
if (selectedSchema) {
|
||||
selectedSchema = name;
|
||||
}
|
||||
@@ -69,10 +73,14 @@
|
||||
message: `Really drop schema ${$appliedCurrentSchema}?`,
|
||||
onConfirm: async () => {
|
||||
const dbid = { conid, database };
|
||||
runOperationOnDatabase(dbid, {
|
||||
type: 'dropSchema',
|
||||
schemaName: $appliedCurrentSchema,
|
||||
});
|
||||
runOperationOnDatabase(
|
||||
dbid,
|
||||
{
|
||||
type: 'dropSchema',
|
||||
schemaName: $appliedCurrentSchema,
|
||||
},
|
||||
'schema-list-changed'
|
||||
);
|
||||
selectedSchema = null;
|
||||
},
|
||||
});
|
||||
@@ -81,14 +89,14 @@
|
||||
$: selectedSchema = localStorage.getItem(valueStorageKey ?? '');
|
||||
</script>
|
||||
|
||||
{#if schemaList.length > 0}
|
||||
{#if realSchemaList.length > 0}
|
||||
<div class="wrapper">
|
||||
<div class="mr-1">Schema:</div>
|
||||
<SelectField
|
||||
isNative
|
||||
options={[
|
||||
{ label: `All schemas (${objectList?.length ?? 0})`, value: '' },
|
||||
...schemaList.map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
|
||||
...realSchemaList.map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
|
||||
// ...schemaList.filter(x => countBySchema[x]).map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
|
||||
// ...schemaList.filter(x => !countBySchema[x]).map(x => ({ label: `${x} (${countBySchema[x] ?? 0})`, value: x })),
|
||||
]}
|
||||
|
||||
@@ -16,7 +16,13 @@
|
||||
import InlineButton from '../buttons/InlineButton.svelte';
|
||||
import SearchInput from '../elements/SearchInput.svelte';
|
||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||
import { useConnectionInfo, useDatabaseInfo, useDatabaseStatus, useSchemaList, useUsedApps } from '../utility/metadataLoaders';
|
||||
import {
|
||||
useConnectionInfo,
|
||||
useDatabaseInfo,
|
||||
useDatabaseStatus,
|
||||
useSchemaList,
|
||||
useUsedApps,
|
||||
} from '../utility/metadataLoaders';
|
||||
import SearchBoxWrapper from '../elements/SearchBoxWrapper.svelte';
|
||||
import AppObjectList from '../appobj/AppObjectList.svelte';
|
||||
import _ from 'lodash';
|
||||
@@ -80,6 +86,7 @@
|
||||
|
||||
const handleRefreshDatabase = () => {
|
||||
apiCall('database-connections/refresh', { conid, database });
|
||||
apiCall('database-connections/dispatch-database-changed-event', { event: 'schema-list-changed', conid, database });
|
||||
};
|
||||
|
||||
function createAddMenu() {
|
||||
|
||||
Reference in New Issue
Block a user