mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 01:23:57 +00:00
switch database command
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
import FormSelectField from '../forms/FormSelectField.svelte';
|
import FormSelectField from '../forms/FormSelectField.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
import FormButton from '../forms/FormButton.svelte';
|
import FormButton from '../forms/FormButton.svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let editingData;
|
export let editingData;
|
||||||
export let savingTab;
|
export let savingTab;
|
||||||
@@ -29,8 +29,8 @@ import { apiCall } from '../utility/api';
|
|||||||
urlPath: _.kebabCase(_.deburr(savingTab.title)),
|
urlPath: _.kebabCase(_.deburr(savingTab.title)),
|
||||||
}
|
}
|
||||||
: editingData
|
: editingData
|
||||||
? _.pick(editingData, savedProperties)
|
? _.pick(editingData, savedProperties)
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
$: savedFile = savingTab && savingTab.props && savingTab.props.savedFile;
|
$: savedFile = savingTab && savingTab.props && savingTab.props.savedFile;
|
||||||
|
|
||||||
|
|||||||
61
packages/web/src/modals/SwitchDatabaseModal.svelte
Normal file
61
packages/web/src/modals/SwitchDatabaseModal.svelte
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
import getElectron from '../utility/getElectron';
|
||||||
|
import hasPermission from '../utility/hasPermission';
|
||||||
|
import localforage from 'localforage';
|
||||||
|
import ModalBase from './ModalBase.svelte';
|
||||||
|
import uuidv1 from 'uuid/v1';
|
||||||
|
import { closeCurrentModal } from './modalTools';
|
||||||
|
import { copyTextToClipboard } from '../utility/clipboard';
|
||||||
|
import FormProvider from '../forms/FormProvider.svelte';
|
||||||
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
|
import FormCheckboxField from '../forms/FormCheckboxField.svelte';
|
||||||
|
import FormValues from '../forms/FormValues.svelte';
|
||||||
|
import FormSelectField from '../forms/FormSelectField.svelte';
|
||||||
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
|
import FormButton from '../forms/FormButton.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
import FormConnectionSelect from '../impexp/FormConnectionSelect.svelte';
|
||||||
|
import FormDatabaseSelect from '../impexp/FormDatabaseSelect.svelte';
|
||||||
|
import { changeTab } from '../utility/common';
|
||||||
|
|
||||||
|
export let editingData;
|
||||||
|
export let callingTab;
|
||||||
|
|
||||||
|
const handleSubmit = async ev => {
|
||||||
|
const { conid, database } = ev.detail;
|
||||||
|
changeTab(callingTab.tabid, tab => ({
|
||||||
|
...tab,
|
||||||
|
props: {
|
||||||
|
...tab.props,
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
closeCurrentModal();
|
||||||
|
// console.log('SwitchDatabaseModal.handleSubmit', ev);
|
||||||
|
// changeTab(tabid, tab => ({ ...tab, busy }));
|
||||||
|
};
|
||||||
|
|
||||||
|
$: initialValues = {
|
||||||
|
conid: callingTab?.props?.conid,
|
||||||
|
database: callingTab?.props?.database,
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<FormProvider {initialValues}>
|
||||||
|
<ModalBase {...$$restProps}>
|
||||||
|
<svelte:fragment slot="header">Switch database</svelte:fragment>
|
||||||
|
|
||||||
|
<FormConnectionSelect name="conid" label="Server" direction="source" isNative />
|
||||||
|
<FormDatabaseSelect conidName="conid" name="database" label="Database" isNative />
|
||||||
|
|
||||||
|
<svelte:fragment slot="footer">
|
||||||
|
<FormValues let:values>
|
||||||
|
<FormSubmit value="OK" on:click={handleSubmit} />
|
||||||
|
<FormButton value="Cancel" on:click={closeCurrentModal} />
|
||||||
|
</FormValues>
|
||||||
|
</svelte:fragment>
|
||||||
|
</ModalBase>
|
||||||
|
</FormProvider>
|
||||||
@@ -292,6 +292,7 @@
|
|||||||
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
||||||
import TabCloseButton from '../elements/TabCloseButton.svelte';
|
import TabCloseButton from '../elements/TabCloseButton.svelte';
|
||||||
import CloseTabModal from '../modals/CloseTabModal.svelte';
|
import CloseTabModal from '../modals/CloseTabModal.svelte';
|
||||||
|
import SwitchDatabaseModal from '../modals/SwitchDatabaseModal.svelte';
|
||||||
|
|
||||||
export let multiTabIndex;
|
export let multiTabIndex;
|
||||||
export let shownTab;
|
export let shownTab;
|
||||||
@@ -304,8 +305,8 @@
|
|||||||
$currentDatabase && $currentDatabase.name && $currentDatabase.connection
|
$currentDatabase && $currentDatabase.name && $currentDatabase.connection
|
||||||
? `database://${$currentDatabase.name}-${$currentDatabase.connection._id}`
|
? `database://${$currentDatabase.name}-${$currentDatabase.connection._id}`
|
||||||
: $currentDatabase && $currentDatabase.connection
|
: $currentDatabase && $currentDatabase.connection
|
||||||
? `server://${$currentDatabase.connection._id}`
|
? `server://${$currentDatabase.connection._id}`
|
||||||
: '_no';
|
: '_no';
|
||||||
|
|
||||||
$: tabsWithDb = $openedTabs.filter(showTabFilterFunc).map(tab => ({
|
$: tabsWithDb = $openedTabs.filter(showTabFilterFunc).map(tab => ({
|
||||||
...tab,
|
...tab,
|
||||||
@@ -372,6 +373,16 @@
|
|||||||
onClick: () => showModal(FavoriteModal, { savingTab: tab }),
|
onClick: () => showModal(FavoriteModal, { savingTab: tab }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
tabComponent &&
|
||||||
|
tabs[tabComponent] &&
|
||||||
|
tabs[tabComponent].allowSwitchDatabase &&
|
||||||
|
tabs[tabComponent].allowSwitchDatabase(props) && [
|
||||||
|
{ divider: true },
|
||||||
|
{
|
||||||
|
text: 'Switch database',
|
||||||
|
onClick: () => showModal(SwitchDatabaseModal, { callingTab: tab }),
|
||||||
|
},
|
||||||
|
],
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
appobj &&
|
appobj &&
|
||||||
appobj.createAppObjectMenu &&
|
appobj.createAppObjectMenu &&
|
||||||
|
|||||||
@@ -51,6 +51,8 @@
|
|||||||
getCurrentEditor() != null && !getCurrentEditor()?.isBusy() && getCurrentEditor()?.hasConnection(),
|
getCurrentEditor() != null && !getCurrentEditor()?.isBusy() && getCurrentEditor()?.hasConnection(),
|
||||||
onClick: () => getCurrentEditor().executeCurrent(),
|
onClick: () => getCurrentEditor().executeCurrent(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const allowSwitchDatabase = props => true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -336,6 +338,15 @@
|
|||||||
|
|
||||||
const quickExportHandlerRef = createQuickExportHandlerRef();
|
const quickExportHandlerRef = createQuickExportHandlerRef();
|
||||||
|
|
||||||
|
$: {
|
||||||
|
conid;
|
||||||
|
database;
|
||||||
|
if (canKill()) {
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
errorMessages = [];
|
||||||
|
}
|
||||||
|
|
||||||
let isInitialized = false;
|
let isInitialized = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
export const matchingProps = ['conid', 'database', 'schemaName', 'pureName'];
|
export const matchingProps = ['conid', 'database', 'schemaName', 'pureName'];
|
||||||
export const allowAddToFavorites = props => true;
|
export const allowAddToFavorites = props => true;
|
||||||
|
export const allowSwitchDatabase = props => true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
export const matchingProps = ['conid', 'database', 'schemaName', 'pureName'];
|
export const matchingProps = ['conid', 'database', 'schemaName', 'pureName'];
|
||||||
export const allowAddToFavorites = props => true;
|
export const allowAddToFavorites = props => true;
|
||||||
|
export const allowSwitchDatabase = props => true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -8,9 +9,9 @@
|
|||||||
import { findEngineDriver } from 'dbgate-tools';
|
import { findEngineDriver } from 'dbgate-tools';
|
||||||
import { setContext } from 'svelte';
|
import { setContext } from 'svelte';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||||
|
|
||||||
import DataGrid from '../datagrid/DataGrid.svelte';
|
import DataGrid from '../datagrid/DataGrid.svelte';
|
||||||
import SqlDataGridCore from '../datagrid/SqlDataGridCore.svelte';
|
import SqlDataGridCore from '../datagrid/SqlDataGridCore.svelte';
|
||||||
|
|||||||
Reference in New Issue
Block a user