You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ei...@apache.org on 2020/03/04 01:28:33 UTC

[incubator-dolphinscheduler] branch dev updated: 1. add input cache for datax task (#2034)

This is an automated email from the ASF dual-hosted git repository.

eights pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 3186545  1. add input cache for datax task (#2034)
3186545 is described below

commit 3186545da115aefceafc0cade91680856ec4cb51
Author: zhukai <bo...@qq.com>
AuthorDate: Wed Mar 4 09:28:23 2020 +0800

    1. add input cache for datax task (#2034)
    
    2. add cache for codemirror component, include python, shell and sql task.
---
 .../pages/dag/_source/formModel/tasks/datax.vue    | 49 +++++++++++++++++++++-
 .../pages/dag/_source/formModel/tasks/python.vue   | 34 ++++++++++++---
 .../pages/dag/_source/formModel/tasks/shell.vue    | 29 +++++++++++--
 .../home/pages/dag/_source/formModel/tasks/sql.vue | 44 ++++++++++++++++++-
 4 files changed, 145 insertions(+), 11 deletions(-)

diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue
index ce918f4..959610f 100755
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue
@@ -232,6 +232,8 @@
        * Processing code highlighting
        */
       _handlerEditor () {
+        this._destroyEditor()
+
         // editor
         editor = codemirror('code-sql-mirror', {
           mode: 'sql',
@@ -249,9 +251,34 @@
         // Monitor keyboard
         editor.on('keypress', this.keypress)
 
+        editor.on('changes', () => {
+          this._cacheParams()
+        })
+
         editor.setValue(this.sql)
 
         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 () {
@@ -286,7 +313,27 @@
         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 }
   }
 </script>
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/python.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/python.vue
index e565b4a..6f495d2 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/python.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/python.vue
@@ -129,6 +129,8 @@
        * Processing code highlighting
        */
       _handlerEditor () {
+        this._destroyEditor()
+
         // editor
         editor = codemirror('code-python-mirror', {
           mode: 'python',
@@ -143,26 +145,45 @@
           }
         }
 
+        this.changes = () => {
+          this._cacheParams()
+        }
+
         // Monitor keyboard
         editor.on('keypress', this.keypress)
 
+        editor.on('changes', this.changes)
+
         editor.setValue(this.rawScript)
 
         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 the cacheParams
       cacheParams (val) {
-        this.$emit('on-cache-params', val);
+        this._cacheParams()
       }
     },
     computed: {
       cacheParams () {
         return {
           resourceList: this.cacheResourceList,
-          localParams: this.localParams,
-          rawScript: editor ? editor.getValue() : ''
+          localParams: this.localParams
         }
       }
     },
@@ -193,8 +214,11 @@
       }, 200)
     },
     destroyed () {
-      editor.toTextArea() // Uninstall
-      editor.off($('.code-python-mirror'), 'keypress', this.keypress)
+      if (editor) {
+        editor.toTextArea() // Uninstall
+        editor.off($('.code-python-mirror'), 'keypress', this.keypress)
+        editor.off($('.code-python-mirror'), 'changes', this.changes)
+      }
     },
     components: { mLocalParams, mListBox, mResources }
   }
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/shell.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/shell.vue
index ad40c58..a4b20f3 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/shell.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/shell.vue
@@ -163,6 +163,8 @@
        * Processing code highlighting
        */
       _handlerEditor () {
+        this._destroyEditor()
+
         // editor
         editor = codemirror('code-shell-mirror', {
           mode: 'shell',
@@ -177,25 +179,45 @@
           }
         }
 
+        this.changes = () => {
+          this._cacheParams()
+        }
+
         // Monitor keyboard
         editor.on('keypress', this.keypress)
+
+        editor.on('changes', this.changes)
+
         editor.setValue(this.rawScript)
 
         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 the cacheParams
       cacheParams (val) {
-        this.$emit('on-cache-params', val);
+        this._cacheParams()
       }
     },
     computed: {
       cacheParams () {
         return {
           resourceList: this.cacheResourceList,
-          localParams: this.localParams,
-          rawScript: editor ? editor.getValue() : ''
+          localParams: this.localParams
         }
       }
     },
@@ -229,6 +251,7 @@
       if (editor) {
         editor.toTextArea() // Uninstall
         editor.off($('.code-shell-mirror'), 'keypress', this.keypress)
+        editor.off($('.code-shell-mirror'), 'changes', this.changes)
       }
     },
     components: { mLocalParams, mListBox, mResources, mScriptBox }
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue
index eb5c409..843c1ea 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue
@@ -318,6 +318,8 @@
        * Processing code highlighting
        */
       _handlerEditor () {
+        this._destroyEditor()
+
         // editor
         editor = codemirror('code-sql-mirror', {
           mode: 'sql',
@@ -332,9 +334,15 @@
           }
         }
 
+        this.changes = () => {
+          this._cacheParams()
+        }
+
         // Monitor keyboard
         editor.on('keypress', this.keypress)
 
+        editor.on('changes', this.changes)
+
         editor.setValue(this.sql)
 
         return editor
@@ -351,6 +359,38 @@
           this.receivers = res.receivers && res.receivers.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: {
@@ -373,7 +413,7 @@
       },
       //Watch the cacheParams
       cacheParams (val) {
-        this.$emit('on-cache-params', val);
+        this._cacheParams()
       }
     },
     created () {
@@ -418,6 +458,7 @@
       if (editor) {
         editor.toTextArea() // Uninstall
         editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
+        editor.off($('.code-sql-mirror'), 'changes', this.changes)
       }
     },
     computed: {
@@ -425,7 +466,6 @@
         return {
           type: this.type,
           datasource: this.rtDatasource,
-          sql: editor ? editor.getValue() : '',
           udfs: this.udfs,
           sqlType: this.sqlType,
           title: this.title,