mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 18:23:59 +00:00
database file label
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { getDatabaseFileLabel } from '../utility/getConnectionLabel';
|
||||||
|
|
||||||
export let connection;
|
export let connection;
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
? {
|
? {
|
||||||
..._.omit(e.detail, ['server', 'port', 'defaultDatabase']),
|
..._.omit(e.detail, ['server', 'port', 'defaultDatabase']),
|
||||||
singleDatabase: true,
|
singleDatabase: true,
|
||||||
|
defaultDatabase: getDatabaseFileLabel(e.detail.databaseFile),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
..._.omit(e.detail, ['databaseFile']),
|
..._.omit(e.detail, ['databaseFile']),
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
export function getDatabaseFileLabel(databaseFile) {
|
||||||
|
if (!databaseFile) return databaseFile;
|
||||||
|
const m = databaseFile.match(/[\/]([^\/]+)$/);
|
||||||
|
if (m) return m[1];
|
||||||
|
return databaseFile;
|
||||||
|
}
|
||||||
|
|
||||||
export default function getConnectionLabel(connection, { allowExplicitDatabase = true } = {}) {
|
export default function getConnectionLabel(connection, { allowExplicitDatabase = true } = {}) {
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
return null;
|
return null;
|
||||||
@@ -9,9 +16,7 @@ export default function getConnectionLabel(connection, { allowExplicitDatabase =
|
|||||||
return `${connection.defaultDatabase} on ${connection.server}`;
|
return `${connection.defaultDatabase} on ${connection.server}`;
|
||||||
}
|
}
|
||||||
if (connection.databaseFile) {
|
if (connection.databaseFile) {
|
||||||
const m = connection.databaseFile.match(/[\/]([^\/]+)$/);
|
return getDatabaseFileLabel(connection.databaseFile);
|
||||||
if (m) return m[1];
|
|
||||||
return connection.databaseFile;
|
|
||||||
}
|
}
|
||||||
if (connection.server) {
|
if (connection.server) {
|
||||||
return connection.server;
|
return connection.server;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import ToolbarButton from './ToolbarButton.svelte';
|
import ToolbarButton from './ToolbarButton.svelte';
|
||||||
import runCommand from '../commands/runCommand';
|
import runCommand from '../commands/runCommand';
|
||||||
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
|
|
||||||
const connections = useConnectionList();
|
const connections = useConnectionList();
|
||||||
const serverStatus = useServerStatus();
|
const serverStatus = useServerStatus();
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
<AppObjectList
|
<AppObjectList
|
||||||
list={_.sortBy(connectionsWithStatus, ({ displayName, server }) => (displayName || server || '').toUpperCase())}
|
list={_.sortBy(connectionsWithStatus, connection => (getConnectionLabel(connection) || '').toUpperCase())}
|
||||||
module={connectionAppObject}
|
module={connectionAppObject}
|
||||||
subItemsComponent={SubDatabaseList}
|
subItemsComponent={SubDatabaseList}
|
||||||
expandOnClick
|
expandOnClick
|
||||||
|
|||||||
Reference in New Issue
Block a user