From 89f84ed166181ad36b0780caad296e5b9d78c8ce Mon Sep 17 00:00:00 2001 From: calvin Date: Thu, 22 Dec 2022 17:17:23 +0800 Subject: [PATCH] cherry-pick [Fix-13248][UI] Ironed out the issue with failing to query task instances by some state of task. #13251 --- dolphinscheduler-ui/src/common/common.ts | 60 +------------------ dolphinscheduler-ui/src/common/types.ts | 7 --- .../modules/process-instances/types.ts | 4 +- .../src/store/project/types.ts | 49 ++++++++++++++- .../components/node/fields/use-dependent.ts | 2 +- .../projects/workflow/instance/use-table.ts | 40 +++++++++++-- 6 files changed, 87 insertions(+), 75 deletions(-) diff --git a/dolphinscheduler-ui/src/common/common.ts b/dolphinscheduler-ui/src/common/common.ts index e8701184a2..4cddddd6a7 100644 --- a/dolphinscheduler-ui/src/common/common.ts +++ b/dolphinscheduler-ui/src/common/common.ts @@ -26,10 +26,8 @@ import { CheckCircleFilled, Loading3QuartersOutlined, PauseCircleFilled, - ClockCircleOutlined, StopFilled, StopOutlined, - GlobalOutlined, IssuesCloseOutlined, SendOutlined, HistoryOutlined @@ -207,14 +205,6 @@ export const tasksState = (t: any): ITaskStateConfig => ({ isSpin: true, classNames: 'running_execution' }, - READY_PAUSE: { - id: 2, - desc: `${t('project.workflow.ready_to_pause')}`, - color: '#07b1a3', - icon: SettingOutlined, - isSpin: false, - classNames: 'ready_pause' - }, PAUSE: { id: 3, desc: `${t('project.workflow.pause')}`, @@ -223,22 +213,6 @@ export const tasksState = (t: any): ITaskStateConfig => ({ isSpin: false, classNames: 'pause' }, - READY_STOP: { - id: 4, - desc: `${t('project.workflow.ready_to_stop')}`, - color: '#FE0402', - icon: StopFilled, - isSpin: false, - classNames: 'ready_stop' - }, - STOP: { - id: 5, - desc: `${t('project.workflow.stop')}`, - color: '#e90101', - icon: StopOutlined, - isSpin: false, - classNames: 'stop' - }, FAILURE: { id: 6, desc: `${t('project.workflow.failed')}`, @@ -271,22 +245,6 @@ export const tasksState = (t: any): ITaskStateConfig => ({ isSpin: false, classNames: 'kill' }, - WAITING_THREAD: { - id: 10, - desc: `${t('project.workflow.waiting_for_thread')}`, - color: '#912eed', - icon: ClockCircleOutlined, - isSpin: false, - classNames: 'waiting_thread' - }, - WAITING_DEPEND: { - id: 11, - desc: `${t('project.workflow.waiting_for_dependence')}`, - color: '#5101be', - icon: GlobalOutlined, - isSpin: false, - classNames: 'waiting_depend' - }, DELAY_EXECUTION: { id: 12, desc: `${t('project.workflow.delay_execution')}`, @@ -303,30 +261,14 @@ export const tasksState = (t: any): ITaskStateConfig => ({ isSpin: false, classNames: 'forced_success' }, - SERIAL_WAIT: { - id: 14, - desc: `${t('project.workflow.serial_wait')}`, - color: '#5102ce', - icon: Loading3QuartersOutlined, - isSpin: true, - classNames: 'serial_wait' - }, DISPATCH: { - id: 15, + id: 17, desc: `${t('project.workflow.dispatch')}`, color: '#5101be', icon: SendOutlined, isSpin: false, classNames: 'dispatch' }, - PENDING: { - id: 18, - desc: `${t('project.workflow.pending')}`, - color: '#5101be', - icon: HistoryOutlined, - isSpin: false, - classNames: 'pending' - } }) /** diff --git a/dolphinscheduler-ui/src/common/types.ts b/dolphinscheduler-ui/src/common/types.ts index 5f6688e618..a07a13c005 100644 --- a/dolphinscheduler-ui/src/common/types.ts +++ b/dolphinscheduler-ui/src/common/types.ts @@ -19,21 +19,14 @@ import { Component } from 'vue' export type ITaskState = | 'SUBMITTED_SUCCESS' | 'RUNNING_EXECUTION' - | 'READY_PAUSE' | 'PAUSE' - | 'READY_STOP' - | 'STOP' | 'FAILURE' | 'SUCCESS' | 'NEED_FAULT_TOLERANCE' | 'KILL' - | 'WAITING_THREAD' - | 'WAITING_DEPEND' | 'DELAY_EXECUTION' | 'FORCED_SUCCESS' - | 'SERIAL_WAIT' | 'DISPATCH' - | 'PENDING' export type IWorkflowExecutionState = | 'SUBMITTED_SUCCESS' diff --git a/dolphinscheduler-ui/src/service/modules/process-instances/types.ts b/dolphinscheduler-ui/src/service/modules/process-instances/types.ts index adbafb915c..bd7df17004 100644 --- a/dolphinscheduler-ui/src/service/modules/process-instances/types.ts +++ b/dolphinscheduler-ui/src/service/modules/process-instances/types.ts @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import type { ITaskState } from '@/common/types' +import type { IWorkflowExecutionState } from '@/common/types' interface CodeReq { projectCode: number @@ -86,7 +86,7 @@ interface ProcessInstanceReq { interface IWorkflowInstance { id: number name: string - state: ITaskState + state: IWorkflowExecutionState commandType: string scheduleTime?: string processDefinitionCode?: number diff --git a/dolphinscheduler-ui/src/store/project/types.ts b/dolphinscheduler-ui/src/store/project/types.ts index 147a84503e..71073c8e89 100644 --- a/dolphinscheduler-ui/src/store/project/types.ts +++ b/dolphinscheduler-ui/src/store/project/types.ts @@ -18,12 +18,57 @@ import type { EditWorkflowDefinition } from '@/views/projects/workflow/components/dag/types' import type { IOption } from '@/components/form/types' +<<<<<<< HEAD type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON' | 'SQL' +======= +type TaskExecuteType = 'STREAM' | 'BATCH' + +type TaskType = + | 'SHELL' + | 'SUB_PROCESS' + | 'PROCEDURE' + | 'SQL' + | 'SPARK' + | 'FLINK' + | 'MR' + | 'PYTHON' + | 'DEPENDENT' + | 'HTTP' + | 'DATAX' + | 'PIGEON' + | 'SQOOP' + | 'CONDITIONS' + | 'DATA_QUALITY' + | 'SWITCH' + | 'SEATUNNEL' + | 'EMR' + | 'ZEPPELIN' + | 'K8S' + | 'JUPYTER' + | 'MLFLOW' + | 'OPENMLDB' + | 'DVC' + | 'JAVA' + | 'DINKY' + | 'SAGEMAKER' + | 'CHUNJUN' + | 'FLINK_STREAM' + | 'PYTORCH' + | 'HIVECLI' + | 'DMS' + | 'DATASYNC' + | 'KUBEFLOW' + | 'LINKIS' + +type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON' + +>>>>>>> 4e09bacb1 ([Fix-13248][UI] Ironed out the issue with failing to query task instances by some state of task. (#13251)) type DependentResultType = { - [key: string]: 'SUCCESS' | 'WAITING_THREAD' | 'FAILURE' + [key: string]: 'SUCCESS' | 'FAILURE' } + type BDependentResultType = { - [key: string]: 'SUCCESS' | 'WAITING_THREAD' | 'FAILED' + [key: string]: 'SUCCESS' | 'FAILED' } interface IResource { diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts index 77149418c1..fdf757f95a 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts @@ -226,7 +226,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] { if (!item || router.currentRoute.value.name !== 'workflow-instance-detail') return null const key = `${item.definitionCode}-${item.depTaskCode}-${item.cycle}-${item.dateValue}` - const state: ITaskState = dependentResult[key] || 'WAITING_THREAD' + const state: ITaskState = dependentResult[key] return h(NIcon, { size: 24, color: TasksStateConfig[state].color }, () => h(TasksStateConfig[state].icon) ) diff --git a/dolphinscheduler-ui/src/views/projects/workflow/instance/use-table.ts b/dolphinscheduler-ui/src/views/projects/workflow/instance/use-table.ts index 08e4d312fa..1fb0628a39 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/instance/use-table.ts +++ b/dolphinscheduler-ui/src/views/projects/workflow/instance/use-table.ts @@ -21,7 +21,8 @@ import { useI18n } from 'vue-i18n' import { useRouter } from 'vue-router' import ButtonLink from '@/components/button-link' import { RowKey } from 'naive-ui/lib/data-table/src/interface' -import { NEllipsis } from 'naive-ui' + +import {NEllipsis, NIcon, NSpin, NTooltip} from 'naive-ui' import { queryProcessInstanceListPaging, deleteProcessInstanceById, @@ -29,8 +30,11 @@ import { } from '@/service/modules/process-instances' import { execute } from '@/service/modules/executors' import TableAction from './components/table-action' -import { renderTableTime, runningType } from '@/common/common' -import { renderStateCell } from '../../task/instance/use-table' + +import { + renderTableTime, + runningType, workflowExecutionState +} from '@/common/common' import { COLUMN_WIDTH_CONFIG, calculateTableWidth, @@ -41,6 +45,8 @@ import type { IWorkflowInstance } from '@/service/modules/process-instances/type import type { ICountDownParam } from './types' import type { ExecuteReq } from '@/service/modules/executors/types' +import { IWorkflowExecutionState } from "@/common/types"; + export function useTable() { const { t } = useI18n() const router: Router = useRouter() @@ -107,7 +113,7 @@ export function useTable() { key: 'state', ...COLUMN_WIDTH_CONFIG['state'], className: 'workflow-status', - render: (_row: IWorkflowInstance) => renderStateCell(_row.state, t) + render: (_row: IWorkflowInstance) => renderWorkflowStateCell(_row.state, t) }, { title: t('project.workflow.run_type'), @@ -341,3 +347,29 @@ export function useTable() { batchDeleteInstance } } + +export function renderWorkflowStateCell(state: IWorkflowExecutionState, t: Function) { + if (!state) return '' + + const stateOption = workflowExecutionState(t)[state] + + const Icon = h( + NIcon, + { + color: stateOption.color, + class: stateOption.classNames, + style: { + display: 'flex' + }, + size: 20 + }, + () => h(stateOption.icon) + ) + return h(NTooltip, null, { + trigger: () => { + if (!stateOption.isSpin) return Icon + return h(NSpin, { size: 20 }, { icon: () => Icon }) + }, + default: () => stateOption.desc + }) +}