This is an automated email from the ASF dual-hosted git repository.

songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new cb454d7  [Feature][UI Next] Add mr into task. (#8444)
cb454d7 is described below

commit cb454d785f7048bd566a6cd91d40f2a18c2f3f07
Author: Amy0104 <[email protected]>
AuthorDate: Sat Feb 19 16:17:44 2022 +0800

    [Feature][UI Next] Add mr into task. (#8444)
---
 .../src/locales/modules/en_US.ts                   |   1 +
 .../src/locales/modules/zh_CN.ts                   |   1 +
 .../projects/task/components/node/fields/index.ts  |   1 +
 .../node/fields/{use-spark.ts => use-mr.ts}        | 167 +--------------------
 .../components/node/fields/use-process-name.ts     |  10 +-
 .../task/components/node/fields/use-spark.ts       |   6 +-
 .../projects/task/components/node/format-data.ts   |  20 ++-
 .../projects/task/components/node/tasks/use-mr.ts  |  82 ++++++++++
 .../views/projects/task/components/node/types.ts   |   4 +-
 .../projects/task/components/node/use-task.ts      |   9 ++
 10 files changed, 124 insertions(+), 177 deletions(-)

diff --git a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts 
b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
index ab4a09b..8ca116a 100644
--- a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
+++ b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
@@ -562,6 +562,7 @@ const project = {
     task_type: 'Task Type',
     task_type_tips: 'Please select a task type (required)',
     process_name: 'Process Name',
+    process_name_tips: 'Please select a process (required)',
     child_node: 'Child Node',
     enter_child_node: 'Enter child node',
     run_flag: 'Run flag',
diff --git a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts 
b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
index 1cd1470..3103a53 100644
--- a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
+++ b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
@@ -560,6 +560,7 @@ const project = {
     task_type: '任务类型',
     task_type_tips: '请选择任务类型(必选)',
     process_name: '工作流名称',
+    process_name_tips: '请选择工作流(必选)',
     child_node: '子节点',
     enter_child_node: '进入该子节点',
     run_flag: '运行标志',
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/index.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/index.ts
index 887a754..6aaf106 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/index.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/index.ts
@@ -32,3 +32,4 @@ export { useChildNode } from './use-child-node'
 
 export { useShell } from './use-shell'
 export { useSpark } from './use-spark'
+export { useMr } from './use-mr'
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-mr.ts
similarity index 58%
copy from 
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
copy to 
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-mr.ts
index e7c2f46..c0ea15e 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-mr.ts
@@ -18,9 +18,10 @@ import { ref, onMounted, computed } from 'vue'
 import { useI18n } from 'vue-i18n'
 import { queryResourceByProgramType } from '@/service/modules/resources'
 import { removeUselessChildren } from './use-shell'
+import { PROGRAM_TYPES, SPARK_VERSIONS, DeployModes } from './use-spark'
 import type { IJsonItem } from '../types'
 
-export function useSpark(model: { [field: string]: any }): IJsonItem[] {
+export function useMr(model: { [field: string]: any }): IJsonItem[] {
   const { t } = useI18n()
 
   const mainClassSpan = computed(() =>
@@ -67,14 +68,6 @@ export function useSpark(model: { [field: string]: any }): 
IJsonItem[] {
       value: model.programType
     },
     {
-      type: 'select',
-      field: 'sparkVersion',
-      span: 12,
-      name: t('project.node.spark_version'),
-      options: SPARK_VERSIONS,
-      value: model.sparkVersion
-    },
-    {
       type: 'input',
       field: 'mainClass',
       span: mainClassSpan,
@@ -116,12 +109,6 @@ export function useSpark(model: { [field: string]: any }): 
IJsonItem[] {
       options: mainJarOptions
     },
     {
-      type: 'radio',
-      field: 'deployMode',
-      name: t('project.node.deploy_mode'),
-      options: DeployModes
-    },
-    {
       type: 'input',
       field: 'appName',
       name: t('project.node.app_name'),
@@ -130,115 +117,6 @@ export function useSpark(model: { [field: string]: any 
}): IJsonItem[] {
       }
     },
     {
-      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'))
-          }
-        }
-      }
-    },
-    {
-      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')
-            )
-          }
-        }
-      },
-      value: model.driverMemory
-    },
-    {
-      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'))
-          }
-        }
-      },
-      value: model.numExecutors
-    },
-    {
-      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')
-            )
-          }
-        }
-      },
-      value: model.executorMemory
-    },
-    {
-      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'))
-          }
-        }
-      },
-      value: model.executorCores
-    },
-    {
       type: 'input',
       field: 'mainArgs',
       name: t('project.node.main_arguments'),
@@ -316,44 +194,3 @@ export function useSpark(model: { [field: string]: any }): 
IJsonItem[] {
     }
   ]
 }
-
-const PROGRAM_TYPES = [
-  {
-    label: 'JAVA',
-    value: 'JAVA'
-  },
-  {
-    label: 'SCALA',
-    value: 'SCALA'
-  },
-  {
-    label: 'PYTHON',
-    value: 'PYTHON'
-  }
-]
-
-const SPARK_VERSIONS = [
-  {
-    label: 'SPARK2',
-    value: 'SPARK2'
-  },
-  {
-    label: 'SPARK1',
-    value: 'SPARK1'
-  }
-]
-
-const DeployModes = [
-  {
-    label: 'cluster',
-    value: 'cluster'
-  },
-  {
-    label: 'client',
-    value: 'client'
-  },
-  {
-    label: 'local',
-    value: 'local'
-  }
-]
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts
index bce5889..b07e055 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts
@@ -23,7 +23,6 @@ import {
   queryProcessDefinitionByCode
 } from '@/service/modules/process-definition'
 import type { IJsonItem } from '../types'
