Unverified Commit 3ced3d59 authored by 向偲彪's avatar 向偲彪 Committed by GitHub
Browse files

datax add custom and add branch flow node verification (#2218)

* Change DOM label

* Change name to lowercase

* Limit customization file content to no more than 3000 lines

* dd branch flow node verification

* datax

* datax add custom
parent 85f55cd5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@
        width: 36px;
        height: 36px;
        float: left;
        margin-bottom: 11px;
        margin-bottom: 8px;
        border-radius: 3px;
        .disabled {
          .icos {
+54 −37
Original line number Diff line number Diff line
@@ -326,6 +326,7 @@
       * Storage interface
       */
      _save (sourceType) {
        if(this._verifConditions()) {
          return new Promise((resolve, reject) => {
            this.spinnerLoading = true
            // Storage store
@@ -365,6 +366,22 @@
              }
            })
          })
        }
      },
      _verifConditions () {
        let tasks = this.$store.state.dag.tasks
        let bool = true
        tasks.map(v=>{
          if(v.type == 'CONDITIONS' && (v.conditionResult.successNode[0] =='' || v.conditionResult.successNode[0] == null || v.conditionResult.failedNode[0] =='' || v.conditionResult.failedNode[0] == null)) {
            bool = false
            return false
          }
        })
        if(!bool) {
          this.$message.warning(`${i18n.$t('Successful branch flow and failed branch flow are required')}`)
          return false
        }
        return true
      },
      /**
       * Global parameter
+2 −2
Original line number Diff line number Diff line
@@ -430,7 +430,7 @@
       * return params
       */
      _onParams (o) {
        this.params = Object.assign(this.params, {}, o)
        this.params = Object.assign({}, o)
      },

      _onCacheParams (o) {
@@ -470,7 +470,7 @@
          this.$message.warning(`${i18n.$t('Please enter name (required)')}`)
          return false
        }
        if (this.successBranch !='' && this.successBranch == this.failedBranch) {
        if (this.successBranch !='' && this.successBranch !=null && this.successBranch == this.failedBranch) {
          this.$message.warning(`${i18n.$t('Cannot select the same node for successful branch flow and failed branch flow')}`)
          return false
        }
+0 −4
Original line number Diff line number Diff line
@@ -128,10 +128,6 @@
            this.store.dispatch('dag/getProcessTasksList', { processDefinitionId: ids }).then(res => {
              resolve(['ALL'].concat(_.map(res, v => v.name)))
            })
          } else {
            this.store.dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids }).then(res => {
              resolve(res)
            })
          }
        })
      },
+258 −131
Original line number Diff line number Diff line
@@ -16,6 +16,17 @@
*/
<template>
  <div class="datax-model">
    <m-list-box>
      <div slot="text">{{$t('Custom template')}}</div>
      <div slot="content">
        <label class="label-box">
          <div style="padding-top: 5px;">
            <x-switch v-model="enable" @on-click="_onSwitch" :disabled="isDetails"></x-switch>
          </div>
        </label>
      </div>
    </m-list-box>
    <div v-if="!enable">
      <m-list-box>
        <div slot="text">{{$t('Datasource')}}</div>
        <div slot="content">
@@ -102,6 +113,32 @@
        </div>
      </m-list-box>
    </div>
    <div v-else>
      <m-list-box>
        <div slot="text">json</div>
        <div slot="content">
          <div class="from-mirror">
            <textarea
              id="code-json-mirror"
              name="code-json-mirror"
              style="opacity: 0;">
            </textarea>
          </div>
        </div>
      </m-list-box>
      <m-list-box>
        <div slot="text">{{$t('Custom Parameters')}}</div>
        <div slot="content">
          <m-local-params
                  ref="refLocalParams"
                  @on-local-params="_onLocalParams"
                  :udp-list="localParams"
                  :hide="false">
          </m-local-params>
        </div>
      </m-list-box>
    </div>
  </div>
</template>
<script>
  import _ from 'lodash'
