From 2087f464fb0eb7e362ca2abffb9700eb6ee8fd53 Mon Sep 17 00:00:00 2001 From: zhukai Date: Tue, 7 Jan 2020 21:59:50 +0800 Subject: [PATCH] Implements the sql type task, now it can be cache the previous input. (#1745) --- .../pages/dag/_source/formModel/formModel.vue | 1 + .../formModel/tasks/_source/datasource.vue | 17 +++++++-- .../pages/dag/_source/formModel/tasks/sql.vue | 35 +++++++++++++++++-- .../src/js/conf/home/store/dag/actions.js | 5 +++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue index 7e3853f104..9d6a10f545 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue @@ -143,6 +143,7 @@ diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/datasource.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/datasource.vue index 8bf855b720..aa067d80e4 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/datasource.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/datasource.vue @@ -112,7 +112,20 @@ }) } }, - watch: {}, + computed: { + cacheParams () { + return { + type: this.type, + datasource: this.datasource + } + } + }, + // Watch the cacheParams + watch: { + cacheParams (val) { + this.$emit('on-dsData', val); + } + }, created () { let supportType = this.supportType || [] this.typeList = _.cloneDeep(this.store.state.dag.dsTypeListS) @@ -146,4 +159,4 @@ }, components: { } } - \ No newline at end of file + 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 7ab032a798..eb5c40992e 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 @@ -371,6 +371,10 @@ this.connParams = '' } }, + //Watch the cacheParams + cacheParams (val) { + this.$emit('on-cache-params', val); + } }, created () { let o = this.backfillItem @@ -396,7 +400,8 @@ this.receivers = o.params.receivers && o.params.receivers.split(',') || [] this.receiversCc = o.params.receiversCc && o.params.receiversCc.split(',') || [] } - if (!_.some(this.store.state.dag.tasks, { id: this.createNodeId }) && + // read tasks from cache + if (!_.some(this.store.state.dag.cacheTasks, { id: this.createNodeId }) && this.router.history.current.name !== 'definition-create') { this._getReceiver() } @@ -415,7 +420,33 @@ editor.off($('.code-sql-mirror'), 'keypress', this.keypress) } }, - computed: {}, + computed: { + cacheParams () { + return { + 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 + } + } + }, components: { mListBox, mDatasource, mLocalParams, mUdfs, mSqlType, mStatementList, mEmail } } 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 b854dc8ade..52237a63ef 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -110,6 +110,11 @@ export default { let processDefinitionJson = JSON.parse(res.data.processDefinitionJson) // tasks info state.tasks = processDefinitionJson.tasks + // tasks cache + state.cacheTasks = {} + processDefinitionJson.tasks.forEach(v => { + state.cacheTasks[v.id] = v + }) // global params state.globalParams = processDefinitionJson.globalParams // timeout