Browse Source

Remove the new label label function

pull/3/MERGE
break60 4 years ago
parent
commit
e5f239530c
  1. 54
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
  2. 122
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formLineModel.vue
  3. 41
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js
  4. 8
      dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js

54
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue

@ -166,7 +166,7 @@
}, },
methods: { methods: {
...mapActions('dag', ['saveDAGchart', 'updateInstance', 'updateDefinition', 'getTaskState']), ...mapActions('dag', ['saveDAGchart', 'updateInstance', 'updateDefinition', 'getTaskState']),
...mapMutations('dag', ['addTasks', 'cacheTasks', 'resetParams', 'setIsEditDag', 'setName', 'addConnects']), ...mapMutations('dag', ['addTasks', 'cacheTasks', 'resetParams', 'setIsEditDag', 'setName']),
// DAG automatic layout // DAG automatic layout
dagAutomaticLayout() { dagAutomaticLayout() {
@ -195,14 +195,9 @@
length: 12, length: 12,
foldback: 0.8 foldback: 0.8
} }
]
], ],
['Label', { Container: 'canvas'
location: 0.5,
id: 'label'
}]
],
Container: 'canvas',
ConnectionsDetachable: true
}) })
}) })
if (this.tasks.length) { if (this.tasks.length) {
@ -508,40 +503,6 @@
* Create a node popup layer * Create a node popup layer
* @param Object id * @param Object id
*/ */
_createLineLabel({id, sourceId, targetId}) {
// $('#jsPlumb_2_50').text('111')
let self = this
self.$modal.destroy()
const removeNodesEvent = (fromThis) => {
// Manually destroy events inside the component
fromThis.$destroy()
// Close the popup
eventModel.remove()
}
eventModel = this.$drawer({
className: 'dagMask',
render (h) {
return h(mFormLineModel,{
on: {
addLineInfo ({ item, fromThis }) {
self.addConnects(item)
setTimeout(() => {
removeNodesEvent(fromThis)
}, 100)
},
cancel ({fromThis}) {
removeNodesEvent(fromThis)
}
},
props: {
id: id,
sourceId: sourceId,
targetId: targetId
}
})
}
})
},
_createNodes ({ id, type }) { _createNodes ({ id, type }) {
let self = this let self = this
self.$modal.destroy() self.$modal.destroy()
@ -676,14 +637,9 @@
length: 12, length: 12,
foldback: 0.8 foldback: 0.8
} }
]
], ],
['Label', { Container: 'canvas'
location: 0.5,
id: 'label'
}]
],
Container: 'canvas',
ConnectionsDetachable: true
}) })
}) })
}, },

122
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formLineModel.vue

@ -1,122 +0,0 @@
/*
* 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.
*/
<template>
<div class="form-model-model" v-clickoutside="_handleClose">
<div class="title-box">
<span class="name">{{$t('Current connection settings')}}</span>
</div>
<div class="content-box">
<div class="from-model">
<!-- Node name -->
<div class="clearfix list">
<div class="text-box"><span>{{$t('Connection name')}}</span></div>
<div class="cont-box">
<label class="label-box">
<x-input
type="text"
v-model="labelName"
:disabled="isDetails"
:placeholder="$t('Please enter name')"
maxlength="100"
autocomplete="off">
</x-input>
</label>
</div>
</div>
</div>
</div>
<div class="bottom-box">
<div class="submit" style="background: #fff;">
<x-button type="text" @click="cancel()"> {{$t('Cancel')}} </x-button>
<x-button type="primary" shape="circle" :loading="spinnerLoading" @click="ok()" :disabled="isDetails">{{spinnerLoading ? 'Loading...' : $t('Confirm add')}} </x-button>
</div>
</div>
</div>
</template>
<script>
import _ from 'lodash'
import { mapActions } from 'vuex'
import i18n from '@/module/i18n'
import JSP from './../plugIn/jsPlumbHandle'
import disabledState from '@/module/mixin/disabledState'
export default {
name: 'form-line-model',
data () {
return {
// loading
spinnerLoading: false,
// node name
labelName: '',
}
},
mixins: [disabledState],
props: {
id: String,
sourceId: String,
targetId: String
},
methods: {
cancel() {
this.$emit('cancel', {
fromThis: this
})
},
ok() {
if($(`#${this.id}`).prev().attr('class')==='jtk-overlay') {
$(`#${this.id}`).prev().empty()
}
$(`#${this.id}`).text(this.labelName)
this.$emit('addLineInfo', {
item: {
labelName: this.labelName,
sourceId: this.sourceId,
targetId: this.targetId
},
fromThis: this
})
}
},
watch: {
},
created () {
if($(`#${this.id}`).prev().attr('class').indexOf('jtk-overlay')!==-1) {
this.labelName = $(`#${this.id}`).prev().text()
} else {
this.labelName = $(`#${this.id}`).text()
}
},
mounted () {
},
updated () {
},
beforeDestroy () {
},
destroyed () {
},
computed: {
},
components: {}
}
</script>
<style lang="scss" rel="stylesheet/scss">
</style>

41
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js

