mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 16:21:39 +00:00
feat(connection): auto-generate name when left empty
Allow saving connections without a name by generating one in the format
`{DbType}_{random4chars}` (e.g. Neo4j_a3f2). Update placeholder text
to inform users about auto-generation.
This commit is contained in:
@@ -515,8 +515,17 @@ async function testConnection() {
|
||||
}
|
||||
}
|
||||
|
||||
function generateConnectionName(): string {
|
||||
const label = selectedProfile().label;
|
||||
const rand = Math.random().toString(36).slice(2, 6);
|
||||
return `${label}_${rand}`;
|
||||
}
|
||||
|
||||
function connectionConfigForSubmit(id: string): ConnectionConfig {
|
||||
const config: ConnectionConfig = { ...form.value, id };
|
||||
if (!config.name?.trim()) {
|
||||
config.name = generateConnectionName();
|
||||
}
|
||||
const sshTimeout = Number(config.ssh_connect_timeout_secs);
|
||||
config.ssh_connect_timeout_secs = Number.isFinite(sshTimeout) && sshTimeout > 0 ? sshTimeout : 5;
|
||||
const proxyPort = Number(config.proxy_port);
|
||||
@@ -1431,7 +1440,6 @@ function openExternalUrl(url: string) {
|
||||
@click="save"
|
||||
:disabled="
|
||||
isSaving ||
|
||||
!form.name ||
|
||||
(!form.host &&
|
||||
!(mongoUseUrl && form.connection_string) &&
|
||||
!(form.db_type === 'jdbc' && form.connection_string))
|
||||
|
||||
@@ -93,7 +93,7 @@ export default {
|
||||
connection: {
|
||||
title: "New Connection",
|
||||
name: "Name",
|
||||
namePlaceholder: "My Database",
|
||||
namePlaceholder: "Connection name, auto-generated if empty",
|
||||
type: "Type",
|
||||
host: "Host",
|
||||
filePath: "File Path",
|
||||
|
||||
@@ -93,7 +93,7 @@ export default {
|
||||
connection: {
|
||||
title: "Nueva conexión",
|
||||
name: "Nombre",
|
||||
namePlaceholder: "Mi base de datos",
|
||||
namePlaceholder: "Nombre de conexión, se genera automáticamente si está vacío",
|
||||
type: "Tipo",
|
||||
host: "Host",
|
||||
filePath: "Ruta del archivo",
|
||||
|
||||
@@ -92,7 +92,7 @@ export default {
|
||||
connection: {
|
||||
title: "新建连接",
|
||||
name: "名称",
|
||||
namePlaceholder: "我的数据库",
|
||||
namePlaceholder: "连接名称,留空则自动生成",
|
||||
type: "类型",
|
||||
host: "主机",
|
||||
filePath: "文件路径",
|
||||
|
||||
Reference in New Issue
Block a user