forked from github/dataease
feat: 重复的数据源连接,保存时增加提示
This commit is contained in:
parent
e4f44bd2d4
commit
18c957cee1
@ -1269,6 +1269,8 @@ export default {
|
||||
get_schema: 'Get Schema',
|
||||
schema: 'Database Schema',
|
||||
please_choose_schema: 'Please select Schema',
|
||||
edit_datasource_msg: 'Modifying the data source information may make the data set under the modified data source unavailable. Confirm the modification?',
|
||||
repeat_datasource_msg: 'Data source information with the same configuration already exists. Confirm?',
|
||||
in_valid: 'Invalid datasource',
|
||||
initial_pool_size: 'Initial connections',
|
||||
min_pool_size: 'Minimum of connections',
|
||||
|
@ -1271,6 +1271,7 @@ export default {
|
||||
schema: '數據庫 Schema',
|
||||
please_choose_schema: '請選擇數據庫 Schema',
|
||||
edit_datasource_msg: '修改數據源信息,可能會導致改數據源下的數據集不可用,確認修改?',
|
||||
repeat_datasource_msg: '已經存在相同配置的數據源信息,確認?',
|
||||
in_valid: '無效數據源',
|
||||
initial_pool_size: '初始連接數',
|
||||
min_pool_size: '最小連接數',
|
||||
|
@ -1275,6 +1275,7 @@ export default {
|
||||
schema: '数据库 Schema',
|
||||
please_choose_schema: '请选择数据库 Schema',
|
||||
edit_datasource_msg: '修改数据源信息,可能会导致该数据源下的数据集不可用,确认修改?',
|
||||
repeat_datasource_msg: '已经存在相同配置的数据源信息,确认?',
|
||||
in_valid: '无效数据源',
|
||||
initial_pool_size: '初始连接数',
|
||||
min_pool_size: '最小连接数',
|
||||
|
@ -4,7 +4,7 @@
|
||||
<ds-tree ref="dsTree" :datasource="datasource" @switch-main="switchMain"/>
|
||||
</de-aside-container>
|
||||
<de-main-container>
|
||||
<component :is="component" v-if="!!component" :params="param" @refresh-type="refreshType"
|
||||
<component :is="component" v-if="!!component" :params="param" :tData="tData" @refresh-type="refreshType"
|
||||
@switch-component="switchMain"/>
|
||||
</de-main-container>
|
||||
</de-container>
|
||||
@ -25,7 +25,8 @@ export default {
|
||||
return {
|
||||
component: DataHome,
|
||||
datasource: {},
|
||||
param: null
|
||||
param: null,
|
||||
tData: null
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
@ -36,7 +37,8 @@ export default {
|
||||
methods: {
|
||||
// 切换main区内容
|
||||
switchMain(param) {
|
||||
const {component, componentParam} = param
|
||||
console.log(param)
|
||||
const {component, componentParam, tData} = param
|
||||
this.component = DataHome
|
||||
this.param = null
|
||||
this.$nextTick(() => {
|
||||
@ -44,6 +46,7 @@ export default {
|
||||
case 'DsForm':
|
||||
this.component = DsForm
|
||||
this.param = componentParam
|
||||
this.tData = tData
|
||||
break
|
||||
default:
|
||||
this.component = DataHome
|
||||
|
@ -216,10 +216,10 @@ export default {
|
||||
},
|
||||
|
||||
addFolder() {
|
||||
this.switchMain('DsForm')
|
||||
this.switchMain('DsForm', {}, this.tData)
|
||||
},
|
||||
addFolderWithType(data) {
|
||||
this.switchMain('DsForm', {type: data.id})
|
||||
this.switchMain('DsForm', {type: data.id}, this.tData)
|
||||
},
|
||||
nodeClick(node, data) {
|
||||
if (node.type === 'folder') return
|
||||
@ -243,11 +243,11 @@ export default {
|
||||
return {optType, data, node}
|
||||
},
|
||||
edit(row) {
|
||||
this.switchMain('DsForm', row)
|
||||
this.switchMain('DsForm', row, this.tData)
|
||||
},
|
||||
showInfo(row) {
|
||||
const param = {...row.data, ...{showModel: 'show'}}
|
||||
this.switchMain('DsForm', param)
|
||||
this.switchMain('DsForm', param, this.tData)
|
||||
},
|
||||
_handleDelete(datasource) {
|
||||
this.$confirm(this.$t('datasource.delete_warning'), '', {
|
||||
@ -257,7 +257,7 @@ export default {
|
||||
}).then(() => {
|
||||
delDs(datasource.id).then(res => {
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.switchMain('DataHome')
|
||||
this.switchMain('DataHome', {}, this.tData)
|
||||
this.refreshType(datasource)
|
||||
})
|
||||
}).catch(() => {
|
||||
@ -267,10 +267,12 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
switchMain(component, componentParam) {
|
||||
switchMain(component, componentParam, tData) {
|
||||
console.log(tData)
|
||||
this.$emit('switch-main', {
|
||||
component,
|
||||
componentParam
|
||||
componentParam,
|
||||
tData
|
||||
})
|
||||
},
|
||||
markInvalid(msgParam) {
|
||||
|
@ -192,6 +192,10 @@ export default {
|
||||
params: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
tData: {
|
||||
type: Array,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -346,29 +350,79 @@ export default {
|
||||
this.$message.error(i18n.t('datasource.no_less_then_0'))
|
||||
return
|
||||
}
|
||||
let repeat = false
|
||||
this.tData.forEach(item => {
|
||||
if(item.id === this.form.type){
|
||||
item.children.forEach(child => {
|
||||
let configuration = JSON.parse(child.configuration)
|
||||
switch (this.form.type) {
|
||||
case 'mysql':
|
||||
case 'hive':
|
||||
case 'mariadb':
|
||||
case 'ds_doris':
|
||||
case 'ck':
|
||||
case 'mongo':
|
||||
case 'mariadb':
|
||||
if(configuration.host == this.form.configuration.host && configuration.dataBase == this.form.configuration.dataBase && configuration.port == this.form.configuration.port){
|
||||
repeat = true
|
||||
}
|
||||
break
|
||||
case 'pg':
|
||||
case 'sqlServer':
|
||||
case 'redshift':
|
||||
case 'oracle':
|
||||
case 'db2':
|
||||
if(configuration.host == this.form.configuration.host && configuration.dataBase == this.form.configuration.dataBase && configuration.port == this.form.configuration.port && configuration.schema == this.form.configuration.schema){
|
||||
repeat = true
|
||||
}
|
||||
break
|
||||
case 'es':
|
||||
if(configuration.url == this.form.configuration.url){
|
||||
repeat = true
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
this.$refs.dsForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addDs : editDs
|
||||
const form = JSON.parse(JSON.stringify(this.form))
|
||||
form.configuration = JSON.stringify(form.configuration)
|
||||
if (this.formType !== 'add' && this.originConfiguration !== form.configuration) {
|
||||
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
||||
method(form).then(res => {
|
||||
this.$success(i18n.t('commons.save_success'))
|
||||
this.refreshType(form)
|
||||
this.backToList()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
method(form).then(res => {
|
||||
this.$success(i18n.t('commons.save_success'))
|
||||
this.refreshType(form)
|
||||
this.backToList()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
const method = this.formType === 'add' ? addDs : editDs
|
||||
const form = JSON.parse(JSON.stringify(this.form))
|
||||
form.configuration = JSON.stringify(form.configuration)
|
||||
if (this.formType === 'modify' && this.originConfiguration !== form.configuration) {
|
||||
if(repeat){
|
||||
$confirm(i18n.t('datasource.repeat_datasource_msg'), () => {
|
||||
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
||||
this.method(method, form)
|
||||
})
|
||||
})
|
||||
}else {
|
||||
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
||||
this.method(method, form)
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
if(repeat){
|
||||
$confirm(i18n.t('datasource.repeat_datasource_msg'), () => {
|
||||
this.method(method, form)
|
||||
})
|
||||
}else {
|
||||
this.method(method, form)
|
||||
}
|
||||
})
|
||||
},
|
||||
method(method, form){
|
||||
method(form).then(res => {
|
||||
this.$success(i18n.t('commons.save_success'))
|
||||
this.refreshType(form)
|
||||
this.backToList()
|
||||
})
|
||||
},
|
||||
getSchema() {
|
||||
|
Loading…
Reference in New Issue
Block a user