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