mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 03:45:59 +00:00
connection colors
This commit is contained in:
@@ -31,12 +31,13 @@
|
||||
import _ from 'lodash';
|
||||
import { writable } from 'svelte/store';
|
||||
import moment from 'moment';
|
||||
import { presetPalettes, presetDarkPalettes } from '@ant-design/colors';
|
||||
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
|
||||
import { activeTabId, currentDatabase, visibleCommandPalette } from '../stores';
|
||||
import { activeTabId, currentDatabase, currentThemeDefinition, visibleCommandPalette } from '../stores';
|
||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||
import { useDatabaseServerVersion, useDatabaseStatus } from '../utility/metadataLoaders';
|
||||
import { useConnectionList, useDatabaseServerVersion, useDatabaseStatus } from '../utility/metadataLoaders';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import { findCommand } from '../commands/runCommand';
|
||||
|
||||
@@ -44,16 +45,29 @@
|
||||
$: connection = $currentDatabase && $currentDatabase.connection;
|
||||
$: status = useDatabaseStatus(connection ? { conid: connection._id, database: databaseName } : {});
|
||||
$: serverVersion = useDatabaseServerVersion(connection ? { conid: connection._id, database: databaseName } : {});
|
||||
const connections = useConnectionList();
|
||||
|
||||
$: contextItems = $statusBarTabInfo[$activeTabId] as any[];
|
||||
$: connectionLabel = getConnectionLabel(connection, { allowExplicitDatabase: false });
|
||||
|
||||
$: connectionColor = getConnectionColor($connections, connection, $currentThemeDefinition);
|
||||
|
||||
let timerValue = 1;
|
||||
|
||||
setInterval(() => {
|
||||
timerValue++;
|
||||
}, 10000);
|
||||
|
||||
function getConnectionColor(connections, connection, themeDef) {
|
||||
if (!connection || !connections) return null;
|
||||
const current = connections.find(x => x._id == connection._id);
|
||||
if (!current?.connectionColor) return null;
|
||||
if (!themeDef) return null;
|
||||
// const palettes = themeDef?.themeType == 'dark' ? presetDarkPalettes : presetPalettes;
|
||||
const palettes = presetDarkPalettes;
|
||||
return palettes[current?.connectionColor][3];
|
||||
}
|
||||
|
||||
async function handleSyncModel() {
|
||||
if (connection && databaseName) {
|
||||
await axiosInstance.post('database-connections/sync-model', { conid: connection._id, database: databaseName });
|
||||
@@ -61,7 +75,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="main">
|
||||
<div class="main" style={connectionColor ? `background: ${connectionColor}` : null}>
|
||||
<div class="container">
|
||||
{#if databaseName}
|
||||
<div class="item">
|
||||
|
||||
Reference in New Issue
Block a user