-import { number } from 'echarts'
 
 export function useProcessName({
   model,
@@ -137,6 +136,15 @@ export function useProcessName({
       disabled: !isCreate,
       'on-update:value': onChange
     },
+    validate: {
+      trigger: ['input', 'blur'],
+      required: true,
+      validator(validate: any, value: string) {
+        if (!value) {
+          return new Error(t('project.node.process_name_tips'))
+        }
+      }
+    },
     options: options
   }
 }
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
index e7c2f46..ca4bf86 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
@@ -317,7 +317,7 @@ export function useSpark(model: { [field: string]: any }): 
IJsonItem[] {
   ]
 }
 
-const PROGRAM_TYPES = [
+export const PROGRAM_TYPES = [
   {
     label: 'JAVA',
     value: 'JAVA'
@@ -332,7 +332,7 @@ const PROGRAM_TYPES = [
   }
 ]
 
-const SPARK_VERSIONS = [
+export const SPARK_VERSIONS = [
   {
     label: 'SPARK2',
     value: 'SPARK2'
@@ -343,7 +343,7 @@ const SPARK_VERSIONS = [
   }
 ]
 
-const DeployModes = [
+export const DeployModes = [
   {
     label: 'cluster',
     value: 'cluster'
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
index b07b121..a7af766 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
@@ -28,9 +28,9 @@ export function formatParams(data: INodeData): {
     taskParams.programType = data.programType
     taskParams.sparkVersion = data.sparkVersion
     taskParams.mainClass = data.mainClass
-    taskParams.mainJar = data.mainJar?.length
-      ? data.mainJar.map((id: number) => ({ id }))
-      : []
+    if (data.mainJar) {
+      taskParams.mainJar = { id: data.mainJar }
+    }
     taskParams.deployMode = data.deployMode
     taskParams.appName = data.appName
     taskParams.driverCores = data.driverCores
@@ -41,6 +41,16 @@ export function formatParams(data: INodeData): {
     taskParams.mainArgs = data.mainArgs
     taskParams.others = data.others
   }
+  if (data.taskType === 'MR') {
+    taskParams.programType = data.programType
+    taskParams.mainClass = data.mainClass
+    if (data.mainJar) {
+      taskParams.mainJar = { id: data.mainJar }
+    }
+    taskParams.appName = data.appName
+    taskParams.mainArgs = data.mainArgs
+    taskParams.others = data.others
+  }
 
   const params = {
     processDefinitionCode: data.processName ? String(data.processName) : '',
@@ -109,9 +119,7 @@ export function formatModel(data: ITaskData) {
     )
   }
   if (data.taskParams?.mainJar) {
-    params.mainJar = data.taskParams.mainJar.map(
-      (item: { id: number }) => item.id
-    )
+    params.mainJar = data.taskParams?.mainJar.id
   }
   return params
 }
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts
 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts
new file mode 100644
index 0000000..3c018b7
--- /dev/null
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts
@@ -0,0 +1,82 @@
+/*
+ * 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 { reactive } from 'vue'
+import * as Fields from '../fields/index'
+import type { IJsonItem, INodeData, ITaskData } from '../types'
+
+export function useMr({
+  projectCode,
+  from = 0,
+  readonly,
+  data
+}: {
+  projectCode: number
+  from?: number
+  readonly?: boolean
+  data?: ITaskData
+}) {
+  const model = reactive({
+    taskType: 'MR',
+    name: '',
+    flag: 'YES',
+    description: '',
+    timeoutFlag: false,
+    localParams: [],
+    environmentCode: null,
+    failRetryInterval: 1,
+    failRetryTimes: 0,
+    workerGroup: 'default',
+    delayTime: 0,
+    timeout: 30,
+    programType: 'SCALA'
+  } 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.useMr(model),
+      Fields.usePreTasks(model)
+    ] as IJsonItem[],
+    model
+  }
+}
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts
index 3438871..18f2312 100644
--- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts
@@ -42,7 +42,7 @@ interface ISourceItem {
 
 interface ITaskParams {
   resourceList?: ISourceItem[]
-  mainJar?: ISourceItem[]
+  mainJar?: ISourceItem
   localParams?: ILocalParam[]
   rawScript?: string
   programType?: string
@@ -84,7 +84,7 @@ interface INodeData extends Omit<ITaskParams, 'resourceList' 
| 'mainJar'> {
   preTaskOptions?: []
   postTaskOptions?: []
   resourceList?: number[]
-  mainJar?: number[]
+  mainJar?: number
 }
 
 interface ITaskData
diff --git 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts
index a76d63e..354dd43 100644
--- 
a/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts
+++ 
b/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts
@@ -19,6 +19,7 @@ import { useShell } from './tasks/use-shell'
 import { useSubProcess } from './tasks/use-sub-process'
 import { usePython } from './tasks/use-python'
 import { useSpark } from './tasks/use-spark'
+import { useMr } from './tasks/use-mr'
 import { IJsonItem, INodeData, ITaskData } from './types'
 
 export function useTask({
@@ -66,5 +67,13 @@ export function useTask({
       data
     })
   }
+  if (taskType === 'MR') {
+    node = useMr({
+      projectCode,
+      from,
+      readonly,
+      data
+    })
+  }
   return node
 }

Reply via email to