mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 12:43:58 +00:00
focused connection widget
This commit is contained in:
@@ -942,6 +942,14 @@ registerCommand({
|
|||||||
onClick: () => showModal(UploadErrorModal),
|
onClick: () => showModal(UploadErrorModal),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'app.unsetCurrentDatabase',
|
||||||
|
category: 'Application',
|
||||||
|
name: 'Unset current database',
|
||||||
|
testEnabled: () => getCurrentDatabase() != null,
|
||||||
|
onClick: () => currentDatabase.set(null),
|
||||||
|
});
|
||||||
|
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
if (electron) {
|
if (electron) {
|
||||||
electron.addEventListener('run-command', (e, commandId) => runCommand(commandId));
|
electron.addEventListener('run-command', (e, commandId) => runCommand(commandId));
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
import { findEngineDriver } from 'dbgate-tools';
|
||||||
import {
|
import {
|
||||||
currentDatabase,
|
currentDatabase,
|
||||||
extensions,
|
extensions,
|
||||||
pinnedDatabases,
|
pinnedDatabases,
|
||||||
pinnedTables,
|
pinnedTables,
|
||||||
focusedConnectionOrDatabase,
|
|
||||||
openedConnections,
|
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
import { useConfig, useConnectionInfo } from '../utility/metadataLoaders';
|
import { useConfig, useConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
@@ -21,9 +19,7 @@
|
|||||||
import DbKeysTree from './DbKeysTree.svelte';
|
import DbKeysTree from './DbKeysTree.svelte';
|
||||||
import SingleConnectionDatabaseList from './SingleConnectionDatabaseList.svelte';
|
import SingleConnectionDatabaseList from './SingleConnectionDatabaseList.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
||||||
import { switchCurrentDatabase } from '../utility/common';
|
|
||||||
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
|
||||||
|
|
||||||
export let hidden = false;
|
export let hidden = false;
|
||||||
let domSqlObjectList = null;
|
let domSqlObjectList = null;
|
||||||
@@ -88,25 +84,9 @@
|
|||||||
skip={conid && (database || singleDatabase)}
|
skip={conid && (database || singleDatabase)}
|
||||||
>
|
>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
<ErrorInfo message="Database not selected" icon="img alert" />
|
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
||||||
|
|
||||||
{#if $focusedConnectionOrDatabase?.database}
|
<ErrorInfo message="Database not selected" icon="img alert" />
|
||||||
<FormStyledButton
|
|
||||||
value={`Switch to ${$focusedConnectionOrDatabase?.database}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() =>
|
|
||||||
switchCurrentDatabase({
|
|
||||||
connection: $focusedConnectionOrDatabase?.connection,
|
|
||||||
name: $focusedConnectionOrDatabase?.database,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
{:else if $focusedConnectionOrDatabase?.connection && !$openedConnections.includes($focusedConnectionOrDatabase?.conid)}
|
|
||||||
<FormStyledButton
|
|
||||||
value={`Connect to ${getConnectionLabel($focusedConnectionOrDatabase?.connection)}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() => openConnection($focusedConnectionOrDatabase?.connection)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
</WidgetColumnBarItem>
|
</WidgetColumnBarItem>
|
||||||
</WidgetColumnBar>
|
</WidgetColumnBar>
|
||||||
|
|||||||
@@ -10,12 +10,13 @@
|
|||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { currentDatabase, getExtensions } from '../stores';
|
import { currentDatabase, focusedConnectionOrDatabase, getExtensions } from '../stores';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { useConnectionInfo } from '../utility/metadataLoaders';
|
import { useConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
||||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
|
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -50,6 +51,13 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: differentFocusedDb =
|
||||||
|
$focusedConnectionOrDatabase &&
|
||||||
|
($focusedConnectionOrDatabase.conid != conid ||
|
||||||
|
($focusedConnectionOrDatabase?.database && $focusedConnectionOrDatabase?.database != database));
|
||||||
|
|
||||||
|
$: connection = useConnectionInfo({ conid });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SearchBoxWrapper>
|
<SearchBoxWrapper>
|
||||||
@@ -62,6 +70,9 @@
|
|||||||
<FontIcon icon="icon refresh" />
|
<FontIcon icon="icon refresh" />
|
||||||
</InlineButton>
|
</InlineButton>
|
||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<WidgetsInnerContainer>
|
{#if differentFocusedDb}
|
||||||
|
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
||||||
|
{/if}
|
||||||
|
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
||||||
<DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} {filter} />
|
<DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} {filter} />
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
|
|||||||
81
packages/web/src/widgets/FocusedConnectionInfoWidget.svelte
Normal file
81
packages/web/src/widgets/FocusedConnectionInfoWidget.svelte
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { switchCurrentDatabase } from '../utility/common';
|
||||||
|
import { getConnectionLabel } from 'dbgate-tools';
|
||||||
|
import { focusedConnectionOrDatabase, openedConnections } from '../stores';
|
||||||
|
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||||
|
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||||
|
|
||||||
|
export let conid;
|
||||||
|
export let database;
|
||||||
|
export let connection;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="no-focused-info">
|
||||||
|
{#if $focusedConnectionOrDatabase?.database}
|
||||||
|
{#if database}
|
||||||
|
<div class="m-1">Current database:</div>
|
||||||
|
<div class="m-1 ml-3 mb-3">
|
||||||
|
<b>{database}</b>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<FormStyledButton
|
||||||
|
value={`Switch to ${$focusedConnectionOrDatabase?.database}`}
|
||||||
|
skipWidth
|
||||||
|
on:click={() =>
|
||||||
|
switchCurrentDatabase({
|
||||||
|
connection: $focusedConnectionOrDatabase?.connection,
|
||||||
|
name: $focusedConnectionOrDatabase?.database,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
{#if database}
|
||||||
|
<FormStyledButton
|
||||||
|
value={`Show ${database}`}
|
||||||
|
skipWidth
|
||||||
|
on:click={() => {
|
||||||
|
$focusedConnectionOrDatabase = {
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
connection,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
{#if connection}
|
||||||
|
<div class="m-1">Current connection:</div>
|
||||||
|
<div class="m-1 ml-3 mb-3">
|
||||||
|
<b>{getConnectionLabel(connection)}</b>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if !$openedConnections.includes($focusedConnectionOrDatabase?.conid) && $focusedConnectionOrDatabase?.conid}
|
||||||
|
<FormStyledButton
|
||||||
|
value={`Connect to ${getConnectionLabel($focusedConnectionOrDatabase?.connection)}`}
|
||||||
|
skipWidth
|
||||||
|
on:click={() => openConnection($focusedConnectionOrDatabase?.connection)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{#if connection}
|
||||||
|
<FormStyledButton
|
||||||
|
value={`Show ${getConnectionLabel(connection)}`}
|
||||||
|
skipWidth
|
||||||
|
on:click={() => {
|
||||||
|
$focusedConnectionOrDatabase = {
|
||||||
|
conid,
|
||||||
|
connection,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.no-focused-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -31,17 +31,16 @@
|
|||||||
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, switchCurrentDatabase } from '../utility/common';
|
import { 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';
|
||||||
import { findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
import { findEngineDriver } from 'dbgate-tools';
|
||||||
import {
|
import {
|
||||||
currentDatabase,
|
currentDatabase,
|
||||||
extensions,
|
extensions,
|
||||||
focusedConnectionOrDatabase,
|
focusedConnectionOrDatabase,
|
||||||
getSelectedDatabaseObjectAppObject,
|
getSelectedDatabaseObjectAppObject,
|
||||||
openedConnections,
|
|
||||||
selectedDatabaseObjectAppObject,
|
selectedDatabaseObjectAppObject,
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
import newQuery from '../query/newQuery';
|
import newQuery from '../query/newQuery';
|
||||||
@@ -52,9 +51,7 @@
|
|||||||
import { appliedCurrentSchema } from '../stores';
|
import { appliedCurrentSchema } from '../stores';
|
||||||
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
||||||
import { matchDatabaseObjectAppObject } from '../appobj/appObjectTools';
|
import { matchDatabaseObjectAppObject } from '../appobj/appObjectTools';
|
||||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
||||||
import clickOutside from '../utility/clickOutside';
|
|
||||||
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -200,56 +197,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{#if differentFocusedDb}
|
{#if differentFocusedDb}
|
||||||
<div class="no-focused-info">
|
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
||||||
{#if $focusedConnectionOrDatabase?.database}
|
|
||||||
<div class="m-1">Current database:</div>
|
|
||||||
<div class="m-1 ml-3 mb-3">
|
|
||||||
<b>{database}</b>
|
|
||||||
</div>
|
|
||||||
<FormStyledButton
|
|
||||||
value={`Switch to ${$focusedConnectionOrDatabase?.database}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() =>
|
|
||||||
switchCurrentDatabase({
|
|
||||||
connection: $focusedConnectionOrDatabase?.connection,
|
|
||||||
name: $focusedConnectionOrDatabase?.database,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<FormStyledButton
|
|
||||||
value={`Show ${database}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() => {
|
|
||||||
$focusedConnectionOrDatabase = {
|
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
connection: $connection,
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<div class="m-1">Current connection:</div>
|
|
||||||
<div class="m-1 ml-3 mb-3">
|
|
||||||
<b>{getConnectionLabel($connection)}</b>
|
|
||||||
</div>
|
|
||||||
{#if !$openedConnections.includes($focusedConnectionOrDatabase?.conid)}
|
|
||||||
<FormStyledButton
|
|
||||||
value={`Connect to ${getConnectionLabel($focusedConnectionOrDatabase?.connection)}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() => openConnection($focusedConnectionOrDatabase?.connection)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<FormStyledButton
|
|
||||||
value={`Show ${getConnectionLabel($connection)}`}
|
|
||||||
skipWidth
|
|
||||||
on:click={() => {
|
|
||||||
$focusedConnectionOrDatabase = {
|
|
||||||
conid,
|
|
||||||
connection: $connection,
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<WidgetsInnerContainer bind:this={domContainer} hideContent={differentFocusedDb}>
|
<WidgetsInnerContainer bind:this={domContainer} hideContent={differentFocusedDb}>
|
||||||
@@ -291,12 +239,3 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
|
||||||
.no-focused-info {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user