Amy0104
3 years ago
committed by
GitHub
31 changed files with 1038 additions and 434 deletions
@ -0,0 +1,45 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useDeployMode(span = 24): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'radio', |
||||||
|
field: 'deployMode', |
||||||
|
name: t('project.node.deploy_mode'), |
||||||
|
options: DEPLOY_MODES, |
||||||
|
span |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export const DEPLOY_MODES = [ |
||||||
|
{ |
||||||
|
label: 'cluster', |
||||||
|
value: 'cluster' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'client', |
||||||
|
value: 'client' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'local', |
||||||
|
value: 'local' |
||||||
|
} |
||||||
|
] |
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useDriverCores(): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'input-number', |
||||||
|
field: 'driverCores', |
||||||
|
name: t('project.node.driver_cores'), |
||||||
|
span: 12, |
||||||
|
props: { |
||||||
|
placeholder: t('project.node.driver_cores_tips'), |
||||||
|
min: 1 |
||||||
|
}, |
||||||
|
validate: { |
||||||
|
trigger: ['input', 'blur'], |
||||||
|
required: true, |
||||||
|
validator(validate: any, value: string) { |
||||||
|
if (!value) { |
||||||
|
return new Error(t('project.node.driver_cores_tips')) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useDriverMemory(): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'input', |
||||||
|
field: 'driverMemory', |
||||||
|
name: t('project.node.driver_memory'), |
||||||
|
span: 12, |
||||||
|
props: { |
||||||
|
placeholder: t('project.node.driver_memory_tips') |
||||||
|
}, |
||||||
|
validate: { |
||||||
|
trigger: ['input', 'blur'], |
||||||
|
required: true, |
||||||
|
validator(validate: any, value: string) { |
||||||
|
if (!value) { |
||||||
|
return new Error(t('project.node.driver_memory_tips')) |
||||||
|
} |
||||||
|
if (!Number.isInteger(parseInt(value))) { |
||||||
|
return new Error( |
||||||
|
t('project.node.driver_memory') + |
||||||
|
t('project.node.positive_integer_tips') |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useExecutorCores(): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'input-number', |
||||||
|
field: 'executorCores', |
||||||
|
name: t('project.node.executor_cores'), |
||||||
|
span: 12, |
||||||
|
props: { |
||||||
|
placeholder: t('project.node.executor_cores_tips'), |
||||||
|
min: 1 |
||||||
|
}, |
||||||
|
validate: { |
||||||
|
trigger: ['input', 'blur'], |
||||||
|
required: true, |
||||||
|
validator(validate: any, value: string) { |
||||||
|
if (!value) { |
||||||
|
return new Error(t('project.node.executor_cores_tips')) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useExecutorMemory(): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'input', |
||||||
|
field: 'executorMemory', |
||||||
|
name: t('project.node.executor_memory'), |
||||||
|
span: 12, |
||||||
|
props: { |
||||||
|
placeholder: t('project.node.executor_memory_tips') |
||||||
|
}, |
||||||
|
validate: { |
||||||
|
trigger: ['input', 'blur'], |
||||||
|
required: true, |
||||||
|
validator(validate: any, value: string) { |
||||||
|
if (!value) { |
||||||
|
return new Error(t('project.node.executor_memory_tips')) |
||||||
|
} |
||||||
|
if (!Number.isInteger(parseInt(value))) { |
||||||
|
return new Error( |
||||||
|
t('project.node.executor_memory_tips') + |
||||||
|
t('project.node.positive_integer_tips') |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import type { IJsonItem } from '../types' |
||||||
|
|
||||||
|
export function useExecutorNumber(): IJsonItem { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return { |
||||||
|
type: 'input-number', |
||||||
|
field: 'numExecutors', |
||||||
|
name: t('project.node.executor_number'), |
||||||
|
span: 12, |
||||||
|
props: { |
||||||
|
placeholder: t('project.node.executor_number_tips'), |
||||||
|
min: 1 |
||||||
|
}, |
||||||
|
validate: { |
||||||
|
trigger: ['input', 'blur'], |
||||||
|
required: true, |
||||||
|
validator(validate: any, value: string) { |
||||||
|
if (!value) { |
||||||
|
return new Error(t('project.node.executor_number_tips')) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,214 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
import { ref, onMounted } from 'vue' |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import { |
||||||
|
queryRuleList, |
||||||
|
getRuleFormCreateJson, |
||||||
|
getDatasourceOptionsById |
||||||
|
} from '@/service/modules/data-quality' |
||||||
|
import { |
||||||
|
getDatasourceTablesById, |
||||||
|
getDatasourceTableColumnsById |
||||||
|
} from '@/service/modules/data-source' |
||||||
|
import type { IJsonItem, IResponseJsonItem, IJsonItemParams } from '../types' |
||||||
|
|
||||||
|
export function useRules( |
||||||
|
model: { [field: string]: any }, |
||||||
|
updateRules: (items: IJsonItem[], len: number) => void |
||||||
|
): IJsonItem[] { |
||||||
|
const { t } = useI18n() |
||||||
|
const rules = ref([]) |
||||||
|
const ruleLoading = ref(false) |
||||||
|
const srcDatasourceOptions = ref([] as { label: string; value: number }[]) |
||||||
|
const srcTableOptions = ref([] as { label: string; value: number }[]) |
||||||
|
const srcTableColumnOptions = ref([] as { label: string; value: number }[]) |
||||||
|
const targetDatasourceOptions = ref([] as { label: string; value: number }[]) |
||||||
|
const targetTableOptions = ref([] as { label: string; value: string }[]) |
||||||
|
const targetTableColumnOptions = ref([] as { label: string; value: number }[]) |
||||||
|
const writerDatasourceOptions = ref([] as { label: string; value: number }[]) |
||||||
|
|
||||||
|
let preItemLen = 0 |
||||||
|
|
||||||
|
const getRuleList = async () => { |
||||||
|
if (ruleLoading.value) return |
||||||
|
ruleLoading.value = true |
||||||
|
try { |
||||||
|
const result = await queryRuleList() |
||||||
|
rules.value = result.map((item: { id: number; name: string }) => { |
||||||
|
let name = '' |
||||||
|
if (item.name) { |
||||||
|
name = item.name.replace('$t(', '').replace(')', '') |
||||||
|
} |
||||||
|
return { |
||||||
|
value: item.id, |
||||||
|
label: name ? t(`project.node.${name}`) : '' |
||||||
|
} |
||||||
|
}) |
||||||
|
ruleLoading.value = false |
||||||
|
} catch (err) { |
||||||
|
ruleLoading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const getRuleById = async (ruleId: number) => { |
||||||
|
if (ruleLoading.value) return |
||||||
|
ruleLoading.value = true |
||||||
|
try { |
||||||
|
const result = await getRuleFormCreateJson(ruleId) |
||||||
|
const items = JSON.parse(result).map((item: IResponseJsonItem) => |
||||||
|
formatResponseJson(item) |
||||||
|
) |
||||||
|
updateRules(items, preItemLen) |
||||||
|
preItemLen = items.length |
||||||
|
ruleLoading.value = false |
||||||
|
} catch (err) { |
||||||
|
ruleLoading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const formatResponseJson = ( |
||||||
|
responseItem: IResponseJsonItem |
||||||
|
): IJsonItemParams => { |
||||||
|
const item: IJsonItemParams = { |
||||||
|
field: responseItem.field, |
||||||
|
options: responseItem.options, |
||||||
|
validate: responseItem.validate, |
||||||
|
props: responseItem.props |
||||||
|
} |
||||||
|
let name = responseItem.name?.replace('$t(', '').replace(')', '') |
||||||
|
item.name = name ? t(`project.node.${name}`) : '' |
||||||
|
|
||||||
|
if (responseItem.type !== 'group') { |
||||||
|
item.type = responseItem.type |
||||||
|
} else { |
||||||
|
item.type = 'custom-parameters' |
||||||
|
item.children = item.props.rules.map((child: IJsonItemParams) => { |
||||||
|
child.span = Math.floor(22 / item.props.rules.length) |
||||||
|
return child |
||||||
|
}) |
||||||
|
model[item.field] = [] |
||||||
|
delete item.props.rules |
||||||
|
} |
||||||
|
if (responseItem.emit) { |
||||||
|
responseItem.emit.forEach((emit) => { |
||||||
|
if (emit === 'change') { |
||||||
|
item.props.onUpdateValue = (value: string | number) => { |
||||||
|
onFieldChange(value, item.field) |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
if (item.field === 'src_datasource_id') { |
||||||
|
item.options = srcDatasourceOptions |
||||||
|
} |
||||||
|
if (item.field === 'target_datasource_id') { |
||||||
|
item.options = targetDatasourceOptions |
||||||
|
} |
||||||
|
if (item.field === 'writer_datasource_id') { |
||||||
|
item.options = writerDatasourceOptions |
||||||
|
} |
||||||
|
if (item.field === 'src_table') { |
||||||
|
item.options = srcTableOptions |
||||||
|
} |
||||||
|
if (item.field === 'target_table') { |
||||||
|
item.options = targetTableOptions |
||||||
|
} |
||||||
|
if (item.field === 'src_field') { |
||||||
|
item.options = srcTableColumnOptions |
||||||
|
} |
||||||
|
if (item.field === 'target_field') { |
||||||
|
item.options = targetTableColumnOptions |
||||||
|
} |
||||||
|
return item |
||||||
|
} |
||||||
|
|
||||||
|
const onFieldChange = async (value: string | number, field: string) => { |
||||||
|
try { |
||||||
|
if (field === 'src_connector_type' && typeof value === 'number') { |
||||||
|
const result = await getDatasourceOptionsById(value) |
||||||
|
srcDatasourceOptions.value = result || [] |
||||||
|
srcTableOptions.value = [] |
||||||
|
model.src_datasource_id = null |
||||||
|
model.src_table = null |
||||||
|
model.src_field = null |
||||||
|
return |
||||||
|
} |
||||||
|
if (field === 'target_connector_type' && typeof value === 'number') { |
||||||
|
const result = await getDatasourceOptionsById(value) |
||||||
|
targetDatasourceOptions.value = result || [] |
||||||
|
targetTableOptions.value = [] |
||||||
|
model.target_datasource_id = null |
||||||
|
model.target_table = null |
||||||
|
model.target_field = null |
||||||
|
return |
||||||
|
} |
||||||
|
if (field === 'writer_connector_type' && typeof value === 'number') { |
||||||
|
const result = await getDatasourceOptionsById(value) |
||||||
|
writerDatasourceOptions.value = result || [] |
||||||
|
model.writer_datasource_id = null |
||||||
|
return |
||||||
|
} |
||||||
|
if (field === 'src_datasource_id' && typeof value === 'number') { |
||||||
|
const result = await getDatasourceTablesById(value) |
||||||
|
srcTableOptions.value = result || [] |
||||||
|
model.src_table = null |
||||||
|
model.src_field = null |
||||||
|
} |
||||||
|
if (field === 'target_datasource_id' && typeof value === 'number') { |
||||||
|
const result = await getDatasourceTablesById(value) |
||||||
|
targetTableOptions.value = result || [] |
||||||
|
model.target_table = null |
||||||
|
model.target_field = null |
||||||
|
} |
||||||
|
if (field === 'src_table' && typeof value === 'string') { |
||||||
|
const result = await getDatasourceTableColumnsById( |
||||||
|
model.src_datasource_id, |
||||||
|
value |
||||||
|
) |
||||||
|
srcTableColumnOptions.value = result || [] |
||||||
|
model.src_field = null |
||||||
|
} |
||||||
|
if (field === 'target_table' && typeof value === 'string') { |
||||||
|
const result = await getDatasourceTableColumnsById( |
||||||
|
model.target_datasource_id, |
||||||
|
value |
||||||
|
) |
||||||
|
targetTableColumnOptions.value = result || [] |
||||||
|
model.target_field = null |
||||||
|
} |
||||||
|
} catch (err) {} |
||||||
|
} |
||||||
|
|
||||||
|
onMounted(async () => { |
||||||
|
await getRuleList() |
||||||
|
await getRuleById(model.ruleId) |
||||||
|
}) |
||||||
|
|
||||||
|
return [ |
||||||
|
{ |
||||||
|
type: 'select', |
||||||
|
field: 'ruleId', |
||||||
|
name: t('project.node.rule_name'), |
||||||
|
props: { |
||||||
|
loading: ruleLoading, |
||||||
|
onUpdateValue: getRuleById |
||||||
|
}, |
||||||
|
options: rules |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import { useFlink } from './use-flink' |
||||||
|
import { useShell } from './use-shell' |
||||||
|
import { useSubProcess } from './use-sub-process' |
||||||
|
import { usePigeon } from './use-pigeon' |
||||||
|
import { usePython } from './use-python' |
||||||
|
import { useSpark } from './use-spark' |
||||||
|
import { useMr } from './use-mr' |
||||||
|
import { useHttp } from './use-http' |
||||||
|
import { useSql } from './use-sql' |
||||||
|
import { useProcedure } from './use-procedure' |
||||||
|
import { useSqoop } from './use-sqoop' |
||||||
|
import { useSeaTunnel } from './use-sea-tunnel' |
||||||
|
import { useSwitch } from './use-switch' |
||||||
|
import { useConditions } from './use-conditions' |
||||||
|
import { useDataX } from './use-datax' |
||||||
|
import { useDependent } from './use-dependent' |
||||||
|
import { useDataQuality } from './use-data-quality' |
||||||
|
|
||||||
|
export default { |
||||||
|
SHELL: useShell, |
||||||
|
SUB_PROCESS: useSubProcess, |
||||||
|
PYTHON: usePython, |
||||||
|
SPARK: useSpark, |
||||||
|
MR: useMr, |
||||||
|
FLINK: useFlink, |
||||||
|
HTTP: useHttp, |
||||||
|
PIGEON: usePigeon, |
||||||
|
SQL: useSql, |
||||||
|
PROCEDURE: useProcedure, |
||||||
|
SQOOP: useSqoop, |
||||||
|
SEATUNNEL: useSeaTunnel, |
||||||
|
SWITCH: useSwitch, |
||||||
|
CONDITIONS: useConditions, |
||||||
|
DATAX: useDataX, |
||||||
|
DEPENDENT: useDependent, |
||||||
|
DATA_QUALITY: useDataQuality |
||||||
|
} |
@ -0,0 +1,116 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import { Ref, reactive } from 'vue' |
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import * as Fields from '../fields/index' |
||||||
|
import type { IJsonItem, INodeData, ITaskData } from '../types' |
||||||
|
|
||||||
|
export function useDataQuality({ |
||||||
|
projectCode, |
||||||
|
from = 0, |
||||||
|
readonly, |
||||||
|
data, |
||||||
|
jsonRef |
||||||
|
}: { |
||||||
|
projectCode: number |
||||||
|
from?: number |
||||||
|
readonly?: boolean |
||||||
|
data?: ITaskData |
||||||
|
jsonRef: Ref<IJsonItem[]> |
||||||
|
}) { |
||||||
|
const { t } = useI18n() |
||||||
|
const model = reactive({ |
||||||
|
taskType: 'DATA_QUALITY', |
||||||
|
name: '', |
||||||
|
flag: 'YES', |
||||||
|
description: '', |
||||||
|
timeoutFlag: false, |
||||||
|
timeoutNotifyStrategy: ['WARN'], |
||||||
|
timeout: 30, |
||||||
|
localParams: [], |
||||||
|
environmentCode: null, |
||||||
|
failRetryInterval: 1, |
||||||
|
failRetryTimes: 0, |
||||||
|
workerGroup: 'default', |
||||||
|
delayTime: 0, |
||||||
|
ruleId: 1, |
||||||
|
deployMode: 'cluster', |
||||||
|
driverCores: 1, |
||||||
|
driverMemory: '512M', |
||||||
|
numExecutors: 2, |
||||||
|
executorMemory: '2G', |
||||||
|
executorCores: 2, |
||||||
|
others: '--conf spark.yarn.maxAppAttempts=1' |
||||||
|
} as INodeData) |
||||||
|
|
||||||
|
let extra: IJsonItem[] = [] |
||||||
|
if (from === 1) { |
||||||
|
extra = [ |
||||||
|
Fields.useTaskType(model, readonly), |
||||||
|
Fields.useProcessName({ |
||||||
|
model, |
||||||
|
projectCode, |
||||||
|
isCreate: !data?.id, |
||||||
|
from, |
||||||
|
processName: data?.processName, |
||||||
|
code: data?.code |
||||||
|
}) |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
json: [ |
||||||
|
Fields.useName(), |
||||||
|
...extra, |
||||||
|
Fields.useRunFlag(), |
||||||
|
Fields.useDescription(), |
||||||
|
Fields.useTaskPriority(), |
||||||
|
Fields.useWorkerGroup(), |
||||||
|
Fields.useEnvironmentName(model, !data?.id), |
||||||
|
...Fields.useTaskGroup(model, projectCode), |
||||||
|
...Fields.useFailed(), |
||||||
|
Fields.useDelayTime(model), |
||||||
|
...Fields.useTimeoutAlarm(model), |
||||||
|
...Fields.useRules(model, (items: IJsonItem[], len: number) => { |
||||||
|
jsonRef.value.splice(17, len, ...items) |
||||||
|
}), |
||||||
|
Fields.useDeployMode(), |
||||||
|
Fields.useDriverCores(), |
||||||
|
Fields.useDriverMemory(), |
||||||
|
Fields.useExecutorNumber(), |
||||||
|
Fields.useExecutorMemory(), |
||||||
|
Fields.useExecutorCores(), |
||||||
|
{ |
||||||
|
type: 'input', |
||||||
|
field: 'others', |
||||||
|
name: t('project.node.option_parameters'), |
||||||
|
props: { |
||||||
|
type: 'textarea', |
||||||
|
placeholder: t('project.node.option_parameters_tips') |
||||||
|
} |
||||||
|
}, |
||||||
|
...Fields.useCustomParams({ |
||||||
|
model, |
||||||
|
field: 'localParams', |
||||||
|
isSimple: true |
||||||
|
}), |
||||||
|
Fields.usePreTasks(model) |
||||||
|
] as IJsonItem[], |
||||||
|
model |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue