mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 18:34:01 +00:00
single database fixes
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
database: connection.defaultDatabase,
|
database: connection.defaultDatabase,
|
||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
});
|
});
|
||||||
|
openedSingleDatabaseConnections.update(x => _.uniq([...x, connection._id]));
|
||||||
} else {
|
} else {
|
||||||
openedConnections.update(x => _.uniq([...x, connection._id]));
|
openedConnections.update(x => _.uniq([...x, connection._id]));
|
||||||
apiCall('server-connections/refresh', {
|
apiCall('server-connections/refresh', {
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
getCurrentConfig,
|
getCurrentConfig,
|
||||||
getOpenedConnections,
|
getOpenedConnections,
|
||||||
openedConnections,
|
openedConnections,
|
||||||
|
openedSingleDatabaseConnections,
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
import { filterName } from 'dbgate-tools';
|
import { filterName } from 'dbgate-tools';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
@@ -55,6 +57,7 @@
|
|||||||
import { apiCall } from '../utility/api';
|
import { apiCall } 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';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -72,10 +75,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenConnectionTab = () => {
|
const handleOpenConnectionTab = () => {
|
||||||
if ($openedConnections.includes(data._id)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: getConnectionLabel(data),
|
title: getConnectionLabel(data),
|
||||||
icon: 'img connection',
|
icon: 'img connection',
|
||||||
@@ -86,6 +85,18 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
if ($openedSingleDatabaseConnections.includes(data._id)) {
|
||||||
|
currentDatabase.set({ connection: data, name: data.defaultDatabase });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($openedConnections.includes(data._id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpenConnectionTab();
|
||||||
|
};
|
||||||
|
|
||||||
const handleSqlRestore = () => {
|
const handleSqlRestore = () => {
|
||||||
showModal(ImportDatabaseDumpModal, {
|
showModal(ImportDatabaseDumpModal, {
|
||||||
connection: data,
|
connection: data,
|
||||||
@@ -198,7 +209,14 @@
|
|||||||
],
|
],
|
||||||
data.singleDatabase && [
|
data.singleDatabase && [
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
getDatabaseMenuItems(data, data.defaultDatabase, $extensions, $currentDatabase, $apps),
|
getDatabaseMenuItems(
|
||||||
|
data,
|
||||||
|
data.defaultDatabase,
|
||||||
|
$extensions,
|
||||||
|
$currentDatabase,
|
||||||
|
$apps,
|
||||||
|
$openedSingleDatabaseConnections
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
driver?.databaseEngineTypes?.includes('sql') && { onClick: handleSqlRestore, text: 'Restore/import SQL dump' },
|
driver?.databaseEngineTypes?.includes('sql') && { onClick: handleSqlRestore, text: 'Restore/import SQL dump' },
|
||||||
@@ -251,7 +269,7 @@
|
|||||||
{extInfo}
|
{extInfo}
|
||||||
colorMark={passProps?.connectionColorFactory && passProps?.connectionColorFactory({ conid: data._id })}
|
colorMark={passProps?.connectionColorFactory && passProps?.connectionColorFactory({ conid: data._id })}
|
||||||
menu={getContextMenu}
|
menu={getContextMenu}
|
||||||
on:click={handleOpenConnectionTab}
|
on:click={handleClick}
|
||||||
on:click
|
on:click
|
||||||
on:expand
|
on:expand
|
||||||
on:dblclick={handleConnect}
|
on:dblclick={handleConnect}
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
export const extractKey = props => props.name;
|
export const extractKey = props => props.name;
|
||||||
|
|
||||||
export function getDatabaseMenuItems(connection, name, $extensions, $currentDatabase, $apps) {
|
export function getDatabaseMenuItems(
|
||||||
|
connection,
|
||||||
|
name,
|
||||||
|
$extensions,
|
||||||
|
$currentDatabase,
|
||||||
|
$apps,
|
||||||
|
$openedSingleDatabaseConnections
|
||||||
|
) {
|
||||||
const apps = filterAppsForDatabase(connection, name, $apps);
|
const apps = filterAppsForDatabase(connection, name, $apps);
|
||||||
const handleNewQuery = () => {
|
const handleNewQuery = () => {
|
||||||
const tooltip = `${getConnectionLabel(connection)}\n${name}`;
|
const tooltip = `${getConnectionLabel(connection)}\n${name}`;
|
||||||
@@ -132,7 +139,10 @@
|
|||||||
if (electron) {
|
if (electron) {
|
||||||
apiCall('database-connections/disconnect', { conid: connection._id, database: name });
|
apiCall('database-connections/disconnect', { conid: connection._id, database: name });
|
||||||
}
|
}
|
||||||
currentDatabase.set(null);
|
if (getCurrentDatabase()?.connection?._id == connection._id && getCurrentDatabase()?.name == name) {
|
||||||
|
currentDatabase.set(null);
|
||||||
|
}
|
||||||
|
openedSingleDatabaseConnections.update(list => list.filter(x => x != connection._id));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExportModel = async () => {
|
const handleExportModel = async () => {
|
||||||
@@ -233,8 +243,9 @@
|
|||||||
|
|
||||||
driver?.databaseEngineTypes?.includes('keyvalue') && { onClick: handleGenerateScript, text: 'Generate script' },
|
driver?.databaseEngineTypes?.includes('keyvalue') && { onClick: handleGenerateScript, text: 'Generate script' },
|
||||||
|
|
||||||
_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
|
($openedSingleDatabaseConnections.includes(connection._id) ||
|
||||||
_.get($currentDatabase, 'name') == name && { onClick: handleDisconnect, text: 'Disconnect' },
|
(_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
|
||||||
|
_.get($currentDatabase, 'name') == name)) && { onClick: handleDisconnect, text: 'Disconnect' },
|
||||||
|
|
||||||
commands.length > 0 && [
|
commands.length > 0 && [
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
@@ -266,7 +277,10 @@
|
|||||||
currentArchive,
|
currentArchive,
|
||||||
currentDatabase,
|
currentDatabase,
|
||||||
extensions,
|
extensions,
|
||||||
|
getCurrentDatabase,
|
||||||
getExtensions,
|
getExtensions,
|
||||||
|
openedConnections,
|
||||||
|
openedSingleDatabaseConnections,
|
||||||
pinnedDatabases,
|
pinnedDatabases,
|
||||||
selectedWidget,
|
selectedWidget,
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
@@ -285,13 +299,20 @@
|
|||||||
import newQuery from '../query/newQuery';
|
import newQuery from '../query/newQuery';
|
||||||
import { exportSqlDump } from '../utility/exportFileTools';
|
import { exportSqlDump } from '../utility/exportFileTools';
|
||||||
import ImportDatabaseDumpModal from '../modals/ImportDatabaseDumpModal.svelte';
|
import ImportDatabaseDumpModal from '../modals/ImportDatabaseDumpModal.svelte';
|
||||||
import ExportDatabaseDumpModal from '../modals/ExportDatabaseDumpModal.svelte';
|
import ExportDatabaseDumpModal from '../modals/ExportDatabaseDumpModal.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
|
|
||||||
function createMenu() {
|
function createMenu() {
|
||||||
return getDatabaseMenuItems(data.connection, data.name, $extensions, $currentDatabase, $apps);
|
return getDatabaseMenuItems(
|
||||||
|
data.connection,
|
||||||
|
data.name,
|
||||||
|
$extensions,
|
||||||
|
$currentDatabase,
|
||||||
|
$apps,
|
||||||
|
$openedSingleDatabaseConnections
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$: isPinned = !!$pinnedDatabases.find(x => x.name == data.name && x.connection?._id == data.connection?._id);
|
$: isPinned = !!$pinnedDatabases.find(x => x.name == data.name && x.connection?._id == data.connection?._id);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ function subscribeCssVariable(store, transform, cssVariable) {
|
|||||||
|
|
||||||
export const selectedWidget = writableWithStorage('database', 'selectedWidget');
|
export const selectedWidget = writableWithStorage('database', 'selectedWidget');
|
||||||
export const openedConnections = writable([]);
|
export const openedConnections = writable([]);
|
||||||
|
export const openedSingleDatabaseConnections = writable([]);
|
||||||
export const expandedConnections = writable([]);
|
export const expandedConnections = writable([]);
|
||||||
export const currentDatabase = writable(null);
|
export const currentDatabase = writable(null);
|
||||||
export const openedTabs = writableWithStorage<TabDefinition[]>([], 'openedTabs');
|
export const openedTabs = writableWithStorage<TabDefinition[]>([], 'openedTabs');
|
||||||
@@ -188,8 +189,12 @@ let currentDatabaseValue = null;
|
|||||||
currentDatabase.subscribe(value => {
|
currentDatabase.subscribe(value => {
|
||||||
currentDatabaseValue = value;
|
currentDatabaseValue = value;
|
||||||
if (value?.connection?._id) {
|
if (value?.connection?._id) {
|
||||||
openedConnections.update(x => _.uniq([...x, value?.connection?._id]));
|
if (value?.connection?.singleDatabase) {
|
||||||
expandedConnections.update(x => _.uniq([...x, value?.connection?._id]));
|
openedSingleDatabaseConnections.update(x => _.uniq([...x, value?.connection?._id]));
|
||||||
|
} else {
|
||||||
|
openedConnections.update(x => _.uniq([...x, value?.connection?._id]));
|
||||||
|
expandedConnections.update(x => _.uniq([...x, value?.connection?._id]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
invalidateCommands();
|
invalidateCommands();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ let lastCurrentTab = null;
|
|||||||
openedTabs.subscribe(value => {
|
openedTabs.subscribe(value => {
|
||||||
const newCurrentTab = (value || []).find(x => x.selected);
|
const newCurrentTab = (value || []).find(x => x.selected);
|
||||||
if (newCurrentTab == lastCurrentTab) return;
|
if (newCurrentTab == lastCurrentTab) return;
|
||||||
|
if (lastCurrentTab?.tabComponent == 'ConnectionTab') return;
|
||||||
|
|
||||||
if (newCurrentTab) {
|
if (newCurrentTab) {
|
||||||
const { conid, database } = newCurrentTab.props || {};
|
const { conid, database } = newCurrentTab.props || {};
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { openedConnections, currentDatabase } from '../stores';
|
import { openedConnections, currentDatabase } from '../stores';
|
||||||
import { apiCall } from './api';
|
import { apiCall } from './api';
|
||||||
|
import { getConnectionList } from './metadataLoaders';
|
||||||
|
|
||||||
|
// const doServerPing = async value => {
|
||||||
|
// const connectionList = getConnectionList();
|
||||||
|
// const connections = value.filter(id => !connectionList.find(x => x._id == id)?.singleDatabase);
|
||||||
|
// apiCall('server-connections/ping', { connections });
|
||||||
|
// };
|
||||||
|
|
||||||
const doServerPing = value => {
|
const doServerPing = value => {
|
||||||
apiCall('server-connections/ping', { connections: value });
|
apiCall('server-connections/ping', { connections: value });
|
||||||
|
|||||||
Reference in New Issue
Block a user