未验证 提交 3186545d 编写于 作者: Z zhukai 提交者: GitHub

1. add input cache for datax task (#2034)

2. add cache for codemirror component, include python, shell and sql task.
上级 3277b906
...@@ -232,6 +232,8 @@ ...@@ -232,6 +232,8 @@
* Processing code highlighting * Processing code highlighting
*/ */
_handlerEditor () { _handlerEditor () {
this._destroyEditor()
// editor // editor
editor = codemirror('code-sql-mirror', { editor = codemirror('code-sql-mirror', {
mode: 'sql', mode: 'sql',
...@@ -249,9 +251,34 @@ ...@@ -249,9 +251,34 @@
// Monitor keyboard // Monitor keyboard
editor.on('keypress', this.keypress) editor.on('keypress', this.keypress)
editor.on('changes', () => {
this._cacheParams()
})
editor.setValue(this.sql) editor.setValue(this.sql)
return editor return editor
},
_cacheParams () {
this.$emit('on-cache-params', {
dsType: this.dsType,
dataSource: this.rtDatasource,
dtType: this.dtType,
dataTarget: this.rtDatatarget,
sql: editor?editor.getValue():'',
targetTable: this.targetTable,
jobSpeedByte: this.jobSpeedByte * 1024,
jobSpeedRecord: this.jobSpeedRecord,
preStatements: this.preStatements,
postStatements: this.postStatements
});
},
_destroyEditor () {
if (editor) {
editor.toTextArea() // Uninstall
editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
editor.off($('.code-sql-mirror'), 'changes', this.changes)
}
} }
}, },
created () { created () {
...@@ -286,7 +313,27 @@ ...@@ -286,7 +313,27 @@
editor.off($('.code-sql-mirror'), 'keypress', this.keypress) editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
} }
}, },
computed: {}, watch: {
//Watch the cacheParams
cacheParams (val) {
this._cacheParams();
}
},
computed: {
cacheParams () {
return {
dsType: this.dsType,
dataSource: this.rtDatasource,
dtType: this.dtType,
dataTarget: this.rtDatatarget,
targetTable: this.targetTable,
jobSpeedByte: this.jobSpeedByte * 1024,
jobSpeedRecord: this.jobSpeedRecord,
preStatements: this.preStatements,
postStatements: this.postStatements
}
}
},
components: { mListBox, mDatasource, mLocalParams, mStatementList, mSelectInput } components: { mListBox, mDatasource, mLocalParams, mStatementList, mSelectInput }
} }
</script> </script>
...@@ -129,6 +129,8 @@ ...@@ -129,6 +129,8 @@
* Processing code highlighting * Processing code highlighting
*/ */
_handlerEditor () { _handlerEditor () {
this._destroyEditor()
// editor // editor
editor = codemirror('code-python-mirror', { editor = codemirror('code-python-mirror', {
mode: 'python', mode: 'python',
...@@ -143,26 +145,45 @@ ...@@ -143,26 +145,45 @@
} }
} }
this.changes = () => {
this._cacheParams()
}
// Monitor keyboard // Monitor keyboard
editor.on('keypress', this.keypress) editor.on('keypress', this.keypress)
editor.on('changes', this.changes)
editor.setValue(this.rawScript) editor.setValue(this.rawScript)
return editor return editor
},
_cacheParams () {
this.$emit('on-cache-params', {
resourceList: this.cacheResourceList,
localParams: this.localParams,
rawScript: editor ? editor.getValue() : ''
});
},
_destroyEditor () {
if (editor) {
editor.toTextArea() // Uninstall
editor.off($('.code-python-mirror'), 'keypress', this.keypress)
editor.off($('.code-python-mirror'), 'changes', this.changes)
}
} }
}, },
watch: { watch: {
//Watch the cacheParams //Watch the cacheParams
cacheParams (val) { cacheParams (val) {
this.$emit('on-cache-params', val); this._cacheParams()
} }
}, },
computed: { computed: {
cacheParams () { cacheParams () {
return { return {
resourceList: this.cacheResourceList, resourceList: this.cacheResourceList,
localParams: this.localParams, localParams: this.localParams
rawScript: editor ? editor.getValue() : ''
} }
} }
}, },
...@@ -193,8 +214,11 @@ ...@@ -193,8 +214,11 @@
}, 200) }, 200)
}, },
destroyed () { destroyed () {
editor.toTextArea() // Uninstall if (editor) {
editor.off($('.code-python-mirror'), 'keypress', this.keypress) editor.toTextArea() // Uninstall
editor.off($('.code-python-mirror'), 'keypress', this.keypress)
editor.off($('.code-python-mirror'), 'changes', this.changes)
}
}, },
components: { mLocalParams, mListBox, mResources } components: { mLocalParams, mListBox, mResources }
} }
......
...@@ -163,6 +163,8 @@ ...@@ -163,6 +163,8 @@
* Processing code highlighting * Processing code highlighting
*/ */
_handlerEditor () { _handlerEditor () {
this._destroyEditor()
// editor // editor
editor = codemirror('code-shell-mirror', { editor = codemirror('code-shell-mirror', {
mode: 'shell', mode: 'shell',
...@@ -177,25 +179,45 @@ ...@@ -177,25 +179,45 @@
} }
} }
this.changes = () => {
this._cacheParams()
}
// Monitor keyboard // Monitor keyboard
editor.on('keypress', this.keypress) editor.on('keypress', this.keypress)
editor.on('changes', this.changes)
editor.setValue(this.rawScript) editor.setValue(this.rawScript)
return editor return editor
},
_cacheParams () {
this.$emit('on-cache-params', {
resourceList: this.cacheResourceList,
localParams: this.localParams,
rawScript: editor ? editor.getValue() : ''
});
},
_destroyEditor () {
if (editor) {
editor.toTextArea() // Uninstall
editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
editor.off($('.code-sql-mirror'), 'changes', this.changes)
}
} }
}, },
watch: { watch: {
//Watch the cacheParams //Watch the cacheParams
cacheParams (val) { cacheParams (val) {
this.$emit('on-cache-params', val); this._cacheParams()
} }
}, },
computed: { computed: {
cacheParams () { cacheParams () {
return { return {
resourceList: this.cacheResourceList, resourceList: this.cacheResourceList,
localParams: this.localParams, localParams: this.localParams
rawScript: editor ? editor.getValue() : ''
} }
} }
}, },
...@@ -229,6 +251,7 @@ ...@@ -229,6 +251,7 @@
if (editor) { if (editor) {
editor.toTextArea() // Uninstall editor.toTextArea() // Uninstall
editor.off($('.code-shell-mirror'), 'keypress', this.keypress) editor.off($('.code-shell-mirror'), 'keypress', this.keypress)
editor.off($('.code-shell-mirror'), 'changes', this.changes)
} }
}, },
components: { mLocalParams, mListBox, mResources, mScriptBox } components: { mLocalParams, mListBox, mResources, mScriptBox }
......
...@@ -318,6 +318,8 @@ ...@@ -318,6 +318,8 @@
* Processing code highlighting * Processing code highlighting
*/ */
_handlerEditor () { _handlerEditor () {
this._destroyEditor()
// editor // editor
editor = codemirror('code-sql-mirror', { editor = codemirror('code-sql-mirror', {
mode: 'sql', mode: 'sql',
...@@ -332,9 +334,15 @@ ...@@ -332,9 +334,15 @@
} }
} }
this.changes = () => {
this._cacheParams()
}
// Monitor keyboard // Monitor keyboard
editor.on('keypress', this.keypress) editor.on('keypress', this.keypress)
editor.on('changes', this.changes)
editor.setValue(this.sql) editor.setValue(this.sql)
return editor return editor
...@@ -351,6 +359,38 @@ ...@@ -351,6 +359,38 @@
this.receivers = res.receivers && res.receivers.split(',') || [] this.receivers = res.receivers && res.receivers.split(',') || []
this.receiversCc = res.receiversCc && res.receiversCc.split(',') || [] this.receiversCc = res.receiversCc && res.receiversCc.split(',') || []
}) })
},
_cacheParams () {
this.$emit('on-cache-params', {
type: this.type,
datasource: this.rtDatasource,
sql: editor ? editor.getValue() : '',
udfs: this.udfs,
sqlType: this.sqlType,
title: this.title,
receivers: this.receivers.join(','),
receiversCc: this.receiversCc.join(','),
showType: (() => {
let showType = this.showType
if (showType.length === 2 && showType[0] === 'ATTACHMENT') {
return [showType[1], showType[0]].join(',')
} else {
return showType.join(',')
}
})(),
localParams: this.localParams,
connParams: this.connParams,
preStatements: this.preStatements,
postStatements: this.postStatements
});
},
_destroyEditor () {
if (editor) {
editor.toTextArea() // Uninstall
editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
editor.off($('.code-sql-mirror'), 'changes', this.changes)
}
} }
}, },
watch: { watch: {
...@@ -373,7 +413,7 @@ ...@@ -373,7 +413,7 @@
}, },
//Watch the cacheParams //Watch the cacheParams
cacheParams (val) { cacheParams (val) {
this.$emit('on-cache-params', val); this._cacheParams()
} }
}, },
created () { created () {
...@@ -418,6 +458,7 @@ ...@@ -418,6 +458,7 @@
if (editor) { if (editor) {
editor.toTextArea() // Uninstall editor.toTextArea() // Uninstall
editor.off($('.code-sql-mirror'), 'keypress', this.keypress) editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
editor.off($('.code-sql-mirror'), 'changes', this.changes)
} }
}, },
computed: { computed: {
...@@ -425,7 +466,6 @@ ...@@ -425,7 +466,6 @@
return { return {
type: this.type, type: this.type,
datasource: this.rtDatasource, datasource: this.rtDatasource,
sql: editor ? editor.getValue() : '',
udfs: this.udfs, udfs: this.udfs,
sqlType: this.sqlType, sqlType: this.sqlType,
title: this.title, title: this.title,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册