mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 11:23:59 +00:00
SYNC: [skip ci] Show server name alongside database name in title of the tab group #1041
This commit is contained in:
committed by
Diflow
parent
8bc2d7cb05
commit
cdec56b661
@@ -121,6 +121,8 @@ ORDER BY
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<FormCheckboxField name="tabGroup.showServerName" label="Show server name alongside database name in title of the tab group" defaultValue={false} />
|
||||||
|
|
||||||
<div class="heading">Data grid</div>
|
<div class="heading">Data grid</div>
|
||||||
<FormTextField
|
<FormTextField
|
||||||
name="dataGrid.pageSize"
|
name="dataGrid.pageSize"
|
||||||
|
|||||||
@@ -196,6 +196,15 @@
|
|||||||
return '(no DB)';
|
return '(no DB)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTabDbServer(tab, connectionList) {
|
||||||
|
if (tab.props && tab.props.conid && tab.props.database) {
|
||||||
|
const connection = connectionList?.find(x => x._id == tab.props.conid);
|
||||||
|
if (connection) return getConnectionLabel(connection, { allowExplicitDatabase: false });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function getDbIcon(key) {
|
function getDbIcon(key) {
|
||||||
if (key) {
|
if (key) {
|
||||||
if (key.startsWith('database://')) return 'icon database';
|
if (key.startsWith('database://')) return 'icon database';
|
||||||
@@ -330,7 +339,7 @@
|
|||||||
import { setSelectedTab, switchCurrentDatabase } from '../utility/common';
|
import { setSelectedTab, switchCurrentDatabase } from '../utility/common';
|
||||||
import contextMenu from '../utility/contextMenu';
|
import contextMenu from '../utility/contextMenu';
|
||||||
import { isElectronAvailable } from '../utility/getElectron';
|
import { isElectronAvailable } from '../utility/getElectron';
|
||||||
import { getConnectionInfo, useConnectionList } from '../utility/metadataLoaders';
|
import { getConnectionInfo, useConnectionList, useSettings } from '../utility/metadataLoaders';
|
||||||
import { duplicateTab, getTabDbKey, sortTabs, groupTabs } from '../utility/openNewTab';
|
import { duplicateTab, getTabDbKey, sortTabs, groupTabs } from '../utility/openNewTab';
|
||||||
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
||||||
import TabCloseButton from '../elements/TabCloseButton.svelte';
|
import TabCloseButton from '../elements/TabCloseButton.svelte';
|
||||||
@@ -338,6 +347,7 @@
|
|||||||
import SwitchDatabaseModal from '../modals/SwitchDatabaseModal.svelte';
|
import SwitchDatabaseModal from '../modals/SwitchDatabaseModal.svelte';
|
||||||
import { getConnectionLabel } from 'dbgate-tools';
|
import { getConnectionLabel } from 'dbgate-tools';
|
||||||
import { handleAfterTabClick } from '../utility/changeCurrentDbByTab';
|
import { handleAfterTabClick } from '../utility/changeCurrentDbByTab';
|
||||||
|
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||||
|
|
||||||
export let multiTabIndex;
|
export let multiTabIndex;
|
||||||
export let shownTab;
|
export let shownTab;
|
||||||
@@ -357,6 +367,7 @@
|
|||||||
...tab,
|
...tab,
|
||||||
tabDbName: getTabDbName(tab, $connectionList),
|
tabDbName: getTabDbName(tab, $connectionList),
|
||||||
tabDbKey: getTabDbKey(tab),
|
tabDbKey: getTabDbKey(tab),
|
||||||
|
tabDbServer: getTabDbServer(tab, $connectionList),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$: groupedTabs = groupTabs(tabsWithDb);
|
$: groupedTabs = groupTabs(tabsWithDb);
|
||||||
@@ -370,6 +381,8 @@
|
|||||||
$: allowSplitTab =
|
$: allowSplitTab =
|
||||||
_.uniq(filteredTabsFromAllParts.map(x => x.multiTabIndex || 0)).length == 1 && filteredTabsFromAllParts.length >= 2;
|
_.uniq(filteredTabsFromAllParts.map(x => x.multiTabIndex || 0)).length == 1 && filteredTabsFromAllParts.length >= 2;
|
||||||
|
|
||||||
|
$: settings = useSettings();
|
||||||
|
|
||||||
const connectionColorFactory = useConnectionColorFactory(3, null, true);
|
const connectionColorFactory = useConnectionColorFactory(3, null, true);
|
||||||
|
|
||||||
const handleTabClick = (e, tabid) => {
|
const handleTabClick = (e, tabid) => {
|
||||||
@@ -595,6 +608,10 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="db-name-inner">
|
<div class="db-name-inner">
|
||||||
|
{#if $settings?.['tabGroup.showServerName'] && tabGroup.tabDbServer}
|
||||||
|
<FontIcon icon="icon server" />
|
||||||
|
{tabGroup.tabDbServer}
|
||||||
|
{/if}
|
||||||
<FontIcon icon={getDbIcon(tabGroup.tabDbKey)} />
|
<FontIcon icon={getDbIcon(tabGroup.tabDbKey)} />
|
||||||
{tabGroup.tabDbName}
|
{tabGroup.tabDbName}
|
||||||
{#if $connectionList?.find(x => x._id == tabGroup.tabs[0]?.props?.conid)?.isReadOnly}
|
{#if $connectionList?.find(x => x._id == tabGroup.tabs[0]?.props?.conid)?.isReadOnly}
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ export function groupTabs(tabs: any[]) {
|
|||||||
res.push({
|
res.push({
|
||||||
tabDbKey: tab.tabDbKey,
|
tabDbKey: tab.tabDbKey,
|
||||||
tabDbName: tab.tabDbName,
|
tabDbName: tab.tabDbName,
|
||||||
|
tabDbServer: tab.tabDbServer,
|
||||||
tabs: [tab],
|
tabs: [tab],
|
||||||
grpid: tab.tabid,
|
grpid: tab.tabid,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user