@ -83,11 +83,8 @@ JSP.prototype.init = function ({ dag, instance, options }) {
// Monitor line click // Monitor line click
this.JspInstance.bind('click', e => { this.JspInstance.bind('click', e => {
// Untie event
if (this.config.isClick) { if (this.config.isClick) {
this.connectClick(e) this.connectClick(e)
} else {
findComponentDownward(this.dag.$root, 'dag-chart')._createLineLabel({id: e._jsPlumb.overlays.label.canvas.id, sourceId: e.sourceId, targetId: e.targetId})
} }
}) })
@ -654,39 +651,13 @@ JSP.prototype.saveStore = function () {
tasks.push(tasksParam) tasks.push(tasksParam)
} }
}) })
if(store.state.dag.connects.length ===this.JspInstance.getConnections().length) {
_.map(store.state.dag.connects, u => {
connects.push({
endPointSourceId: u.endPointSourceId,
endPointTargetId: u.endPointTargetId,
label: u.label
})
})
} else if(store.state.dag.connects.length>0 && store.state.dag.connects.length < this.JspInstance.getConnections().length) {
_.map(this.JspInstance.getConnections(), v => {
connects.push({
endPointSourceId: v.sourceId,
endPointTargetId: v.targetId,
label: v._jsPlumb.overlays.label.canvas.innerText
})
})
_.map(store.state.dag.connects, u => {
_.map(connects, v => {
if(u.label && u.endPointSourceId === v.endPointSourceId && u.endPointTargetId===v.endPointTargetId) {
v.label = u.label
}
})
})
} else if(store.state.dag.connects.length===0) {
_.map(this.JspInstance.getConnections(), v => { _.map(this.JspInstance.getConnections(), v => {
connects.push({ connects.push({
endPointSourceId: v.sourceId, endPointSourceId: v.sourceId,
endPointTargetId: v.targetId, endPointTargetId: v.targetId
label: v._jsPlumb.overlays.label.canvas.innerText
}) })
}) })
}
_.map(tasksAll(), v => { _.map(tasksAll(), v => {
locations[v.id] = { locations[v.id] = {
name: v.name, name: v.name,
@ -779,7 +750,6 @@ JSP.prototype.jspBackfill = function ({ connects, locations, largeJson }) {
_.map(connects, v => { _.map(connects, v => {
let sourceId = v.endPointSourceId.split('-') let sourceId = v.endPointSourceId.split('-')
let targetId = v.endPointTargetId.split('-') let targetId = v.endPointTargetId.split('-')
let labels = v.label
if (sourceId.length === 4 && targetId.length === 4) { if (sourceId.length === 4 && targetId.length === 4) {
sourceId = `${sourceId[0]}-${sourceId[1]}-${sourceId[2]}` sourceId = `${sourceId[0]}-${sourceId[1]}-${sourceId[2]}`
targetId = `${targetId[0]}-${targetId[1]}-${targetId[2]}` targetId = `${targetId[0]}-${targetId[1]}-${targetId[2]}`
@ -795,7 +765,7 @@ JSP.prototype.jspBackfill = function ({ connects, locations, largeJson }) {
type: 'basic', type: 'basic',
paintStyle: { strokeWidth: 2, stroke: '#4caf50' }, paintStyle: { strokeWidth: 2, stroke: '#4caf50' },
HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}, HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3},
overlays:[["Label", { label: labels} ]] overlays:[["Label", { label: i18n.$t('success'), location:0.5, id:"label"} ]]
}) })
} else if($(`#${sourceId}`).attr('data-tasks-type') === 'CONDITIONS' && $(`#${sourceId}`).attr('data-failednode') === $(`#${targetId}`).find('.name-p').text()) { } else if($(`#${sourceId}`).attr('data-tasks-type') === 'CONDITIONS' && $(`#${sourceId}`).attr('data-failednode') === $(`#${targetId}`).find('.name-p').text()) {
this.JspInstance.connect({ this.JspInstance.connect({
@ -804,7 +774,7 @@ JSP.prototype.jspBackfill = function ({ connects, locations, largeJson }) {
type: 'basic', type: 'basic',
paintStyle: { strokeWidth: 2, stroke: '#252d39' }, paintStyle: { strokeWidth: 2, stroke: '#252d39' },
HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}, HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3},
overlays:[["Label", { label: labels} ]] overlays:[["Label", { label: i18n.$t('failed'), location:0.5, id:"label"} ]]
}) })
} else { } else {
this.JspInstance.connect({ this.JspInstance.connect({
@ -812,8 +782,7 @@ JSP.prototype.jspBackfill = function ({ connects, locations, largeJson }) {
target: targetId, target: targetId,
type: 'basic', type: 'basic',
paintStyle: { strokeWidth: 2, stroke: '#2d8cf0' }, paintStyle: { strokeWidth: 2, stroke: '#2d8cf0' },
HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}, HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}
overlays:[["Label", { label: labels} ]]
}) })
} }
}) })

8
dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js

@ -140,14 +140,6 @@ export default {
y: parseInt(dom.css('top'), 10) y: parseInt(dom.css('top'), 10)
}) })
}, },
addConnects(state, payload) {
state.connects = _.map(state.connects, v => {
if(v.endPointSourceId===payload.sourceId && v.endPointTargetId===payload.targetId) {
v.label = payload.labelName
}
return v
})
},
/** /**
* Cache the input * Cache the input
* @param state * @param state

Loading…
Cancel
Save