From bf74b4280fa7c98ea3ec5c5c995bfe0d2f3710d1 Mon Sep 17 00:00:00 2001 From: songjianet <1778651752@qq.com> Date: Thu, 10 Nov 2022 17:28:20 +0800 Subject: [PATCH] [Feature][UI] Joint debugging of the interface of the mvp version of the dynamic task component. (#12859) * [Feature][UI] Joint debugging of the interface of the mvp version of the dynamic task component. * [Feature][UI] Joint debugging of the interface of the mvp version of the dynamic task component. * [Feature][UI] Joint debugging of the interface of the mvp version of the dynamic task component. --- .../src/service/modules/dynamic-dag/index.ts | 39 ++++++ .../components/dynamic-dag/dag-sidebar.tsx | 4 +- .../workflow/components/dynamic-dag/index.tsx | 20 +++- .../components/dynamic-dag/task/index.tsx | 8 +- .../dynamic-dag/task/use-task-form.ts | 113 ++---------------- .../components/dynamic-dag/use-sidebar.ts | 14 ++- 6 files changed, 83 insertions(+), 115 deletions(-) create mode 100644 dolphinscheduler-ui/src/service/modules/dynamic-dag/index.ts diff --git a/dolphinscheduler-ui/src/service/modules/dynamic-dag/index.ts b/dolphinscheduler-ui/src/service/modules/dynamic-dag/index.ts new file mode 100644 index 0000000000..c52e763d79 --- /dev/null +++ b/dolphinscheduler-ui/src/service/modules/dynamic-dag/index.ts @@ -0,0 +1,39 @@ +/* + * 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 { axios } from '@/service/service' + +export function queryDynamicTaskCategories(): any { + return axios({ + url: '/dynamic/taskCategories', + method: 'get' + }) +} + +export function queryDynamicTaskResourceList(categories: string): any { + return axios({ + url: `/dynamic/${categories}/taskTypes`, + method: 'get' + }) +} + +export function queryDynamicTaskResource(url: string): any { + return axios({ + url, + method: 'get' + }) +} \ No newline at end of file diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx index cf933a1bd8..b44da1d183 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx @@ -42,10 +42,10 @@ const DagSidebar = defineComponent({ return (
{ - this.taskList.map(task => { + this.taskList.map((task: any) => { return (
this.handleDragstart(task)}> - {task} + {task.name}
) }) diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx index becf9a38af..db2fa0bf5e 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/index.tsx @@ -21,16 +21,22 @@ import { DagCanvas } from './dag-canvas' import { useDagStore } from '@/store/project/dynamic/dag' import { NodeShape, NodeHeight, NodeWidth } from './dag-setting' import { TaskForm } from './task' +import { queryDynamicTaskResource } from '@/service/modules/dynamic-dag' import styles from './index.module.scss' const DynamicDag = defineComponent({ name: 'DynamicDag', setup() { - const draggedTask = ref('') + const draggedTask = ref() + const formData = ref() const showModal = ref(false) - const handelDragstart = (task: string) => { - draggedTask.value = task + const handelDragstart = (task: any) => { + draggedTask.value = task.name + + queryDynamicTaskResource(task.json).then((res: any) => { + formData.value = res + }) } const handelDrop = (e: DragEvent) => { @@ -45,9 +51,9 @@ const DynamicDag = defineComponent({ width: NodeWidth, height: NodeHeight, shape: NodeShape, - label: draggedTask.value + String(shapes.length + 1), + label: draggedTask.value.name + String(shapes.length + 1), zIndex: 1, - task: draggedTask.value + task: draggedTask.value.name }) useDagStore().setDagTasks(shapes) @@ -57,6 +63,7 @@ const DynamicDag = defineComponent({ return { draggedTask, + formData, handelDragstart, handelDrop, showModal @@ -70,8 +77,9 @@ const DynamicDag = defineComponent({
{ - this.draggedTask && this.showModal = false} onConfirmModal={() => this.showModal = false} diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx index fad2c65bf5..79a4ee9a30 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/task/index.tsx @@ -30,6 +30,9 @@ const props = { }, task: { type: String as PropType + }, + formData: { + type: Object as PropType } } @@ -39,7 +42,7 @@ const TaskForm = defineComponent({ emits: ['cancelModal', 'confirmModal'], setup(props, ctx) { const trim = getCurrentInstance()?.appContext.config.globalProperties.trim - const { variables } = useTaskForm() + const { variables, handleValidate } = useTaskForm(props.formData) const { t } = useI18n() const cancelModal = () => { @@ -47,6 +50,7 @@ const TaskForm = defineComponent({ } const confirmModal = () => { + handleValidate() ctx.emit('confirmModal') } @@ -80,7 +84,7 @@ const TaskForm = defineComponent({ return ( { + variables.taskForm.validate((err: any) => { + if (err) return + }) + } + return { - variables + variables, + handleValidate } } diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-sidebar.ts b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-sidebar.ts index a5d2c5ce60..ce5ac51584 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-sidebar.ts +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/use-sidebar.ts @@ -16,6 +16,7 @@ */ import { reactive } from 'vue' +import { queryDynamicTaskCategories, queryDynamicTaskResourceList } from '@/service/modules/dynamic-dag' export function useSidebar() { const variables = reactive({ @@ -23,8 +24,15 @@ export function useSidebar() { }) const getTaskList = () => { - variables.taskList = ['shell'] as any + queryDynamicTaskCategories().then((resC: any) => { + queryDynamicTaskResourceList(resC[0]).then((res: any) => { + variables.taskList = res + }) + }) } - return { variables, getTaskList } -} \ No newline at end of file + return { + variables, + getTaskList + } +}