diff --git a/packages/api/src/controllers/connections.js b/packages/api/src/controllers/connections.js
index 1a20669f1..544a9c1b3 100644
--- a/packages/api/src/controllers/connections.js
+++ b/packages/api/src/controllers/connections.js
@@ -170,6 +170,23 @@ module.exports = {
return res;
},
+ updateDatabase_meta: 'post',
+ async updateDatabase({ conid, database, values }) {
+ if (portalConnections) return;
+ const conn = await this.datastore.find({ _id: conid });
+ let databaseConfig = conn.databaseConfig || {};
+ databaseConfig = {
+ ...databaseConfig,
+ [database]: {
+ ...databaseConfig[database],
+ ...values,
+ },
+ };
+ const res = await this.datastore.update({ _id: conid }, { $set: { databaseConfig } });
+ socket.emitChanged('connection-list-changed');
+ return res;
+ },
+
delete_meta: 'post',
async delete(connection) {
if (portalConnections) return;
diff --git a/packages/web/src/appobj/AppObjectListItem.svelte b/packages/web/src/appobj/AppObjectListItem.svelte
index f61003985..d3af18c99 100644
--- a/packages/web/src/appobj/AppObjectListItem.svelte
+++ b/packages/web/src/appobj/AppObjectListItem.svelte
@@ -56,7 +56,7 @@
{#if (isExpanded || isExpandedBySearch) && subItemsComponent}
-
+
{/if}
{/if}
diff --git a/packages/web/src/appobj/DatabaseAppObject.svelte b/packages/web/src/appobj/DatabaseAppObject.svelte
index 39cfb4802..da235b0f3 100644
--- a/packages/web/src/appobj/DatabaseAppObject.svelte
+++ b/packages/web/src/appobj/DatabaseAppObject.svelte
@@ -171,8 +171,10 @@
import { findEngineDriver } from 'dbgate-tools';
import InputTextModal from '../modals/InputTextModal.svelte';
import { getDatabaseInfo } from '../utility/metadataLoaders';
-import { openJsonDocument } from '../tabs/JsonTab.svelte';
+ import { openJsonDocument } from '../tabs/JsonTab.svelte';
+
export let data;
+ export let passProps;
function createMenu() {
return getDatabaseMenuItems(data.connection, data.name, $extensions, $currentDatabase);
@@ -184,6 +186,12 @@ import { openJsonDocument } from '../tabs/JsonTab.svelte';
{data}
title={data.name}
icon="img database"
+ colorMark={passProps?.connectionColorFactory(
+ { conid: _.get(data.connection, '_id'), database: data.name },
+ null,
+ null,
+ false
+ )}
isBold={_.get($currentDatabase, 'connection._id') == _.get(data.connection, '_id') &&
_.get($currentDatabase, 'name') == data.name}
on:click={() => ($currentDatabase = data)}
diff --git a/packages/web/src/appobj/SubDatabaseList.svelte b/packages/web/src/appobj/SubDatabaseList.svelte
index 9cb442679..b719ac97b 100644
--- a/packages/web/src/appobj/SubDatabaseList.svelte
+++ b/packages/web/src/appobj/SubDatabaseList.svelte
@@ -7,6 +7,7 @@
export let filter;
export let data;
+ export let passProps;
$: databases = useDatabaseList({ conid: data._id });
@@ -17,4 +18,5 @@
'name'
).map(db => ({ ...db, connection: data }))}
module={databaseAppObject}
+ {passProps}
/>
diff --git a/packages/web/src/modals/ChooseConnectionColorModal.svelte b/packages/web/src/modals/ChooseConnectionColorModal.svelte
index 4a244dc84..c36d1f944 100644
--- a/packages/web/src/modals/ChooseConnectionColorModal.svelte
+++ b/packages/web/src/modals/ChooseConnectionColorModal.svelte
@@ -6,22 +6,33 @@
export let conid;
export let database;
+ export let header;
- const initialColor = useConnectionColor({ conid, database }, null);
+ const initialColor = useConnectionColor({ conid, database }, null, null, false, false);
$: value = $initialColor;
+ {header}
+
{
value = e.detail;
- axiosInstance.post('connections/update', {
- _id: conid,
- values: { connectionColor: e.detail },
- });
+ if (database) {
+ axiosInstance.post('connections/update-database', {
+ conid,
+ database,
+ values: { databaseColor: e.detail },
+ });
+ } else {
+ axiosInstance.post('connections/update', {
+ _id: conid,
+ values: { connectionColor: e.detail },
+ });
+ }
}}
/>
diff --git a/packages/web/src/plugins/ThemeDark.svelte b/packages/web/src/plugins/ThemeDark.svelte
index 0ff082ab3..f0a543a47 100644
--- a/packages/web/src/plugins/ThemeDark.svelte
+++ b/packages/web/src/plugins/ThemeDark.svelte
@@ -56,6 +56,7 @@
--theme-bg-statusbar-inv: #0050b3;
--theme-bg-statusbar-inv-hover: #096dd9;
--theme-bg-statusbar-inv-font: #222;
+ --theme-bg-statusbar-inv-bg: #ccc;
--theme-bg-modalheader: rgb(43, 60, 61);
--theme-bg-button-inv: #004488;
diff --git a/packages/web/src/plugins/ThemeLight.svelte b/packages/web/src/plugins/ThemeLight.svelte
index 353e1b536..1956d393b 100644
--- a/packages/web/src/plugins/ThemeLight.svelte
+++ b/packages/web/src/plugins/ThemeLight.svelte
@@ -50,6 +50,7 @@
--theme-bg-statusbar-inv: #0050b3;
--theme-bg-statusbar-inv-hover: #096dd9;
--theme-bg-statusbar-inv-font: #222;
+ --theme-bg-statusbar-inv-bg: #ccc;
--theme-bg-modalheader: #eff;
--theme-bg-button-inv: #337ab7;
diff --git a/packages/web/src/utility/useConnectionColor.ts b/packages/web/src/utility/useConnectionColor.ts
index 20b1eefea..c1beaf47c 100644
--- a/packages/web/src/utility/useConnectionColor.ts
+++ b/packages/web/src/utility/useConnectionColor.ts
@@ -3,35 +3,76 @@ import { derived } from 'svelte/store';
import { currentThemeDefinition } from '../stores';
import { useConnectionList } from '../utility/metadataLoaders';
-export function getConnectionColor(connections, dbid, themeType, colorIndex, backgroundStyle = false) {
+export function getConnectionColor(
+ connections,
+ dbid,
+ themeType,
+ colorIndex,
+ backgroundStyle = false,
+ useConnectionFallback = true
+) {
if (!dbid || !connections) return undefined;
const current = connections.find(x => x._id == dbid.conid);
- if (!current?.connectionColor) return undefined;
+ const { database } = dbid;
+ let colorName = useConnectionFallback || !database ? current?.connectionColor : null;
+ if (
+ database &&
+ current.databaseConfig &&
+ current.databaseConfig[database] &&
+ current.databaseConfig[database].databaseColor
+ ) {
+ colorName = current.databaseConfig[database].databaseColor;
+ }
+ if (!colorName) return undefined;
const palettes = themeType == 'dark' ? presetDarkPalettes : presetPalettes;
- if (colorIndex == null) return current?.connectionColor;
- const color = palettes[current?.connectionColor][colorIndex];
+ if (colorIndex == null) return colorName;
+ const color = palettes[colorName][colorIndex];
if (backgroundStyle) return `background:${color}`;
return color;
}
-export function useConnectionColor(dbid, colorIndex, themeType = null, backgroundStyle = false) {
+export function useConnectionColor(
+ dbid,
+ colorIndex,
+ themeType = null,
+ backgroundStyle = false,
+ useConnectionFallback = true
+) {
const connections = useConnectionList();
return derived([connections, currentThemeDefinition], ([$connections, $themeDef]) =>
- getConnectionColor($connections, dbid, themeType ?? $themeDef?.themeType, colorIndex, backgroundStyle)
+ getConnectionColor(
+ $connections,
+ dbid,
+ themeType ?? $themeDef?.themeType,
+ colorIndex,
+ backgroundStyle,
+ useConnectionFallback
+ )
);
}
-export function useConnectionColorFactory(colorIndex, themeType = null, backgroundStyle = false) {
+export function useConnectionColorFactory(
+ colorIndex,
+ themeType = null,
+ backgroundStyle = false,
+ useConnectionFallback = true
+) {
const connections = useConnectionList();
return derived(
[connections, currentThemeDefinition],
- ([$connections, $themeDef]) => (dbid, colorIndexOverride = null) =>
+ ([$connections, $themeDef]) => (
+ dbid,
+ colorIndexOverride = null,
+ backgroundStyleOverride = null,
+ useConnectionFallbackOverride = null
+ ) =>
getConnectionColor(
$connections,
dbid,
themeType ?? $themeDef?.themeType,
- colorIndexOverride || colorIndex,
- backgroundStyle
+ colorIndexOverride ?? colorIndex,
+ backgroundStyleOverride ?? backgroundStyle,
+ useConnectionFallbackOverride ?? useConnectionFallback
)
);
}
diff --git a/packages/web/src/widgets/StatusBar.svelte b/packages/web/src/widgets/StatusBar.svelte
index 0bbc1bb40..86e3b1354 100644
--- a/packages/web/src/widgets/StatusBar.svelte
+++ b/packages/web/src/widgets/StatusBar.svelte
@@ -48,13 +48,13 @@
$: dbid = connection ? { conid: connection._id, database: databaseName } : null;
$: status = useDatabaseStatus(dbid || {});
$: serverVersion = useDatabaseServerVersion(dbid || {});
- const connections = useConnectionList();
$: contextItems = $statusBarTabInfo[$activeTabId] as any[];
$: connectionLabel = getConnectionLabel(connection, { allowExplicitDatabase: false });
$: connectionBackground = useConnectionColor(dbid, 3, 'dark', true);
- $: connectionButtonBackground = useConnectionColor(dbid, 6, 'dark', true);
+ $: connectionButtonBackground = useConnectionColor(dbid ? { conid: dbid.conid } : null, 6, 'dark', true);
+ $: databaseButtonBackground = useConnectionColor(dbid, 6, 'dark', true, false);
let timerValue = 1;
@@ -76,23 +76,38 @@
{databaseName}
+ {#if dbid}
+ {
+ showModal(ChooseConnectionColorModal, { ...dbid, header: 'Choose database color' });
+ }}
+ >
+
+
+
+
+ {/if}
{/if}
- {#if connectionLabel && dbid}
+ {#if connectionLabel}
{connectionLabel}
- {
- showModal(ChooseConnectionColorModal, { conid: dbid.conid });
- }}
- >
-
-
+ {#if dbid}
+
{
+ showModal(ChooseConnectionColorModal, { conid: dbid.conid, header: 'Choose connection color' });
+ }}
+ >
+
+
+
-
+ {/if}
{/if}
{#if connection && connection.user}
@@ -192,5 +207,6 @@
padding: 0px 3px;
border-radius: 2px;
color: var(--theme-bg-statusbar-inv-font);
+ background: var(--theme-bg-statusbar-inv-bg);
}