Browse Source

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 <devosend@gmail.com>
3.2.0-release
labbomb 2 years ago committed by GitHub
parent
commit
4b980ad6fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      dolphinscheduler-ui/src/locales/en_US/datasource.ts
  2. 13
      dolphinscheduler-ui/src/locales/zh_CN/datasource.ts
  3. 5
      dolphinscheduler-ui/src/service/modules/data-source/types.ts
  4. 154
      dolphinscheduler-ui/src/views/datasource/list/detail.tsx
  5. 70
      dolphinscheduler-ui/src/views/datasource/list/use-form.ts
  6. 7
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts

13
dolphinscheduler-ui/src/locales/en_US/datasource.ts

@ -72,7 +72,18 @@ export default {
user_password_tips: 'Please enter your password', user_password_tips: 'Please enter your password',
aws_region: 'Aws Region', aws_region: 'Aws Region',
aws_region_tips: 'Please enter AwsRegion', 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', jdbc_format_tips: 'jdbc connection parameters is not a correct JSON format',
datasource_test_flag_tips: 'Please select a data source definition', 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',
} }

13
dolphinscheduler-ui/src/locales/zh_CN/datasource.ts

@ -69,7 +69,18 @@ export default {
user_password_tips: '请输入密码', user_password_tips: '请输入密码',
aws_region: 'AwsRegion', aws_region: 'AwsRegion',
aws_region_tips: '请输入AwsRegion', aws_region_tips: '请输入AwsRegion',
validation: '验证',
mode_tips: '请选择验证模式',
jdbc_format_tips: 'jdbc连接参数不是一个正确的JSON格式', jdbc_format_tips: 'jdbc连接参数不是一个正确的JSON格式',
datasource_test_flag_tips: '请选择数据源定义', 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'
} }

5
dolphinscheduler-ui/src/service/modules/data-source/types.ts

