From 4b980ad6fa7717bc4d8a282acbf232ed517879c0 Mon Sep 17 00:00:00 2001 From: labbomb <739955946@qq.com> Date: Mon, 19 Dec 2022 10:28:11 +0800 Subject: [PATCH] feat: add AZURESQL datasource (#13200) * feat: add AZURESQL datasource * fix form validate bug * feat: Adjusted the password display form, added AZURESQL type * feat: Order of adjustment Co-authored-by: devosend --- .../src/locales/en_US/datasource.ts | 13 +- .../src/locales/zh_CN/datasource.ts | 13 +- .../src/service/modules/data-source/types.ts | 5 + .../src/views/datasource/list/detail.tsx | 154 ++++++++++++++++++ .../src/views/datasource/list/use-form.ts | 72 +++++++- .../components/node/fields/use-datasource.ts | 7 +- 6 files changed, 257 insertions(+), 7 deletions(-) diff --git a/dolphinscheduler-ui/src/locales/en_US/datasource.ts b/dolphinscheduler-ui/src/locales/en_US/datasource.ts index 6d205d7434..6c1e48eee8 100644 --- a/dolphinscheduler-ui/src/locales/en_US/datasource.ts +++ b/dolphinscheduler-ui/src/locales/en_US/datasource.ts @@ -72,7 +72,18 @@ export default { user_password_tips: 'Please enter your password', aws_region: 'Aws Region', aws_region_tips: 'Please enter AwsRegion', + validation: 'Validation', + mode_tips: 'Please select a mode', jdbc_format_tips: 'jdbc connection parameters is not a correct JSON format', datasource_test_flag_tips: 'Please select a data source definition', - datasource_bind_test_id_tips: 'Please bind the test data source' + datasource_bind_test_id_tips: 'Please bind the test data source', + database_username: 'Database Username', + database_password: 'Database Password', + Azure_AD_username: 'Azure AD username', + Azure_AD_password: 'Azure AD password', + MSIClientId: 'MSI ClientId', + clientId: 'ClientId', + clientSecret: 'ClientSecret', + OAuth_token_endpoint: 'OAuth 2.0 token endpoint', + endpoint_tips: 'Please enter OAuth Token', } diff --git a/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts b/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts index 8ddff9d8ff..48c29992e3 100644 --- a/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts +++ b/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts @@ -69,7 +69,18 @@ export default { user_password_tips: '请输入密码', aws_region: 'AwsRegion', aws_region_tips: '请输入AwsRegion', + validation: '验证', + mode_tips: '请选择验证模式', jdbc_format_tips: 'jdbc连接参数不是一个正确的JSON格式', datasource_test_flag_tips: '请选择数据源定义', - datasource_bind_test_id_tips: '请绑定测试数据源' + datasource_bind_test_id_tips: '请绑定测试数据源', + database_username: '数据库用户名', + database_password: '数据库密码', + Azure_AD_username: 'Azure AD用户名', + Azure_AD_password: 'Azure AD密码', + MSIClientId: 'MSI ClientId', + clientId: 'ClientId', + clientSecret: 'ClientSecret', + OAuth_token_endpoint: 'OAuth 2.0 token endpoint', + endpoint_tips: '请输入OAuth' } diff --git a/dolphinscheduler-ui/src/service/modules/data-source/types.ts b/dolphinscheduler-ui/src/service/modules/data-source/types.ts index e61ba64ab3..1ad7fb7ad1 100644 --- a/dolphinscheduler-ui/src/service/modules/data-source/types.ts +++ b/dolphinscheduler-ui/src/service/modules/data-source/types.ts @@ -28,6 +28,7 @@ type IDataBase = | 'REDSHIFT' | 'ATHENA' | 'TRINO' + | 'AZURESQL' | 'STARROCKS' type IDataBaseLabel = @@ -43,6 +44,7 @@ type IDataBaseLabel = | 'REDSHIFT' | 'ATHENA' | 'TRINO' +| 'AZURESQL' | 'STARROCKS' interface IDataSource { @@ -57,6 +59,7 @@ interface IDataSource { javaSecurityKrb5Conf?: string loginUserKeytabUsername?: string loginUserKeytabPath?: string + mode?: string userName?: string password?: string awsRegion?: string @@ -65,6 +68,8 @@ interface IDataSource { other?: object testFlag?: number bindTestId?: number + endpoint?: string + MSIClientId?: string } interface ListReq { diff --git a/dolphinscheduler-ui/src/views/datasource/list/detail.tsx b/dolphinscheduler-ui/src/views/datasource/list/detail.tsx index a67d2a457a..bb46683265 100644 --- a/dolphinscheduler-ui/src/views/datasource/list/detail.tsx +++ b/dolphinscheduler-ui/src/views/datasource/list/detail.tsx @@ -160,6 +160,8 @@ const DetailModal = defineComponent({ showAwsRegion, showConnectType, showPrincipal, + showMode, + modeOptions, loading, saving, testing, @@ -279,6 +281,156 @@ const DetailModal = defineComponent({ placeholder={t('datasource.krb5_conf_tips')} /> + {/* 验证条件选择 */} + + + + {/* SqlPassword */} + + + + + + + {/* ActiveDirectoryPassword */} + + + + + + + {/* ActiveDirectoryMSI */} + + + + {/* ActiveDirectoryServicePrincipal */} + + + + + + + {/* accessToken */} + + + + + + + + + + + + + diff --git a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts index 2542fee7cc..371129ea04 100644 --- a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts +++ b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts @@ -45,13 +45,16 @@ export function useForm(id?: number) { javaSecurityKrb5Conf: '', loginUserKeytabUsername: '', loginUserKeytabPath: '', + mode: '', userName: '', password: '', database: '', connectType: '', other: '', testFlag: -1, - bindTestId: undefined + bindTestId: undefined, + endpoint: '', + MSIClientId: '' } as IDataSourceDetail const state = reactive({ @@ -63,6 +66,7 @@ export function useForm(id?: number) { showAwsRegion: false, showConnectType: false, showPrincipal: false, + showMode: false, bindTestDataSourceExample: [] as { label: string; value: number }[], rules: { name: { @@ -97,10 +101,21 @@ export function useForm(id?: number) { } } }, + mode: { + trigger: ['blur'], + validator() { + if (!state.detailForm.mode && state.showMode) { + return new Error(t('datasource.mode_tips')) + } + } + }, userName: { trigger: ['input'], validator() { - if (!state.detailForm.userName) { + if ( + !state.detailForm.userName && + state.detailForm.type !== 'AZURESQL' + ) { return new Error(t('datasource.user_name_tips')) } } @@ -152,8 +167,50 @@ export function useForm(id?: number) { return new Error(t('datasource.datasource_bind_test_id_tips')) } } - } - } as FormRules + }, + endpoint: { + trigger: ['input'], + validator() { + if ( + !state.detailForm.endpoint && + state.detailForm.type === 'AZURESQL' && + state.detailForm.mode === 'accessToken' + ) { + return new Error(t('datasource.endpoint_tips')) + } + } + }, + // databaseUserName: { + // trigger: ['input'], + // validator() { + // if (!state.detailForm.userName) { + // return new Error(t('datasource.user_name_tips')) + // } + // } + // }, + } as FormRules, + modeOptions: [ + { + label: "SqlPassword", + value: 'SqlPassword', + }, + { + label: "ActiveDirectoryPassword", + value: 'ActiveDirectoryPassword', + }, + { + label: "ActiveDirectoryMSI", + value: 'ActiveDirectoryMSI', + }, + { + label: "ActiveDirectoryServicePrincipal", + value: 'ActiveDirectoryServicePrincipal', + }, + { + label: "accessToken", + value: 'accessToken', + }, + ] }) const changeType = async (type: IDataBase, options: IDataBaseOption) => { @@ -165,6 +222,7 @@ export function useForm(id?: number) { state.showHost = type !== 'ATHENA' state.showPort = type !== 'ATHENA' state.showAwsRegion = type === 'ATHENA' + state.showMode = type === 'AZURESQL' if (type === 'ORACLE' && !id) { state.detailForm.connectType = 'ORACLE_SERVICE_NAME' @@ -226,6 +284,7 @@ export function useForm(id?: number) { const getFieldsValue = () => state.detailForm + return { state, changeType, @@ -299,6 +358,11 @@ export const datasourceType: IDataBaseOptionKeys = { label: 'TRINO', defaultPort: 8080 }, + AZURESQL: { + value: 'AZURESQL', + label: 'AZURESQL', + defaultPort: 1433 + }, STARROCKS: { value: 'STARROCKS', label: 'STARROCKS', diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts index e927e3629e..30cddc65cd 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts @@ -102,7 +102,12 @@ export function useDatasource( id: 13, code: 'STARROCKS', disabled: false - } + }, + { + id: 14, + code: 'AZURESQL', + disabled: false + }, ] const getDatasourceTypes = async () => {