From 42966bea973dd12588124a3a7142909c856e8a23 Mon Sep 17 00:00:00 2001 From: Wangyizhi1 <87303815+Wangyizhi1@users.noreply.github.com> Date: Fri, 10 Sep 2021 20:12:34 +0800 Subject: [PATCH] [Fix-6139][UI] fix some bugs in UI (#6163) * Disable delete button when the process is online * the jump affirm * process tree code * put the processInstanceId of Gantt * fix kinship bugs * modify lineage id to code --- .../home/pages/dag/_source/canvas/canvas.vue | 76 +++++++++---------- .../home/pages/dag/_source/canvas/toolbar.vue | 7 ++ .../js/conf/home/pages/dag/_source/dag.vue | 16 ++-- .../pages/dag/_source/jumpAffirm/index.js | 4 +- .../definition/pages/list/_source/list.vue | 2 +- .../pages/definition/pages/tree/index.vue | 42 +++++----- .../instance/pages/list/_source/list.vue | 4 +- .../pages/kinship/_source/graphGrid.vue | 11 +-- .../pages/kinship/_source/graphGridOption.js | 8 +- .../pages/projects/pages/kinship/index.vue | 5 +- .../src/js/conf/home/router/index.js | 2 +- .../src/js/conf/home/store/dag/actions.js | 8 +- .../src/js/conf/home/store/dag/mutations.js | 4 +- .../src/js/conf/home/store/dag/state.js | 2 +- .../src/js/conf/home/store/kinship/actions.js | 20 +++-- .../src/js/conf/home/store/kinship/state.js | 2 +- 16 files changed, 110 insertions(+), 103 deletions(-) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/canvas.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/canvas.vue index b25c9860bb..3bbeabf137 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/canvas.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/canvas.vue @@ -85,9 +85,7 @@ contextMenu }, computed: { - ...mapState('dag', [ - 'tasks' - ]) + ...mapState('dag', ['tasks']) }, methods: { ...mapActions('dag', ['genTaskCodeList']), @@ -237,7 +235,9 @@ this.graph.on('cell:mouseenter', (data) => { const { cell, e } = data const isStatusIcon = (tagName) => - tagName && (tagName.toLocaleLowerCase() === 'em' || tagName.toLocaleLowerCase() === 'body') + tagName && + (tagName.toLocaleLowerCase() === 'em' || + tagName.toLocaleLowerCase() === 'body') if (!isStatusIcon(e.target.tagName)) { this.setHighlight(cell) } @@ -381,42 +381,38 @@ * @param {Edge} edge */ setEdgeHighlight (edge) { - edge.setAttrs(EDGE_HIGHLIGHT_PROPS.attrs) const labelName = this.getEdgeLabelName(edge) - if (labelName) { - edge.setLabels([ - _.merge(EDGE_HIGHLIGHT_PROPS.defaultLabel, { - attrs: { - label: { - text: labelName - } - } - }) - ]) - } + edge.setAttrs(EDGE_HIGHLIGHT_PROPS.attrs) + edge.setLabels([ + _.merge( + { + attrs: _.cloneDeep(EDGE_HIGHLIGHT_PROPS.defaultLabel.attrs) + }, + { + attrs: { label: { text: labelName } } + } + ) + ]) }, /** * Reset edge style * @param {Edge} edge */ resetEdgeStyle (edge) { - edge.setAttrs(EDGE_PROPS.attrs) const labelName = this.getEdgeLabelName(edge) - if (labelName) { - edge.setLabels([ - { - attrs: { - label: { - fill: EDGE_PROPS.defaultLabel.attrs.label.fill, - text: labelName - }, - body: { - stroke: EDGE_PROPS.defaultLabel.attrs.body.stroke - } + edge.setAttrs(EDGE_PROPS.attrs) + edge.setLabels([ + { + ..._.merge( + { + attrs: _.cloneDeep(EDGE_PROPS.defaultLabel.attrs) + }, + { + attrs: { label: { text: labelName } } } - } - ]) - } + ) + } + ]) }, /** * Set cell highlight @@ -644,7 +640,7 @@ this.graph.removeCells(cells) cells.forEach((cell) => { if (cell.isNode()) { - this.removeTask(cell.id) + this.removeTask(+cell.id) } }) }, @@ -761,12 +757,12 @@ const nodes = this.getNodes() const edges = this.getEdges() const nodesMap = {} - nodes.forEach(node => { + nodes.forEach((node) => { nodesMap[node.id] = node }) return edges - .filter(edge => edge.targetId === code) - .map(edge => nodesMap[edge.sourceId]) + .filter((edge) => edge.targetId === code) + .map((edge) => nodesMap[edge.sourceId]) }, /** * set prev nodes @@ -786,7 +782,7 @@ } } }) - preNodeCodes.forEach(preCode => { + preNodeCodes.forEach((preCode) => { if (currPreCodes.includes(preCode) || preCode === code) return const edge = this.genEdgeJSON(preCode, code) this.graph.addEdge(edge) @@ -802,12 +798,12 @@ const nodes = this.getNodes() const edges = this.getEdges() const nodesMap = {} - nodes.forEach(node => { + nodes.forEach((node) => { nodesMap[node.id] = node }) return edges - .filter(edge => edge.sourceId === code) - .map(edge => nodesMap[edge.targetId]) + .filter((edge) => edge.sourceId === code) + .map((edge) => nodesMap[edge.targetId]) }, /** * set post nodes @@ -827,7 +823,7 @@ } } }) - postNodeCodes.forEach(postCode => { + postNodeCodes.forEach((postCode) => { if (currPostCodes.includes(postCode) || postCode === code) return const edge = this.genEdgeJSON(code, postCode) this.graph.addEdge(edge) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/toolbar.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/toolbar.vue index 83e6a5366d..4fcde2cfe1 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/toolbar.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/toolbar.vue @@ -55,6 +55,7 @@ class="toolbar-operation" :content="$t('Delete selected lines or nodes')" placement="bottom" + v-if="!isDetails" > @@ -135,6 +136,7 @@ diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/_source/graphGridOption.js b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/_source/graphGridOption.js index 1352e24e1d..ac08521050 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/_source/graphGridOption.js +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/_source/graphGridOption.js @@ -17,8 +17,8 @@ import _ from 'lodash' import i18n from '@/module/i18n/index.js' -const getCategory = (categoryDic, { workFlowPublishStatus, schedulePublishStatus, id }, sourceWorkFlowId) => { - if (id === sourceWorkFlowId) return categoryDic.active +const getCategory = (categoryDic, { workFlowPublishStatus, schedulePublishStatus, code }, sourceWorkFlowCode) => { + if (code === sourceWorkFlowCode) return categoryDic.active switch (true) { case workFlowPublishStatus === '0': return categoryDic['0'] @@ -30,7 +30,7 @@ const getCategory = (categoryDic, { workFlowPublishStatus, schedulePublishStatus } } -export default function (locations, links, sourceWorkFlowId, isShowLabel) { +export default function (locations, links, sourceWorkFlowCode, isShowLabel) { const categoryDic = { active: { color: '#2D8DF0', category: i18n.$t('KinshipStateActive') }, 1: { color: '#00C800', category: i18n.$t('KinshipState1') }, @@ -38,7 +38,7 @@ export default function (locations, links, sourceWorkFlowId, isShowLabel) { 10: { color: '#FF8F05', category: i18n.$t('KinshipState10') } } const newData = _.map(locations, (item) => { - const { color, category } = getCategory(categoryDic, item, sourceWorkFlowId) + const { color, category } = getCategory(categoryDic, item, sourceWorkFlowCode) return { ...item, emphasis: { diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/index.vue index f3dd3990f5..68d06e61c9 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/index.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/kinship/index.vue @@ -22,12 +22,13 @@ :placeholder="$t('Process Name')" @change="onChange" :style="inputFocusStyle" + v-model="currentItemName" v-tooltip="tooltipOption(currentItemName)" size="small"> diff --git a/dolphinscheduler-ui/src/js/conf/home/router/index.js b/dolphinscheduler-ui/src/js/conf/home/router/index.js index 5e3a6c9b92..d2aed56d08 100644 --- a/dolphinscheduler-ui/src/js/conf/home/router/index.js +++ b/dolphinscheduler-ui/src/js/conf/home/router/index.js @@ -139,7 +139,7 @@ const router = new Router({ } }, { - path: '/projects/:projectCode/definition/tree/:id', + path: '/projects/:projectCode/definition/tree/:code', name: 'definition-tree-view-index', component: resolve => require(['../pages/projects/pages/definition/pages/tree/index'], resolve), meta: { diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js index 12437bc975..d1dabb4ed8 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -144,7 +144,7 @@ export default { // timeout state.timeout = res.data.processDefinition.timeout // tenantId - state.tenantCode = res.data.processDefinition.tenantCode + state.tenantCode = res.data.processDefinition.tenantCode || 'default' // tasks info state.tasks = res.data.taskDefinitionList.map(task => _.pick(task, [ 'code', @@ -240,7 +240,7 @@ export default { // timeout state.timeout = processDefinition.timeout // tenantCode - state.tenantCode = res.data.tenantCode + state.tenantCode = res.data.tenantCode || 'default' // tasks info state.tasks = taskDefinitionList.map(task => _.pick(task, [ 'code', @@ -760,7 +760,7 @@ export default { */ getViewTree ({ state }, payload) { return new Promise((resolve, reject) => { - io.get(`projects/${state.projectCode}/process-definition/${payload.code}/view-tree`, payload, res => { + io.get(`projects/${state.projectCode}/process-definition/${payload.code}/view-tree`, { limit: payload.limit }, res => { resolve(res.data) }).catch(e => { reject(e) @@ -772,7 +772,7 @@ export default { */ getViewGantt ({ state }, payload) { return new Promise((resolve, reject) => { - io.get(`projects/${state.projectCode}/process-instances/${payload.code}/view-gantt`, payload, res => { + io.get(`projects/${state.projectCode}/process-instances/${payload.processInstanceId}/view-gantt`, payload, res => { resolve(res.data) }).catch(e => { reject(e) diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js index b974fed118..a89b09c886 100755 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js @@ -113,7 +113,7 @@ export default { state.name = (payload && payload.name) || '' state.description = (payload && payload.description) || '' state.timeout = (payload && payload.timeout) || 0 - state.tenantCode = (payload && payload.tenantCode) || '' + state.tenantCode = (payload && payload.tenantCode) || 'default' state.processListS = (payload && payload.processListS) || [] state.resourcesListS = (payload && payload.resourcesListS) || [] state.resourcesListJar = (payload && payload.resourcesListJar) || [] @@ -128,6 +128,7 @@ export default { * @param {Task} task */ addTask (state, task) { + state.isEditDag = true const i = _.findIndex(state.tasks, v => v.code === task.code) if (i !== -1) { state.tasks[i] = Object.assign(state.tasks[i], {}, task) @@ -141,6 +142,7 @@ export default { * @param {string} code */ removeTask (state, code) { + state.isEditDag = true state.tasks = state.tasks.filter(task => task.code !== code) }, resetLocalParam (state, payload) { diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js index 6750300430..61e1af14ac 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js @@ -38,7 +38,7 @@ export default { // Timeout alarm timeout: 0, // tenant code - tenantCode: '', + tenantCode: 'default', // Node location information locations: {}, // Node relations diff --git a/dolphinscheduler-ui/src/js/conf/home/store/kinship/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/kinship/actions.js index d2d1e17fc4..019dc85575 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/kinship/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/kinship/actions.js @@ -26,7 +26,7 @@ export default { getWorkFlowList ({ state }, payload) { const projectCode = localStore.getItem('projectCode') return new Promise((resolve, reject) => { - const url = `lineages/${projectCode}/list-name` + const url = `projects/${projectCode}/lineages/query-by-name` io.get(url, { searchVal: payload }, res => { @@ -34,7 +34,7 @@ export default { if (res.data) { _.map(res.data, (item) => { workList.push({ - id: `${item.workFlowId}`, + code: `${item.workFlowCode}`, name: item.workFlowName }) }) @@ -52,15 +52,13 @@ export default { getWorkFlowDAG ({ state }, payload) { const projectCode = localStore.getItem('projectCode') return new Promise((resolve, reject) => { - const url = `lineages/${projectCode}/list-ids` - io.get(url, { - ids: payload - }, res => { + const url = `projects/${projectCode}/lineages/list` + io.get(url, { code: payload }, res => { let locations = [] let connects = [] if (res.data.workFlowList) { - locations = _.uniqBy(res.data.workFlowList, 'workFlowId').map((item) => ({ - id: `${item.workFlowId}`, + locations = _.uniqBy(res.data.workFlowList, 'workFlowCode').map((item) => ({ + code: `${item.workFlowCode}`, name: item.workFlowName, workFlowPublishStatus: item.workFlowPublishStatus, scheduleStartTime: item.scheduleStartTime, @@ -71,11 +69,11 @@ export default { } if (res.data.workFlowRelationList) { connects = _.map(res.data.workFlowRelationList, (item) => ({ - source: `${item.sourceWorkFlowId}`, // should be string, or connects will not show by echarts - target: `${item.targetWorkFlowId}` // should be string, or connects will not show by echarts + source: `${item.sourceWorkFlowCode}`, // should be string, or connects will not show by echarts + target: `${item.targetWorkFlowCode}` // should be string, or connects will not show by echarts })) } - state.sourceWorkFlowId = payload || '' + state.sourceWorkFlowCode = payload || '' // locations state.locations = locations /* JSON.parse(locations) */ // connects diff --git a/dolphinscheduler-ui/src/js/conf/home/store/kinship/state.js b/dolphinscheduler-ui/src/js/conf/home/store/kinship/state.js index 6f22b86477..8f07de5c70 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/kinship/state.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/kinship/state.js @@ -16,7 +16,7 @@ */ export default { - sourceWorkFlowId: '', + sourceWorkFlowCode: '', workList: [], locations: [], connects: []