From 18c24089f300f7677deb2622fbd8a57d2d06b421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=88=E8=AD=B7?= <2413957313@qq.com> Date: Thu, 9 May 2024 22:43:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/connection/list.vue | 405 +----------------- .../src/views/connection/updateDataSource.vue | 59 ++- 2 files changed, 59 insertions(+), 405 deletions(-) diff --git a/dbswitch-admin-ui/src/views/connection/list.vue b/dbswitch-admin-ui/src/views/connection/list.vue index 1a0eba39..162b7bf0 100644 --- a/dbswitch-admin-ui/src/views/connection/list.vue +++ b/dbswitch-admin-ui/src/views/connection/list.vue @@ -18,13 +18,6 @@ icon="el-icon-document-add" @click="selectDataSource">接入数据源 - - - - - - - - - - - @@ -100,265 +89,6 @@ layout="total, sizes, prev, pager, next, jumper" :total="totalCount"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -505,8 +235,6 @@ export default { } ); }, - // handleClose(done) { - // }, handleDelete: function (index, row) { this.$confirm( "此操作将此数据源ID=" + row.id + "删除么, 是否继续?", @@ -520,7 +248,6 @@ export default { this.$http.delete( "/dbswitch/admin/api/v1/connection/delete/" + row.id ).then(res => { - //console.log(res); if (0 === res.data.code) { this.loadData(); } else { @@ -534,14 +261,11 @@ export default { path: "/connection/list/dataSourceInfo", query: row }); - // this.dialogFormVisible = true; - // this.queryForm = row; }, handleTest: function (index, row) { this.$http.get( "/dbswitch/admin/api/v1/connection/test/" + row.id ).then(res => { - //console.log(res); if (0 === res.data.code) { this.$message({ message: '测试连接成功!', @@ -552,142 +276,21 @@ export default { } }); }, - // addConnection: function () { - // this.createFormVisible = true; - // this.createform = {}; - // }, selectDataSource: function () { // this.dataSourceCreateStep1 = true; this.$router.push('/connection/list/addDataSource1'); }, - // handleCreate: function () { - // let driverClass = ""; - // if (this.databaseType.length > 0) { - // for (let i = 0; i < this.databaseType.length; i++) { - // //console.log(this.databaseType[i]) - // if (this.databaseType[i].type == this.createform.type) { - // driverClass = this.databaseType[i].driver; - // break; - // } - // } - // } - // - // this.$refs['createform'].validate(valid => { - // if (valid) { - // this.$http({ - // method: "POST", - // headers: { - // 'Content-Type': 'application/json' - // }, - // url: "/dbswitch/admin/api/v1/connection/create", - // data: JSON.stringify({ - // name: this.createform.name, - // type: this.createform.type, - // version: this.createform.version, - // driver: driverClass, - // url: this.createform.url, - // username: this.createform.username, - // password: this.createform.password - // }) - // }).then(res => { - // if (0 === res.data.code) { - // this.createFormVisible = false; - // this.$message("添加连接信息成功"); - // this.createform = {}; - // this.loadData(); - // } else { - // alert("添加连接信息失败:" + res.data.message); - // } - // }); - // } else { - // alert("请检查输入"); - // } - // }); - // }, - // selectChangedDriverVersion: function (value) { - // this.connectionDriver = []; - // this.$http.get( - // "/dbswitch/admin/api/v1/connection/" + value + "/drivers" - // ).then(res => { - // if (0 === res.data.code) { - // this.connectionDriver = res.data.data; - // let varDatabaseType = this.databaseType.find( - // (item) => { - // return item.type === value; - // }); - // if (varDatabaseType) { - // this.createform.sample = varDatabaseType.sample; - // } - // } else { - // this.$message.error("查询数据库可用的驱动版本失败," + res.data.message); - // this.connectionDriver = []; - // } - // }); - // }, handleUpdate: function (index, row) { + row["templateUrl"] = this.databaseType.find( + (item) => { + return item.type === row['type']; + }).url; this.$router.push({ path: "/connection/list/updateDataSource", query: row }); - // this.updateform = JSON.parse(JSON.stringify(row)); - // this.$http.get( - // "/dbswitch/admin/api/v1/connection/" + this.updateform.type + "/drivers" - // ).then(res => { - // if (0 === res.data.code) { - // this.connectionDriver = res.data.data; - // } else { - // this.$message.error("查询数据库可用的驱动版本失败," + res.data.message); - // this.connectionDriver = []; - // } - // }); - // this.updateFormVisible = true; }, - // handleSave: function () { - // let driverClass = ""; - // if (this.databaseType.length > 0) { - // for (let i = 0; i < this.databaseType.length; i++) { - // //console.log(this.databaseType[i]) - // if (this.databaseType[i].type == this.updateform.type) { - // driverClass = this.databaseType[i].driver; - // break; - // } - // } - // } - // - // this.$refs['updateform'].validate(valid => { - // if (valid) { - // this.$http({ - // method: "POST", - // headers: { - // 'Content-Type': 'application/json' - // }, - // url: "/dbswitch/admin/api/v1/connection/update", - // data: JSON.stringify({ - // id: this.updateform.id, - // name: this.updateform.name, - // type: this.updateform.type, - // version: this.updateform.version, - // driver: driverClass, - // url: this.updateform.url, - // username: this.updateform.username, - // password: this.updateform.password - // }) - // }).then(res => { - // if (0 === res.data.code) { - // this.updateFormVisible = false; - // this.$message("修改连接信息成功"); - // this.loadData(); - // this.updateform = {}; - // } else { - // alert("修改连接信息失败:" + res.data.message); - // } - // }); - // } else { - // alert("请检查输入"); - // } - // }); - // }, handleSizeChange: function (pageSize) { this.loading = true; this.pageSize = pageSize; diff --git a/dbswitch-admin-ui/src/views/connection/updateDataSource.vue b/dbswitch-admin-ui/src/views/connection/updateDataSource.vue index 80f28bef..cea89d45 100644 --- a/dbswitch-admin-ui/src/views/connection/updateDataSource.vue +++ b/dbswitch-admin-ui/src/views/connection/updateDataSource.vue @@ -53,7 +53,7 @@ - + / @@ -61,7 +61,7 @@ placeholder="Port"> - + @@ -147,7 +147,7 @@ export default { password: "", sample: "", url: "", - oldUrl: "", + templateUrl: "", }, rules: { name: [ @@ -257,7 +257,58 @@ export default { }); }, changeUrl: function () { - console.log('') + var params = this.updateform.url.split("?"); + var turl = this.updateform.templateUrl + var flag = false + if (Object.keys(this.updateform.address).length > 0){ + // address + var address = this.updateform.address + turl = turl.replaceAll("{host}",address) + flag = true + } + if (Object.keys(this.updateform.port).length > 0){ + // port + var port = this.updateform.port + turl = turl.replaceAll("{port}",port) + flag = true + } + if (Object.keys(this.updateform.databaseName).length > 0){ + // databaseName or filePath + var databaseName = this.updateform.databaseName + turl = turl.replaceAll("{database}",databaseName) + turl = turl.replaceAll("{file}",databaseName) + flag = true + } + if (flag){ + if (Object.keys(params).length > 1){ + this.updateform.url = turl + "?" + params[1] + }else{ + this.updateform.url = turl + } + } else{ + debugger + if (Object.keys(params).length > 1){ + this.updateform.url = this.updateform.sample.split("?")[0] + "?" + params[1] + }else{ + this.updateform.url = this.updateform.sample + } + } + }, + isShowDatabaseName: function () { + var type = this.updateform.type + var flag = true; + if (type === "ELASTICSEARCH"){ + flag = false + } + return flag; + }, + isShowUrlAndPort: function () { + var type = this.updateform.type + var flag = true; + if (type === "SQLITE3"){ + flag = false + } + return flag; }, startTest: function () { let driverClass = "";