mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 16:53:58 +00:00
refresh database options
This commit is contained in:
@@ -3,7 +3,7 @@ import { currentDatabase, getCurrentDatabase } from '../stores';
|
|||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import registerCommand from './registerCommand';
|
import registerCommand from './registerCommand';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { switchCurrentDatabase } from '../utility/common';
|
import { getDatabasStatusMenu, switchCurrentDatabase } from '../utility/common';
|
||||||
import { __t } from '../translations';
|
import { __t } from '../translations';
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
@@ -18,33 +18,7 @@ registerCommand({
|
|||||||
conid: connection._id,
|
conid: connection._id,
|
||||||
database: name,
|
database: name,
|
||||||
};
|
};
|
||||||
return [
|
|
||||||
{
|
return getDatabasStatusMenu(dbid);
|
||||||
text: 'Sync model (incremental)',
|
|
||||||
onClick: () => {
|
|
||||||
apiCall('database-connections/sync-model', dbid);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Sync model (full)',
|
|
||||||
onClick: () => {
|
|
||||||
apiCall('database-connections/sync-model', { ...dbid, isFullRefresh: true });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Reopen',
|
|
||||||
onClick: () => {
|
|
||||||
apiCall('database-connections/refresh', dbid);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Disconnect',
|
|
||||||
onClick: () => {
|
|
||||||
const electron = getElectron();
|
|
||||||
if (electron) apiCall('database-connections/disconnect', dbid);
|
|
||||||
switchCurrentDatabase(null);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import _ from 'lodash';
|
|||||||
import { getSchemaList } from './metadataLoaders';
|
import { getSchemaList } from './metadataLoaders';
|
||||||
import { showSnackbarError } from './snackbar';
|
import { showSnackbarError } from './snackbar';
|
||||||
import { _t } from '../translations';
|
import { _t } from '../translations';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
import getElectron from './getElectron';
|
||||||
|
|
||||||
export class LoadingToken {
|
export class LoadingToken {
|
||||||
isCanceled = false;
|
isCanceled = false;
|
||||||
@@ -63,7 +65,8 @@ export function getObjectTypeFieldLabel(objectTypeField, driver?) {
|
|||||||
if (objectTypeField == 'procedures') return _t('dbObject.procedures', { defaultMessage: 'Procedures' });
|
if (objectTypeField == 'procedures') return _t('dbObject.procedures', { defaultMessage: 'Procedures' });
|
||||||
if (objectTypeField == 'functions') return _t('dbObject.functions', { defaultMessage: 'Functions' });
|
if (objectTypeField == 'functions') return _t('dbObject.functions', { defaultMessage: 'Functions' });
|
||||||
if (objectTypeField == 'triggers') return _t('dbObject.triggers', { defaultMessage: 'Triggers' });
|
if (objectTypeField == 'triggers') return _t('dbObject.triggers', { defaultMessage: 'Triggers' });
|
||||||
if (objectTypeField == 'schedulerEvents') return _t('dbObject.schedulerEvents', { defaultMessage: 'Scheduler Events' });
|
if (objectTypeField == 'schedulerEvents')
|
||||||
|
return _t('dbObject.schedulerEvents', { defaultMessage: 'Scheduler Events' });
|
||||||
if (objectTypeField == 'matviews') return _t('dbObject.matviews', { defaultMessage: 'Materialized Views' });
|
if (objectTypeField == 'matviews') return _t('dbObject.matviews', { defaultMessage: 'Materialized Views' });
|
||||||
if (objectTypeField == 'collections') return _t('dbObject.collections', { defaultMessage: 'Collections/Containers' });
|
if (objectTypeField == 'collections') return _t('dbObject.collections', { defaultMessage: 'Collections/Containers' });
|
||||||
return _.startCase(objectTypeField);
|
return _.startCase(objectTypeField);
|
||||||
@@ -151,3 +154,40 @@ export function getKeyTextFromEvent(e) {
|
|||||||
keyText += e.key;
|
keyText += e.key;
|
||||||
return keyText;
|
return keyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDatabasStatusMenu(dbid) {
|
||||||
|
function callSchemalListChanged() {
|
||||||
|
apiCall('database-connections/dispatch-database-changed-event', { event: 'schema-list-changed', ...dbid });
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
text: 'Refresh DB structure (incremental)',
|
||||||
|
onClick: () => {
|
||||||
|
apiCall('database-connections/sync-model', dbid);
|
||||||
|
callSchemalListChanged();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Refresh DB structure (full)',
|
||||||
|
onClick: () => {
|
||||||
|
apiCall('database-connections/sync-model', { ...dbid, isFullRefresh: true });
|
||||||
|
callSchemalListChanged();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Reopen connection',
|
||||||
|
onClick: () => {
|
||||||
|
apiCall('database-connections/refresh', dbid);
|
||||||
|
callSchemalListChanged();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Disconnect',
|
||||||
|
onClick: () => {
|
||||||
|
const electron = getElectron();
|
||||||
|
if (electron) apiCall('database-connections/disconnect', dbid);
|
||||||
|
switchCurrentDatabase(null);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
import { chevronExpandIcon } from '../icons/expandIcons';
|
import { chevronExpandIcon } from '../icons/expandIcons';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
import { getObjectTypeFieldLabel } from '../utility/common';
|
import { getDatabasStatusMenu, getObjectTypeFieldLabel } from '../utility/common';
|
||||||
import DropDownButton from '../buttons/DropDownButton.svelte';
|
import DropDownButton from '../buttons/DropDownButton.svelte';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||||
@@ -120,11 +120,6 @@
|
|||||||
// setInterval(() => (generateIndex += 1), 2000);
|
// setInterval(() => (generateIndex += 1), 2000);
|
||||||
// $: objectList = generateObjectList(generateIndex);
|
// $: objectList = generateObjectList(generateIndex);
|
||||||
|
|
||||||
const handleRefreshDatabase = () => {
|
|
||||||
apiCall('database-connections/refresh', { conid, database });
|
|
||||||
apiCall('database-connections/dispatch-database-changed-event', { event: 'schema-list-changed', conid, database });
|
|
||||||
};
|
|
||||||
|
|
||||||
function createAddMenu() {
|
function createAddMenu() {
|
||||||
const res = [];
|
const res = [];
|
||||||
if (driver?.databaseEngineTypes?.includes('document')) {
|
if (driver?.databaseEngineTypes?.includes('document')) {
|
||||||
@@ -147,6 +142,15 @@
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createRefreshDatabaseMenu() {
|
||||||
|
return getDatabasStatusMenu({ conid, database });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFullRefreshDatabase() {
|
||||||
|
apiCall('database-connections/sync-model', { conid, database, isFullRefresh: true });
|
||||||
|
apiCall('database-connections/dispatch-database-changed-event', { event: 'schema-list-changed', conid, database });
|
||||||
|
}
|
||||||
|
|
||||||
function createSearchMenu() {
|
function createSearchMenu() {
|
||||||
const res = [];
|
const res = [];
|
||||||
res.push({ label: _t('sqlObject.searchBy', { defaultMessage: 'Search by:' }), isBold: true, disabled: true });
|
res.push({ label: _t('sqlObject.searchBy', { defaultMessage: 'Search by:' }), isBold: true, disabled: true });
|
||||||
@@ -237,7 +241,18 @@
|
|||||||
|
|
||||||
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
||||||
<ErrorInfo message={$status.message} icon="img error" />
|
<ErrorInfo message={$status.message} icon="img error" />
|
||||||
<InlineButton on:click={handleRefreshDatabase}>{_t('common.refresh', { defaultMessage: 'Refresh' })}</InlineButton>
|
<InlineButton on:click={handleFullRefreshDatabase}
|
||||||
|
>{_t('common.refresh', { defaultMessage: 'Refresh' })}</InlineButton
|
||||||
|
>
|
||||||
|
|
||||||
|
<DropDownButton
|
||||||
|
menu={createRefreshDatabaseMenu}
|
||||||
|
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: 'Refresh database connection and object list' })}
|
||||||
|
square
|
||||||
|
narrow={false}
|
||||||
|
data-testid="SqlObjectList_refreshButton"
|
||||||
|
icon="icon dots-vertical"
|
||||||
|
/>
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
{:else if objectList.length == 0 && $status && $status.name != 'pending' && $status.name != 'checkStructure' && $status.name != 'loadStructure' && $objects}
|
{:else if objectList.length == 0 && $status && $status.name != 'pending' && $status.name != 'checkStructure' && $status.name != 'loadStructure' && $objects}
|
||||||
<SchemaSelector
|
<SchemaSelector
|
||||||
@@ -298,14 +313,14 @@
|
|||||||
{#if !filter}
|
{#if !filter}
|
||||||
<DropDownButton icon="icon plus-thick" menu={createAddMenu} />
|
<DropDownButton icon="icon plus-thick" menu={createAddMenu} />
|
||||||
{/if}
|
{/if}
|
||||||
<InlineButton
|
<DropDownButton
|
||||||
on:click={handleRefreshDatabase}
|
menu={createRefreshDatabaseMenu}
|
||||||
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: 'Refresh database connection and object list' })}
|
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: 'Refresh database connection and object list' })}
|
||||||
square
|
square
|
||||||
|
narrow={false}
|
||||||
data-testid="SqlObjectList_refreshButton"
|
data-testid="SqlObjectList_refreshButton"
|
||||||
>
|
icon="icon dots-vertical"
|
||||||
<FontIcon icon="icon refresh" />
|
/>
|
||||||
</InlineButton>
|
|
||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<SchemaSelector
|
<SchemaSelector
|
||||||
schemaList={_.isArray($schemaList) ? $schemaList : null}
|
schemaList={_.isArray($schemaList) ? $schemaList : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user