@@ -115,12 +152,15 @@
  import codemirror from '@/conf/home/pages/resource/pages/file/pages/_source/codemirror'

  let editor
  let jsonEditor

  export default {
    name: 'datax',

    data () {
      return {
        // Data Custom template
        enable: false,
        // Data source type
        dsType: '',
        // data source
@@ -135,6 +175,7 @@
        rtDatatarget: '',
        // Sql statement
        sql: '',
        json: '',
        // target table
        targetTable: '',
        // Pre statements
@@ -145,6 +186,9 @@
        jobSpeedByte: 0,
        // speed record
        jobSpeedRecord: 1000,
        // Custom parameter
        localParams: [],
        customConfig: 0,
      }
    },
    mixins: [disabledState],
@@ -153,6 +197,19 @@
      createNodeId: Number
    },
    methods: {
      _onSwitch (is) {
        if(is) {
          this.customConfig = 1
          setTimeout(() => {
            this._handlerJsonEditor()
          }, 200)
        } else {
          this.customConfig = 0
          setTimeout(() => {
            this._handlerEditor()
          }, 200)
        }
      },
      /**
       * return data source
       */
@@ -183,6 +240,20 @@
       * verification
       */
      _verification () {
        if(this.customConfig) {
          if (!jsonEditor.getValue()) {
            this.$message.warning(`${i18n.$t('Please enter a JSON Statement(required)')}`)
            return false
          }

          // storage
          this.$emit('on-params', {
            customConfig: this.customConfig,
            json: jsonEditor.getValue(),
            localParams: this.localParams
          })
          return true
        } else {
          if (!editor.getValue()) {
            this.$message.warning(`${i18n.$t('Please enter a SQL Statement(required)')}`)
            return false
@@ -215,6 +286,7 @@

          // storage
          this.$emit('on-params', {
            customConfig: this.customConfig,
            dsType: this.dsType,
            dataSource: this.rtDatasource,
            dtType: this.dtType,
@@ -227,6 +299,7 @@
            postStatements: this.postStatements
          })
          return true
        }
      },
      /**
       * Processing code highlighting
@@ -259,6 +332,34 @@

        return editor
      },
      _handlerJsonEditor () {
        this._destroyJsonEditor()

        // jsonEditor
        jsonEditor = codemirror('code-json-mirror', {
          mode: 'json',
          readOnly: this.isDetails
        })

        this.keypress = () => {
          if (!jsonEditor.getOption('readOnly')) {
            jsonEditor.showHint({
              completeSingle: false
            })
          }
        }

        // Monitor keyboard
        jsonEditor.on('keypress', this.keypress)

        jsonEditor.on('changes', () => {
          // this._cacheParams()
        })

        jsonEditor.setValue(this.json)

        return jsonEditor
      },
      _cacheParams () {
        this.$emit('on-cache-params', {
          dsType: this.dsType,
@@ -279,6 +380,13 @@
          editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
          editor.off($('.code-sql-mirror'), 'changes', this.changes)
        }
      },
      _destroyJsonEditor () {
         if (jsonEditor) {
          jsonEditor.toTextArea() // Uninstall
          jsonEditor.off($('.code-json-mirror'), 'keypress', this.keypress)
          jsonEditor.off($('.code-json-mirror'), 'changes', this.changes)
        }
      }
    },
    created () {
@@ -287,6 +395,9 @@
      // Non-null objects represent backfill
      if (!_.isEmpty(o)) {
        // backfill
        if(o.params.customConfig == 0) {
          this.customConfig = 0
          this.enable = false
          this.dsType = o.params.dsType || ''
          this.datasource = o.params.dataSource || ''
          this.dtType = o.params.dtType || ''
@@ -297,12 +408,24 @@
          this.jobSpeedRecord = o.params.jobSpeedRecord || 0
          this.preStatements = o.params.preStatements || []
          this.postStatements = o.params.postStatements || []
        } else {
          this.customConfig = 1
          this.enable = true
          this.json = o.params.json || []
          this.localParams = o.params.localParams || ''
        }
      }
    },
    mounted () {
      if(this.customConfig) {
        setTimeout(() => {
          this._handlerJsonEditor()
        }, 200)
      } else {
        setTimeout(() => {
          this._handlerEditor()
        }, 200)
      }
    },
    destroyed () {
      /**
@@ -312,6 +435,10 @@
        editor.toTextArea() // Uninstall
        editor.off($('.code-sql-mirror'), 'keypress', this.keypress)
      }
      if (jsonEditor) {
        jsonEditor.toTextArea() // Uninstall
        jsonEditor.off($('.code-json-mirror'), 'keypress', this.keypress)
      }
    },
    watch: {
      //Watch the cacheParams
Loading