mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 09:24:00 +00:00
disconnect command
This commit is contained in:
@@ -21,6 +21,7 @@ module.exports = ({ editMenu }) => [
|
|||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ command: 'file.exit', hideDisabled: true },
|
{ command: 'file.exit', hideDisabled: true },
|
||||||
{ command: 'app.logout', hideDisabled: true, skipInApp: true },
|
{ command: 'app.logout', hideDisabled: true, skipInApp: true },
|
||||||
|
{ command: 'app.disconnect', hideDisabled: true, skipInApp: true },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
6
packages/api/env/dblogin/.env
vendored
6
packages/api/env/dblogin/.env
vendored
@@ -6,9 +6,9 @@ SINGLE_CONNECTION=mysql
|
|||||||
|
|
||||||
LABEL_mysql=MySql localhost
|
LABEL_mysql=MySql localhost
|
||||||
SERVER_mysql=localhost
|
SERVER_mysql=localhost
|
||||||
USER_mysql=root
|
# USER_mysql=root
|
||||||
PORT_mysql=3306
|
PORT_mysql=3306
|
||||||
PASSWORD_mysql=Pwd2020Db
|
# PASSWORD_mysql=Pwd2020Db
|
||||||
ENGINE_mysql=mysql@dbgate-plugin-mysql
|
ENGINE_mysql=mysql@dbgate-plugin-mysql
|
||||||
# PASSWORD_MODE_mysql=askPassword
|
# PASSWORD_MODE_mysql=askPassword
|
||||||
# PASSWORD_MODE_mysql=askUser
|
PASSWORD_MODE_mysql=askUser
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
const currentDb = getCurrentDatabase();
|
const currentDb = getCurrentDatabase();
|
||||||
openedConnections.update(list => list.filter(x => x != conid));
|
openedConnections.update(list => list.filter(x => x != conid));
|
||||||
|
removeVolatileMapping(conid);
|
||||||
if (electron) {
|
if (electron) {
|
||||||
apiCall('server-connections/disconnect', { conid });
|
apiCall('server-connections/disconnect', { conid });
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
import { getDatabaseList, useUsedApps } from '../utility/metadataLoaders';
|
import { getDatabaseList, useUsedApps } from '../utility/metadataLoaders';
|
||||||
import { getLocalStorage } from '../utility/storageCache';
|
import { getLocalStorage } from '../utility/storageCache';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall, removeVolatileMapping } from '../utility/api';
|
||||||
import ImportDatabaseDumpModal from '../modals/ImportDatabaseDumpModal.svelte';
|
import ImportDatabaseDumpModal from '../modals/ImportDatabaseDumpModal.svelte';
|
||||||
import { closeMultipleTabs } from '../widgets/TabsPanel.svelte';
|
import { closeMultipleTabs } from '../widgets/TabsPanel.svelte';
|
||||||
import AboutModal from '../modals/AboutModal.svelte';
|
import AboutModal from '../modals/AboutModal.svelte';
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import { openWebLink } from '../utility/exportFileTools';
|
|||||||
import { getSettings } from '../utility/metadataLoaders';
|
import { getSettings } from '../utility/metadataLoaders';
|
||||||
import { isMac } from '../utility/common';
|
import { isMac } from '../utility/common';
|
||||||
import { doLogout, internalRedirectTo } from '../clientAuth';
|
import { doLogout, internalRedirectTo } from '../clientAuth';
|
||||||
|
import { disconnectServerConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||||
|
|
||||||
// function themeCommand(theme: ThemeDefinition) {
|
// function themeCommand(theme: ThemeDefinition) {
|
||||||
// return {
|
// return {
|
||||||
@@ -552,6 +553,14 @@ registerCommand({
|
|||||||
onClick: doLogout,
|
onClick: doLogout,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'app.disconnect',
|
||||||
|
category: 'App',
|
||||||
|
name: 'Disconnect',
|
||||||
|
testEnabled: () => getCurrentConfig()?.singleConnection != null,
|
||||||
|
onClick: () => disconnectServerConnection(getCurrentConfig()?.singleConnection?._id),
|
||||||
|
});
|
||||||
|
|
||||||
export function registerFileCommands({
|
export function registerFileCommands({
|
||||||
idPrefix,
|
idPrefix,
|
||||||
category,
|
category,
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ export function getVolatileRemappingInv(conid) {
|
|||||||
return volatileConnectionMapInv[conid] || conid;
|
return volatileConnectionMapInv[conid] || conid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeVolatileMapping(conid) {
|
||||||
|
const mapped = volatileConnectionMap[conid];
|
||||||
|
if (mapped) {
|
||||||
|
delete volatileConnectionMap[conid];
|
||||||
|
delete volatileConnectionMapInv[mapped];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function wantEventSource() {
|
function wantEventSource() {
|
||||||
if (!eventSource) {
|
if (!eventSource) {
|
||||||
eventSource = new EventSource(`${resolveApi()}/stream`);
|
eventSource = new EventSource(`${resolveApi()}/stream`);
|
||||||
|
|||||||
Reference in New Issue
Block a user