Browse Source

[Bug][UI Next][V1.0.0-Alpha] Fix workflow instance save is not responding bug (#8926)

* fix workflow instance save is not responding bug

* add WorkflowInstance interface
3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
276a68a23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      dolphinscheduler-ui-next/src/locales/modules/en_US.ts
  2. 1
      dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
  3. 5
      dolphinscheduler-ui-next/src/service/modules/process-instances/index.ts
  4. 4
      dolphinscheduler-ui-next/src/service/modules/process-instances/types.ts
  5. 7
      dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx
  6. 18
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-save-modal.tsx
  7. 5
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx
  8. 5
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx
  9. 14
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/types.ts
  10. 61
      dolphinscheduler-ui-next/src/views/projects/workflow/instance/detail/index.tsx

1
dolphinscheduler-ui-next/src/locales/modules/en_US.ts

@ -586,6 +586,7 @@ const project = {
success: 'Success', success: 'Success',
delete_cell: 'Delete selected edges and nodes', delete_cell: 'Delete selected edges and nodes',
online_directly: 'Whether to go online the process definition', online_directly: 'Whether to go online the process definition',
update_directly: 'Whether to update the process definition',
dag_name_empty: 'DAG graph name cannot be empty', dag_name_empty: 'DAG graph name cannot be empty',
positive_integer: 'Please enter a positive integer greater than 0', positive_integer: 'Please enter a positive integer greater than 0',
prop_empty: 'prop is empty', prop_empty: 'prop is empty',

1
dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts

@ -583,6 +583,7 @@ const project = {
success: '成功', success: '成功',
delete_cell: '删除选中的线或节点', delete_cell: '删除选中的线或节点',
online_directly: '是否上线流程定义', online_directly: '是否上线流程定义',
update_directly: '是否更新流程定义',
dag_name_empty: 'DAG图名称不能为空', dag_name_empty: 'DAG图名称不能为空',
positive_integer: '请输入大于 0 的正整数', positive_integer: '请输入大于 0 的正整数',
prop_empty: '自定义参数prop不能为空', prop_empty: '自定义参数prop不能为空',

5
dolphinscheduler-ui-next/src/service/modules/process-instances/index.ts

@ -23,7 +23,6 @@ import {
SubIdReq, SubIdReq,
TaskReq, TaskReq,
LongestReq, LongestReq,
IdReq,
ProcessInstanceReq ProcessInstanceReq
} from './types' } from './types'
@ -94,8 +93,8 @@ export function queryProcessInstanceById(
export function updateProcessInstance( export function updateProcessInstance(
data: ProcessInstanceReq, data: ProcessInstanceReq,
id: IdReq, id: number,
code: CodeReq code: number
): any { ): any {
return axios({ return axios({
url: `/projects/${code}/process-instances/${id}`, url: `/projects/${code}/process-instances/${id}`,

4
dolphinscheduler-ui-next/src/service/modules/process-instances/types.ts

@ -71,7 +71,7 @@ interface IdReq {
} }
interface ProcessInstanceReq { interface ProcessInstanceReq {
syncDefine: string syncDefine: boolean
flag?: string flag?: string
globalParams?: string globalParams?: string
locations?: string locations?: string
@ -79,7 +79,7 @@ interface ProcessInstanceReq {
taskDefinitionJson?: string taskDefinitionJson?: string
taskRelationJson?: string taskRelationJson?: string
tenantCode?: string tenantCode?: string
timeout?: string timeout?: number
} }
interface IWorkflowInstance { interface IWorkflowInstance {

7
dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx

@ -38,7 +38,10 @@ import {
import { NIcon } from 'naive-ui' import { NIcon } from 'naive-ui'
import { TASK_TYPES_MAP } from '../../constants/task-type' import { TASK_TYPES_MAP } from '../../constants/task-type'
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import { IWorkflowTaskInstance } from '@/views/projects/workflow/components/dag/types' import {
IWorkflowTaskInstance,
WorkflowInstance
} from '@/views/projects/workflow/components/dag/types'
const props = { const props = {
show: { show: {
@ -65,7 +68,7 @@ const props = {
type: Object as PropType<any> type: Object as PropType<any>
}, },
processInstance: { processInstance: {
type: Object as PropType<any> type: Object as PropType<WorkflowInstance>
}, },
taskInstance: { taskInstance: {
type: Object as PropType<IWorkflowTaskInstance> type: Object as PropType<IWorkflowTaskInstance>

18
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-save-modal.tsx

@ -29,7 +29,7 @@ import {
NCheckbox NCheckbox
} from 'naive-ui' } from 'naive-ui'
import { queryTenantList } from '@/service/modules/tenants' import { queryTenantList } from '@/service/modules/tenants'
import { SaveForm, WorkflowDefinition } from './types' import { SaveForm, WorkflowDefinition, WorkflowInstance } from './types'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { verifyName } from '@/service/modules/process-definition' import { verifyName } from '@/service/modules/process-definition'
import './x6-style.scss' import './x6-style.scss'
@ -44,6 +44,10 @@ const props = {
definition: { definition: {
type: Object as PropType<WorkflowDefinition>, type: Object as PropType<WorkflowDefinition>,
default: undefined default: undefined
},
instance: {
type: Object as PropType<WorkflowInstance>,
default: undefined
} }
} }
@ -86,7 +90,8 @@ export default defineComponent({
timeoutFlag: false, timeoutFlag: false,
timeout: 0, timeout: 0,
globalParams: [], globalParams: [],
release: false release: false,
sync: false
}) })
const formRef = ref() const formRef = ref()
const rule = { const rule = {
@ -221,13 +226,20 @@ export default defineComponent({
class='input-global-params' class='input-global-params'
/> />
</NFormItem> </NFormItem>
{props.definition && ( {props.definition && !props.instance && (
<NFormItem path='timeoutFlag'> <NFormItem path='timeoutFlag'>
<NCheckbox v-model:checked={formValue.value.release}> <NCheckbox v-model:checked={formValue.value.release}>
{t('project.dag.online_directly')} {t('project.dag.online_directly')}
</NCheckbox> </NCheckbox>
</NFormItem> </NFormItem>
)} )}
{props.instance && (
<NFormItem path='sync'>
<NCheckbox v-model:checked={formValue.value.sync}>
{t('project.dag.update_directly')}
</NCheckbox>
</NFormItem>
)}
</NForm> </NForm>
</Modal> </Modal>
) )

5
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-toolbar.tsx

@ -40,6 +40,7 @@ import { useThemeStore } from '@/store/theme/theme'
import type { Graph } from '@antv/x6' import type { Graph } from '@antv/x6'
import StartupParam from './dag-startup-param' import StartupParam from './dag-startup-param'
import VariablesView from '@/views/projects/workflow/instance/components/variables-view' import VariablesView from '@/views/projects/workflow/instance/components/variables-view'
import { WorkflowDefinition, WorkflowInstance } from './types'
const props = { const props = {
layoutToggle: { layoutToggle: {
@ -48,12 +49,12 @@ const props = {
}, },
// If this prop is passed, it means from definition detail // If this prop is passed, it means from definition detail
instance: { instance: {
type: Object as PropType<any>, type: Object as PropType<WorkflowInstance>,
default: null default: null
}, },
definition: { definition: {
// The same as the structure responsed by the queryProcessDefinitionByCode api // The same as the structure responsed by the queryProcessDefinitionByCode api
type: Object as PropType<any>, type: Object as PropType<WorkflowDefinition>,
default: null default: null
} }
} }

5
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx

@ -44,7 +44,7 @@ import {
} from './dag-hooks' } from './dag-hooks'
import { useThemeStore } from '@/store/theme/theme' import { useThemeStore } from '@/store/theme/theme'
import VersionModal from '../../definition/components/version-modal' import VersionModal from '../../definition/components/version-modal'
import { WorkflowDefinition } from './types' import { WorkflowDefinition, WorkflowInstance } from './types'
import DagSaveModal from './dag-save-modal' import DagSaveModal from './dag-save-modal'
import ContextMenuItem from './dag-context-menu' import ContextMenuItem from './dag-context-menu'
import TaskModal from '@/views/projects/task/components/node/detail-modal' import TaskModal from '@/views/projects/task/components/node/detail-modal'
@ -55,7 +55,7 @@ import './x6-style.scss'
const props = { const props = {
// If this prop is passed, it means from definition detail // If this prop is passed, it means from definition detail
instance: { instance: {
type: Object as PropType<any>, type: Object as PropType<WorkflowInstance>,
default: undefined default: undefined
}, },
definition: { definition: {
@ -278,6 +278,7 @@ export default defineComponent({
v-model:show={saveModalShow.value} v-model:show={saveModalShow.value}
onSave={onSave} onSave={onSave}
definition={props.definition} definition={props.definition}
instance={props.instance}
/> />
<TaskModal <TaskModal
readonly={props.readonly} readonly={props.readonly}

14
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/types.ts

@ -102,6 +102,19 @@ export interface WorkflowDefinition {
taskDefinitionList: TaskDefinition[] taskDefinitionList: TaskDefinition[]
} }
export interface WorkflowInstance {
name: string
state: string
dagData: WorkflowDefinition
commandType: string
commandParam: string
failureStrategy: string
processInstancePriority: string
workerGroup: string
warningType: string
warningGroupId: number
}
export interface Dragged { export interface Dragged {
x: number x: number
y: number y: number
@ -126,6 +139,7 @@ export interface SaveForm {
timeout: number timeout: number
globalParams: GlobalParam[] globalParams: GlobalParam[]
release: boolean release: boolean
sync: boolean
} }
export interface Location { export interface Location {

61
dolphinscheduler-ui-next/src/views/projects/workflow/instance/detail/index.tsx

@ -16,23 +16,43 @@
*/ */
import { defineComponent, onMounted, ref } from 'vue' import { defineComponent, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useThemeStore } from '@/store/theme/theme' import { useThemeStore } from '@/store/theme/theme'
import { useI18n } from 'vue-i18n'
import Dag from '../../components/dag' import Dag from '../../components/dag'
import { queryProcessInstanceById } from '@/service/modules/process-instances' import {
import { WorkflowDefinition } from '../../components/dag/types' queryProcessInstanceById,
updateProcessInstance
} from '@/service/modules/process-instances'
import {
WorkflowDefinition,
WorkflowInstance,
SaveForm,
TaskDefinition,
Connect,
Location
} from '../../components/dag/types'
import Styles from './index.module.scss' import Styles from './index.module.scss'
interface SaveData {
saveForm: SaveForm
taskDefinitions: TaskDefinition[]
connects: Connect[]
locations: Location[]
}
export default defineComponent({ export default defineComponent({
name: 'WorkflowInstanceDetails', name: 'WorkflowInstanceDetails',
setup() { setup() {
const theme = useThemeStore() const theme = useThemeStore()
const route = useRoute() const route = useRoute()
const router = useRouter()
const { t } = useI18n()
const projectCode = Number(route.params.projectCode) const projectCode = Number(route.params.projectCode)
const id = Number(route.params.id) const id = Number(route.params.id)
const definition = ref<WorkflowDefinition>() const definition = ref<WorkflowDefinition>()
const instance = ref<any>() const instance = ref<WorkflowInstance>()
const refresh = () => { const refresh = () => {
queryProcessInstanceById(id, projectCode).then((res: any) => { queryProcessInstanceById(id, projectCode).then((res: any) => {
@ -43,7 +63,38 @@ export default defineComponent({
}) })
} }
const save = () => {} const save = ({
taskDefinitions,
saveForm,
connects,
locations
}: SaveData) => {
const globalParams = saveForm.globalParams.map((p) => {
return {
prop: p.key,
value: p.value,
direct: 'IN',
type: 'VARCHAR'
}
})
updateProcessInstance(
{
syncDefine: saveForm.sync,
globalParams: JSON.stringify(globalParams),
locations: JSON.stringify(locations),
taskDefinitionJson: JSON.stringify(taskDefinitions),
taskRelationJson: JSON.stringify(connects),
tenantCode: saveForm.tenantCode,
timeout: saveForm.timeoutFlag ? saveForm.timeout : 0
},
id,
projectCode
).then((ignored: any) => {
window.$message.success(t('project.dag.success'))
router.push({ path: `/projects/${projectCode}/workflow/instances` })
})
}
onMounted(() => { onMounted(() => {
if (!id || !projectCode) return if (!id || !projectCode) return

Loading…
Cancel
Save