From 4e09bacb17c5a5d554815be03916960f354d45a1 Mon Sep 17 00:00:00 2001 From: calvin Date: Thu, 22 Dec 2022 17:17:23 +0800 Subject: [PATCH] [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 | 6 +- .../components/node/fields/use-dependent.ts | 2 +- .../projects/workflow/instance/use-table.ts | 34 +++++++++-- 6 files changed, 38 insertions(+), 75 deletions(-) diff --git a/dolphinscheduler-ui/src/common/common.ts b/dolphinscheduler-ui/src/common/common.ts index 5928658023..aa98186c5d 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 @@ -210,14 +208,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')}`, @@ -226,22 +216,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')}`, @@ -274,22 +248,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')}`, @@ -306,30 +264,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 6cadb0d4fd..ca6f79ce1a 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 050190cf40..e801f4a1eb 100644 --- a/dolphinscheduler-ui/src/store/project/types.ts +++ b/dolphinscheduler-ui/src/store/project/types.ts @@ -58,11 +58,13 @@ type TaskType = | 'LINKIS' type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON' + 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 e51f21857e..68e487e239 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,7 @@ 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, @@ -31,9 +31,8 @@ import { execute } from '@/service/modules/executors' import TableAction from './components/table-action' import { renderTableTime, - runningType + runningType, workflowExecutionState } from '@/common/common' -import { renderStateCell } from '../../task/instance/use-table' import { COLUMN_WIDTH_CONFIG, calculateTableWidth, @@ -44,6 +43,7 @@ import type { IWorkflowInstance } from '@/service/modules/process-instances/type import type { ICountDownParam } from './types' import type { ExecuteReq } from '@/service/modules/executors/types' import {renderEnvironmentalDistinctionCell} from "@/utils/environmental-distinction"; +import { IWorkflowExecutionState } from "@/common/types"; export function useTable() { const { t } = useI18n() @@ -117,7 +117,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.operating_environment'), @@ -359,3 +359,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 + }) +}