@ -28,6 +28,7 @@ type IDataBase =
| 'REDSHIFT' | 'REDSHIFT'
| 'ATHENA' | 'ATHENA'
| 'TRINO' | 'TRINO'
| 'AZURESQL'
| 'STARROCKS' | 'STARROCKS'
type IDataBaseLabel = type IDataBaseLabel =
@ -43,6 +44,7 @@ type IDataBaseLabel =
| 'REDSHIFT' | 'REDSHIFT'
| 'ATHENA' | 'ATHENA'
| 'TRINO' | 'TRINO'
| 'AZURESQL'
| 'STARROCKS' | 'STARROCKS'
interface IDataSource { interface IDataSource {
@ -57,6 +59,7 @@ interface IDataSource {
javaSecurityKrb5Conf?: string javaSecurityKrb5Conf?: string
loginUserKeytabUsername?: string loginUserKeytabUsername?: string
loginUserKeytabPath?: string loginUserKeytabPath?: string
mode?: string
userName?: string userName?: string
password?: string password?: string
awsRegion?: string awsRegion?: string
@ -65,6 +68,8 @@ interface IDataSource {
other?: object other?: object
testFlag?: number testFlag?: number
bindTestId?: number bindTestId?: number
endpoint?: string
MSIClientId?: string
} }
interface ListReq { interface ListReq {

154
dolphinscheduler-ui/src/views/datasource/list/detail.tsx

@ -160,6 +160,8 @@ const DetailModal = defineComponent({
showAwsRegion, showAwsRegion,
showConnectType, showConnectType,
showPrincipal, showPrincipal,
showMode,
modeOptions,
loading, loading,
saving, saving,
testing, testing,
@ -279,6 +281,156 @@ const DetailModal = defineComponent({
placeholder={t('datasource.krb5_conf_tips')} placeholder={t('datasource.krb5_conf_tips')}
/> />
</NFormItem> </NFormItem>
{/* 验证条件选择 */}
<NFormItem
v-show={showMode}
label={t('datasource.validation')}
path='mode'
show-require-mark
>
<NSelect
v-model={[detailForm.mode, 'value']}
options={modeOptions}
></NSelect>
</NFormItem>
{/* SqlPassword */}
<NFormItem
v-show={showMode && detailForm.mode === 'SqlPassword'}
label={t('datasource.database_username')}
path='userName'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.userName, 'value']}
type='text'
placeholder={t('datasource.database_username')}
/>
</NFormItem>
<NFormItem
v-show={showMode && detailForm.mode === 'SqlPassword'}
label={t('datasource.database_password')}
path='password'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.password, 'value']}
type='password'
placeholder={t('datasource.database_password')}
/>
</NFormItem>
{/* ActiveDirectoryPassword */}
<NFormItem
v-show={showMode && detailForm.mode === 'ActiveDirectoryPassword'}
label={t('datasource.Azure_AD_username')}
path='userName'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.userName, 'value']}
type='text'
placeholder={t('datasource.Azure_AD_username')}
/>
</NFormItem>
<NFormItem
v-show={showMode && detailForm.mode === 'ActiveDirectoryPassword'}
label={t('datasource.Azure_AD_password')}
path='password'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.password, 'value']}
type='password'
placeholder={t('datasource.Azure_AD_password')}
/>
</NFormItem>
{/* ActiveDirectoryMSI */}
<NFormItem
v-show={showMode && detailForm.mode === 'ActiveDirectoryMSI'}
label={t('datasource.MSIClientId')}
path='MSIClientId'
>
<NInput
allowInput={this.trim}
v-model={[detailForm.MSIClientId, 'value']}
type='password'
placeholder={t('datasource.MSIClientId')}
/>
</NFormItem>
{/* ActiveDirectoryServicePrincipal */}
<NFormItem
v-show={showMode && detailForm.mode === 'ActiveDirectoryServicePrincipal'}
label={t('datasource.clientId')}
path='userName'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.userName, 'value']}
type='text'
placeholder={t('datasource.clientId')}
/>
</NFormItem>
<NFormItem
v-show={showMode && detailForm.mode === 'ActiveDirectoryServicePrincipal'}
label={t('datasource.clientSecret')}
path='password'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.password, 'value']}
type='password'
placeholder={t('datasource.clientSecret')}
/>
</NFormItem>
{/* accessToken */}
<NFormItem
v-show={showMode && detailForm.mode === 'accessToken'}
label={t('datasource.clientId')}
path='userName'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.userName, 'value']}
type='text'
placeholder={t('datasource.clientId')}
/>
</NFormItem>
<NFormItem
v-show={showMode && detailForm.mode === 'accessToken'}
label={t('datasource.clientSecret')}
path='password'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.password, 'value']}
type='password'
placeholder={t('datasource.clientSecret')}
/>
</NFormItem>
<NFormItem
v-show={showMode && detailForm.mode === 'accessToken'}
label={t('datasource.OAuth_token_endpoint')}
path='endpoint'
show-require-mark
>
<NInput
allowInput={this.trim}
v-model={[detailForm.endpoint, 'value']}
type='text'
placeholder={t('datasource.OAuth_token_endpoint')}
/>
</NFormItem>
<NFormItem <NFormItem
v-show={showPrincipal} v-show={showPrincipal}
label='keytab.username' label='keytab.username'
@ -304,6 +456,7 @@ const DetailModal = defineComponent({
/> />
</NFormItem> </NFormItem>
<NFormItem <NFormItem
v-show={!showMode}
label={t('datasource.user_name')} label={t('datasource.user_name')}
path='userName' path='userName'
show-require-mark show-require-mark
@ -318,6 +471,7 @@ const DetailModal = defineComponent({
/> />
</NFormItem> </NFormItem>
<NFormItem <NFormItem
v-show={!showMode}
label={t('datasource.user_password')} label={t('datasource.user_password')}
path='password' path='password'
> >

70
dolphinscheduler-ui/src/views/datasource/list/use-form.ts

@ -45,13 +45,16 @@ export function useForm(id?: number) {
javaSecurityKrb5Conf: '', javaSecurityKrb5Conf: '',
loginUserKeytabUsername: '', loginUserKeytabUsername: '',
loginUserKeytabPath: '', loginUserKeytabPath: '',
mode: '',
userName: '', userName: '',
password: '', password: '',
database: '', database: '',
connectType: '', connectType: '',
other: '', other: '',
testFlag: -1, testFlag: -1,
bindTestId: undefined bindTestId: undefined,
endpoint: '',
MSIClientId: ''
} as IDataSourceDetail } as IDataSourceDetail
const state = reactive({ const state = reactive({
@ -63,6 +66,7 @@ export function useForm(id?: number) {
showAwsRegion: false, showAwsRegion: false,
showConnectType: false, showConnectType: false,
showPrincipal: false, showPrincipal: false,
showMode: false,
bindTestDataSourceExample: [] as { label: string; value: number }[], bindTestDataSourceExample: [] as { label: string; value: number }[],
rules: { rules: {
name: { 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: { userName: {
trigger: ['input'], trigger: ['input'],
validator() { validator() {
if (!state.detailForm.userName) { if (
!state.detailForm.userName &&
state.detailForm.type !== 'AZURESQL'
) {
return new Error(t('datasource.user_name_tips')) 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')) return new Error(t('datasource.datasource_bind_test_id_tips'))
} }
} }
},
endpoint: {
trigger: ['input'],
validator() {
if (
!state.detailForm.endpoint &&
state.detailForm.type === 'AZURESQL' &&
state.detailForm.mode === 'accessToken'
) {
return new Error(t('datasource.endpoint_tips'))
} }
} as FormRules }
},
// 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) => { const changeType = async (type: IDataBase, options: IDataBaseOption) => {
@ -165,6 +222,7 @@ export function useForm(id?: number) {
state.showHost = type !== 'ATHENA' state.showHost = type !== 'ATHENA'
state.showPort = type !== 'ATHENA' state.showPort = type !== 'ATHENA'
state.showAwsRegion = type === 'ATHENA' state.showAwsRegion = type === 'ATHENA'
state.showMode = type === 'AZURESQL'
if (type === 'ORACLE' && !id) { if (type === 'ORACLE' && !id) {
state.detailForm.connectType = 'ORACLE_SERVICE_NAME' state.detailForm.connectType = 'ORACLE_SERVICE_NAME'
@ -226,6 +284,7 @@ export function useForm(id?: number) {
const getFieldsValue = () => state.detailForm const getFieldsValue = () => state.detailForm
return { return {
state, state,
changeType, changeType,
@ -299,6 +358,11 @@ export const datasourceType: IDataBaseOptionKeys = {
label: 'TRINO', label: 'TRINO',
defaultPort: 8080 defaultPort: 8080
}, },
AZURESQL: {
value: 'AZURESQL',
label: 'AZURESQL',
defaultPort: 1433
},
STARROCKS: { STARROCKS: {
value: 'STARROCKS', value: 'STARROCKS',
label: 'STARROCKS', label: 'STARROCKS',

7
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts

@ -102,7 +102,12 @@ export function useDatasource(
id: 13, id: 13,
code: 'STARROCKS', code: 'STARROCKS',
disabled: false disabled: false
} },
{
id: 14,
code: 'AZURESQL',
disabled: false
},
] ]
const getDatasourceTypes = async () => { const getDatasourceTypes = async () => {

Loading…
Cancel
Save