feat: 支持数据源插件

This commit is contained in:
taojinlong
2022-04-17 15:05:01 +08:00
parent 8f9b355b89
commit ea43644f07
20 changed files with 240 additions and 253 deletions

View File

@@ -213,5 +213,4 @@ export function checkCustomDs() {
loading: true
})
}
export const disabledSyncDs= ['es', 'ck', 'mongo', 'redshift', 'hive', 'impala']
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, checkCustomDs }

View File

@@ -70,7 +70,7 @@ export default {
}, */
callPluginInner(param) {
const { methodName, methodParam } = param
this.$refs[this.refId] && this.$refs[this.refId][methodName] && this.$refs[this.refId][methodName](methodParam)
return this.$refs[this.refId] && this.$refs[this.refId][methodName] && this.$refs[this.refId][methodName](methodParam)
}
}
}

View File

@@ -2,7 +2,7 @@ export default {
fu: {
search_bar: {
search: 'Search',
adv_search: 'Advanced search',
adv_search: 'Advarequirednced search',
ok: 'Confirm',
cancel: 'Cancel',
please_select: 'Please select',
@@ -278,7 +278,7 @@ export default {
id: 'ID',
millisecond: 'Millisecond',
cannot_be_null: 'Cannot be null',
required: '{0} is required',
required: 'Required',
already_exists: 'Already Exists',
modifier: 'Modifier',
validate: 'Validate',

View File

@@ -278,7 +278,7 @@ export default {
id: 'ID',
millisecond: '毫秒',
cannot_be_null: '不能爲空',
required: '{0}是必填',
required: '必填',
already_exists: '名稱不能重複',
modifier: '修改人',
validate: '校驗',

View File

@@ -69,7 +69,7 @@
</template>
<script>
import {listDatasource, post, isKettleRunning, disabledSyncDs} from '@/api/dataset/dataset'
import {listDatasource, post, isKettleRunning} from '@/api/dataset/dataset'
import {engineMode} from "@/api/system/engine";
export default {
@@ -93,8 +93,7 @@ export default {
kettleRunning: false,
selectedDatasource: {},
engineMode: 'local',
disabledSync: true,
disabledSyncDs: disabledSyncDs
disabledSync: true
}
},
watch: {
@@ -108,7 +107,7 @@ export default {
if (this.options[i].id === val) {
this.selectedDatasource = this.options[i]
this.mode = '0'
if (this.engineMode === 'simple' || (!this.kettleRunning || this.disabledSyncDs.indexOf(this.selectedDatasource.type) !== -1 )) {
if (this.engineMode === 'simple' || (!this.kettleRunning || this.selectedDatasource.calculationMode === 'DIRECT')) {
this.disabledSync = true
} else {
this.disabledSync = false

View File

@@ -99,7 +99,7 @@
</template>
<script>
import {post, listDatasource, isKettleRunning, disabledSyncDs} from '@/api/dataset/dataset'
import {post, listDatasource, isKettleRunning} from '@/api/dataset/dataset'
import {codemirror} from 'vue-codemirror'
import {getTable} from '@/api/dataset/dataset'
// 核心样式
@@ -206,7 +206,7 @@ export default {
if (this.options[i].id === this.dataSource) {
this.selectedDatasource = this.options[i]
this.mode = '0'
if (this.engineMode === 'simple' || (!this.kettleRunning || this.disabledSyncDs.indexOf(this.selectedDatasource.type) !== -1 )) {
if (this.engineMode === 'simple' || (!this.kettleRunning || this.selectedDatasource.calculationMode === 'DIRECT' )) {
this.disabledSync = true
} else {
this.disabledSync = false

View File

@@ -2,9 +2,8 @@
<div>
<el-row>
<el-col>
<el-form
ref="DsForm"
ref="DsConfig"
:model="form"
:rules="rule"
size="small"
@@ -214,7 +213,7 @@ export default {
disabled: {
type: Boolean,
default() {
return true;
return false;
}
},
method: String,

View File

@@ -13,7 +13,7 @@
:model="form"
:rules="rule"
size="small"
:disabled="disabled"
:disabled="params && params.id && params.showModel && params.showModel === 'show' && !canEdit"
label-width="180px"
label-position="right"
>
@@ -41,7 +41,10 @@
</el-select>
</el-form-item>
<ds-configuration :form="form" :disabled="disabled" :edit-api-item="edit_api_item"></ds-configuration>
<ds-configuration ref="dsConfig" v-if="!datasourceType.isPlugin" :form="form" :disabled="params && params.id && params.showModel && params.showModel === 'show' && !canEdit" :edit-api-item="edit_api_item"></ds-configuration>
<plugin-com ref="pluginDsConfig" v-if="datasourceType.isPlugin" :component-name="datasourceType.type" :obj="{form, disabled }" />
</el-form>
@@ -72,13 +75,15 @@ import {$confirm} from '@/utils/message'
import i18n from '@/lang/index'
import ApiHttpRequestForm from '@/views/system/datasource/ApiHttpRequestForm'
import DsConfiguration from "@/views/system/datasource/DsConfiguration";
import PluginCom from '@/views/system/plugin/PluginCom'
export default {
name: 'DsForm',
components: {
DsConfiguration,
LayoutContent,
ApiHttpRequestForm
ApiHttpRequestForm,
PluginCom
},
props: {
params: {
@@ -96,7 +101,7 @@ export default {
},
data() {
return {
disabled: true,
disabled: false,
form: {
configuration: {
initialPoolSize: 5,
@@ -110,6 +115,7 @@ export default {
},
apiConfiguration: []
},
datasourceType: {},
rule: {
name: [{required: true, message: i18n.t('datasource.input_name'), trigger: 'blur'},
{min: 2, max: 25, message: i18n.t('datasource.input_limit_2_25', [2, 25]), trigger: 'blur'}],
@@ -229,10 +235,11 @@ export default {
if (this.params && this.params.id) {
const row = this.params
this.edit(row)
this.changeType()
} else {
this.create()
if (this.params && this.params.type) {
this.setType()
this.changeType()
}
}
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
@@ -252,13 +259,12 @@ export default {
idleConnectionTestPeriod: 5,
connectTimeout: 5
}
this.changeType()
},
changeEdit() {
this.canEdit = true
this.formType = 'modify'
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
console.log(this.disabled)
},
create() {
this.formType = 'add'
@@ -413,6 +419,15 @@ export default {
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
return
}
let status = null;
if(this.datasourceType.isPlugin){
status = this.$refs['pluginDsConfig'].callPluginInner({methodName: 'validate'})
}else {
status = this.$refs['dsConfig'].$refs['DsConfig'].validate
}
if(!status){
return;
}
this.$refs.dsForm.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
@@ -461,6 +476,7 @@ export default {
for (let i = 0; i < this.dsTypes.length; i++) {
if (this.dsTypes[i].type === this.form.type) {
this.form.configuration.extraParams = this.dsTypes[i].extraParams
this.datasourceType = this.dsTypes[i]
}
}
},

View File

@@ -83,7 +83,7 @@ export default {
this.$refs[this.refId] && this.$refs[this.refId].chartResize && this.$refs[this.refId].chartResize()
}, */
callPluginInner(param) {
this.$refs[this.refId] && this.$refs[this.refId].callPluginInner && this.$refs[this.refId].callPluginInner(param)
return this.$refs[this.refId] && this.$refs[this.refId].callPluginInner && this.$refs[this.refId].callPluginInner(param)
}
}
}