Browse Source

[Fix][UI] Fix datax task data instance replay error. (#11222)

3.1.0-release
Amy0104 2 years ago committed by GitHub
parent
commit
0141aa511b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts
  2. 185
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datax.ts
  3. 2
      dolphinscheduler-ui/src/views/projects/workflow/definition/use-table.ts

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

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ref, onMounted, nextTick } from 'vue' import { ref, onMounted, nextTick, Ref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { queryDataSourceList } from '@/service/modules/data-source' import { queryDataSourceList } from '@/service/modules/data-source'
import { indexOf, find } from 'lodash' import { indexOf, find } from 'lodash'
@ -24,8 +24,12 @@ import type { TypeReq } from '@/service/modules/data-source/types'
export function useDatasource( export function useDatasource(
model: { [field: string]: any }, model: { [field: string]: any },
supportedDatasourceType?: string[], params: {
field?: string supportedDatasourceType?: string[]
typeField?: string
sourceField?: string
span?: Ref | number
} = {}
): IJsonItem[] { ): IJsonItem[] {
const { t } = useI18n() const { t } = useI18n()
@ -91,8 +95,8 @@ export function useDatasource(
if (item.disabled) { if (item.disabled) {
return false return false
} }
if (supportedDatasourceType) { if (params.supportedDatasourceType) {
return indexOf(supportedDatasourceType, item.code) !== -1 return indexOf(params.supportedDatasourceType, item.code) !== -1
} }
return true return true
}) })
@ -100,17 +104,18 @@ export function useDatasource(
} }
const refreshOptions = async () => { const refreshOptions = async () => {
const params = { type: model.type } as TypeReq const parameters = { type: model[params.typeField || 'type'] } as TypeReq
const res = await queryDataSourceList(params) const res = await queryDataSourceList(parameters)
datasourceOptions.value = res.map((item: any) => ({ datasourceOptions.value = res.map((item: any) => ({
label: item.name, label: item.name,
value: item.id value: item.id
})) }))
if (!res.length && model.datasource) model.datasource = null const sourceField = params.sourceField || 'datasource'
if (res.length && model.datasource) { if (!res.length && model[sourceField]) model[sourceField] = null
const item = find(res, { id: model.datasource }) if (res.length && model[sourceField]) {
const item = find(res, { id: model[sourceField] })
if (!item) { if (!item) {
model.datasource = null model[sourceField] = null
} }
} }
} }
@ -127,8 +132,8 @@ export function useDatasource(
return [ return [
{ {
type: 'select', type: 'select',
field: field ? field : 'type', field: params.typeField || 'type',
span: 12, span: params.span || 12,
name: t('project.node.datasource_type'), name: t('project.node.datasource_type'),
props: { props: {
'on-update:value': onChange 'on-update:value': onChange
@ -141,8 +146,8 @@ export function useDatasource(
}, },
{ {
type: 'select', type: 'select',
field: field || 'datasource', field: params.sourceField || 'datasource',
span: 12, span: params.span || 12,
name: t('project.node.datasource_instances'), name: t('project.node.datasource_instances'),
options: datasourceOptions, options: datasourceOptions,
validate: { validate: {

185
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datax.ts

@ -16,65 +16,11 @@
*/ */
import { ref, onMounted, watch } from 'vue' import { ref, onMounted, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useCustomParams, useDatasource } from '.'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
import { find } from 'lodash'
import { TypeReq } from '@/service/modules/data-source/types'
import { queryDataSourceList } from '@/service/modules/data-source'
import {useCustomParams} from "."
export function useDataX(model: { [field: string]: any }): IJsonItem[] { export function useDataX(model: { [field: string]: any }): IJsonItem[] {
const { t } = useI18n() const { t } = useI18n()
const datasourceTypes = [
{
id: 0,
code: 'MYSQL',
disabled: false
},
{
id: 1,
code: 'POSTGRESQL',
disabled: false
},
{
id: 2,
code: 'HIVE',
disabled: true
},
{
id: 3,
code: 'SPARK',
disabled: true
},
{
id: 4,
code: 'CLICKHOUSE',
disabled: false
},
{
id: 5,
code: 'ORACLE',
disabled: false
},
{
id: 6,
code: 'SQLSERVER',
disabled: false
},
{
id: 7,
code: 'DB2',
disabled: true
},
{
id: 8,
code: 'PRESTO',
disabled: true
}
]
const datasourceTypeOptions = ref([] as any)
const datasourceOptions = ref([] as any)
const destinationDatasourceOptions = ref([] as any)
const jobSpeedByteOptions: any[] = [ const jobSpeedByteOptions: any[] = [
{ {
label: `0(${t('project.node.unlimited')})`, label: `0(${t('project.node.unlimited')})`,
@ -149,53 +95,6 @@ export function useDataX(model: { [field: string]: any }): IJsonItem[] {
value: 4 value: 4
} }
] ]
const loading = ref(false)
const getDatasourceTypes = async () => {
if (loading.value) return
loading.value = true
datasourceTypeOptions.value = datasourceTypes
.filter((item) => !item.disabled)
.map((item) => ({ label: item.code, value: item.code }))
loading.value = false
}
const getDatasourceInstances = async () => {
const params = { type: model.dsType } as TypeReq
const res = await queryDataSourceList(params)
datasourceOptions.value = []
res.map((item: any) => {
datasourceOptions.value.push({ label: item.name, value: String(item.id) })
})
if (datasourceOptions.value && model.dataSource) {
const item = find(datasourceOptions.value, {
value: String(model.dataSource)
})
if (!item) {
model.dataSource = null
}
}
}
const getDestinationDatasourceInstances = async () => {
const params = { type: model.dtType } as TypeReq
const res = await queryDataSourceList(params)
destinationDatasourceOptions.value = []
res.map((item: any) => {
destinationDatasourceOptions.value.push({
label: item.name,
value: String(item.id)
})
})
if (destinationDatasourceOptions.value && model.dataTarget) {
const item = find(destinationDatasourceOptions.value, {
value: String(model.dataTarget)
})
if (!item) {
model.dataTarget = null
}
}
}
const sqlEditorSpan = ref(24) const sqlEditorSpan = ref(24)
const jsonEditorSpan = ref(0) const jsonEditorSpan = ref(0)
@ -226,22 +125,8 @@ export function useDataX(model: { [field: string]: any }): IJsonItem[] {
} }
onMounted(() => { onMounted(() => {
getDatasourceTypes()
getDatasourceInstances()
getDestinationDatasourceInstances()
initConstants() initConstants()
}) })
const onSourceTypeChange = (type: string) => {
model.dsType = type
getDatasourceInstances()
}
const onDestinationTypeChange = (type: string) => {
model.dtType = type
getDestinationDatasourceInstances()
}
watch( watch(
() => model.customConfig, () => model.customConfig,
() => { () => {
@ -255,35 +140,11 @@ export function useDataX(model: { [field: string]: any }): IJsonItem[] {
field: 'customConfig', field: 'customConfig',
name: t('project.node.datax_custom_template') name: t('project.node.datax_custom_template')
}, },
{ ...useDatasource(model, {
type: 'select', typeField: 'dsType',
field: 'dsType', sourceField: 'dataSource',
span: datasourceSpan, span: datasourceSpan
name: t('project.node.datasource_type'), }),
props: {
loading: loading,
'on-update:value': onSourceTypeChange
},
options: datasourceTypeOptions,
validate: {
trigger: ['input', 'blur'],
required: true
}
},
{
type: 'select',
field: 'dataSource',
span: datasourceSpan,
name: t('project.node.datasource_instances'),
props: {
loading: loading
},
options: datasourceOptions,
validate: {
trigger: ['input', 'blur'],
required: true
}
},
{ {
type: 'editor', type: 'editor',
field: 'sql', field: 'sql',
@ -306,35 +167,11 @@ export function useDataX(model: { [field: string]: any }): IJsonItem[] {
message: t('project.node.sql_empty_tips') message: t('project.node.sql_empty_tips')
} }
}, },
{ ...useDatasource(model, {
type: 'select', typeField: 'dtType',
field: 'dtType', sourceField: 'dataTarget',
name: t('project.node.datax_target_datasource_type'), span: destinationDatasourceSpan
span: destinationDatasourceSpan, }),
props: {
loading: loading,
'on-update:value': onDestinationTypeChange
},
options: datasourceTypeOptions,
validate: {
trigger: ['input', 'blur'],
required: true
}
},
{
type: 'select',
field: 'dataTarget',
name: t('project.node.datax_target_database'),
span: destinationDatasourceSpan,
props: {
loading: loading
},
options: destinationDatasourceOptions,
validate: {
trigger: ['input', 'blur'],
required: true
}
},
{ {
type: 'input', type: 'input',
field: 'targetTable', field: 'targetTable',

2
dolphinscheduler-ui/src/views/projects/workflow/definition/use-table.ts

@ -185,7 +185,7 @@ export function useTable() {
{ {
title: t('project.workflow.operation'), title: t('project.workflow.operation'),
key: 'operation', key: 'operation',
...COLUMN_WIDTH_CONFIG['operation'](8.5), ...COLUMN_WIDTH_CONFIG['operation'](10),
render: (row) => render: (row) =>
h(TableAction, { h(TableAction, {
row, row,

Loading…
Cancel
Save