From 931da60ce56ccd2a677257a9b125a08c7807dfdb Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 23 Jul 2024 12:26:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SSH=20=E8=AE=BE=E7=BD=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/form/EditorDetail.vue | 99 ++++++++++++++----- .../visualized/data/datasource/index.vue | 30 ++++++ 2 files changed, 107 insertions(+), 22 deletions(-) diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue index b434e6a059..269614a408 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue @@ -157,6 +157,50 @@ const authMethodList = [ label: 'Kerberos' } ] + +const validateSshHost = (_: any, value: any, callback: any) => { + if ((value === null || value === '') && form.value.configuration.useSSH) { + callback(new Error('SSH主机不能为空')) + } + return callback() +} + +const validateSshPort = (_: any, value: any, callback: any) => { + if ((value === null || value === '') && form.value.configuration.useSSH) { + callback(new Error('SSH端口不能为空')) + } + return callback() +} + +const validateSshUserName = (_: any, value: any, callback: any) => { + if ((value === null || value === '') && form.value.configuration.useSSH) { + callback(new Error('SSH用户名不能为空')) + } + return callback() +} + +const validateSshPassword = (_: any, value: any, callback: any) => { + if ( + (value === null || value === '') && + form.value.configuration.useSSH && + form.value.configuration.sshType === 'password' + ) { + callback(new Error('SSH密码不能为空')) + } + return callback() +} + +const validateSshkey = (_: any, value: any, callback: any) => { + if ( + (value === null || value === '' || value === undefined) && + form.value.configuration.useSSH && + form.value.configuration.sshType === 'sshkey' + ) { + callback(new Error('SSH key不能为空')) + } + return callback() +} + const setRules = () => { const configRules = { 'configuration.jdbcUrl': [ @@ -242,7 +286,12 @@ const setRules = () => { message: t('common.inputText') + t('datasource.query_timeout'), trigger: 'blur' } - ] + ], + 'configuration.sshHost': [{ validator: validateSshHost, trigger: 'blur' }], + 'configuration.sshPort': [{ validator: validateSshPort, trigger: 'blur' }], + 'configuration.sshUserName': [{ validator: validateSshUserName, trigger: 'blur' }], + 'configuration.sshPassword': [{ validator: validateSshPassword, trigger: 'blur' }], + 'configuration.sshKey': [{ validator: validateSshkey, trigger: 'blur' }] } if (['oracle', 'sqlServer', 'pg', 'redshift', 'db2'].includes(form.value.type)) { configRules['configuration.schema'] = [ @@ -1016,17 +1065,19 @@ defineExpose({ autocomplete="off" /> - SSH 设置 - - - - + + SSH 设置 + + + + + - {{ t('datasource.priority') }} - - - - + + {{ t('datasource.priority') }} + + + + + + + SSH 设置 + + + + +