diff --git a/backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java b/backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java index 6e37a346e1..b019df64a5 100644 --- a/backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java +++ b/backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java @@ -24,7 +24,7 @@ public class DatasourceController { } @PostMapping("/validate") - public void validate(@RequestBody Datasource datasource) throws Exception{ + public void validate(@RequestBody Datasource datasource) throws Exception { datasourceService.validate(datasource); } @@ -34,7 +34,7 @@ public class DatasourceController { } @PostMapping("/list/{goPage}/{pageSize}") - public Pager> getDatasourceList(@RequestBody Datasource request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception{ + public Pager> getDatasourceList(@RequestBody Datasource request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, datasourceService.getDatasourceList(request)); } @@ -48,4 +48,9 @@ public class DatasourceController { public void updateDatasource(@RequestBody Datasource Datasource) { datasourceService.updateDatasource(Datasource); } + + @PostMapping("/getTables") + public List getTables(@RequestBody Datasource datasource) throws Exception { + return datasourceService.getTables(datasource); + } } diff --git a/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java b/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java index e81a18fe25..bcd525a4d5 100644 --- a/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java +++ b/backend/src/main/java/io/dataease/datasource/service/DatasourceService.java @@ -30,7 +30,7 @@ public class DatasourceService { public Datasource addDatasource(Datasource datasource) { DatasourceExample example = new DatasourceExample(); example.createCriteria().andNameEqualTo(datasource.getName()); - if(CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))){ + if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) { DEException.throwException("Exist data connection with the same name "); } long currentTimeMillis = System.currentTimeMillis(); @@ -41,7 +41,7 @@ public class DatasourceService { return datasource; } - public List getDatasourceList(Datasource request)throws Exception{ + public List getDatasourceList(Datasource request) throws Exception { DatasourceExample example = new DatasourceExample(); DatasourceExample.Criteria criteria = example.createCriteria(); if (StringUtils.isNotBlank(request.getName())) { @@ -64,13 +64,19 @@ public class DatasourceService { datasourceMapper.updateByPrimaryKeySelective(datasource); } - public void validate(Datasource datasource)throws Exception { + public void validate(Datasource datasource) throws Exception { DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType()); DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setDatasource(datasource); datasourceProvider.test(datasourceRequest); } - + public List getTables(Datasource datasource) throws Exception { + Datasource ds = datasourceMapper.selectByPrimaryKey(datasource.getId()); + DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDatasource(ds); + return datasourceProvider.getTables(datasourceRequest); + } } diff --git a/frontend/src/business/components/dataset/DataSet.vue b/frontend/src/business/components/dataset/DataSet.vue index 7d59ddd3ec..e0c29585ef 100644 --- a/frontend/src/business/components/dataset/DataSet.vue +++ b/frontend/src/business/components/dataset/DataSet.vue @@ -33,7 +33,7 @@ diff --git a/frontend/src/business/components/dataset/group/Group.vue b/frontend/src/business/components/dataset/group/Group.vue index 1377d9aa58..c762db4e6c 100644 --- a/frontend/src/business/components/dataset/group/Group.vue +++ b/frontend/src/business/components/dataset/group/Group.vue @@ -2,10 +2,13 @@ - - {{ $t('dataset.datalist') }} - + + + {{ $t('dataset.datalist') }} + + + {{$t('dataset.add_group')}} @@ -46,7 +49,7 @@ size="mini"> - {{ data.label }} + {{ data.name }} @@ -111,8 +114,8 @@ - - + + {{currGroup.name}} @@ -160,13 +163,13 @@ - + {{sceneData}} + @node-click="sceneClick"> @@ -176,7 +179,7 @@ size="mini"> - {{ data.label }} + {{ data.name }} @@ -235,11 +238,19 @@ export default { } } }, + computed: { + sceneData: function () { + console.log(this.$store.state.dataset.sceneData + ' do post'); + return this.$store.state.dataset.sceneData; + } + }, mounted() { this.tree(this.groupForm); + this.$router.push('/dataset'); }, activated() { this.tree(this.groupForm); + this.$router.push('/dataset'); }, watch: { // search(val){ @@ -384,19 +395,19 @@ export default { }, clickAddData(param) { - console.log(param); + // console.log(param); switch (param.type) { case 'db': this.addDB(); break; case 'sql': - + this.$message(param.type); break; case 'excel': - + this.$message(param.type); break; case 'custom': - + this.$message(param.type); break; } }, @@ -407,8 +418,17 @@ export default { } }, + sceneClick() { + + }, + addDB() { - this.$router.push('/dataset/add_db'); + this.$router.push({ + name: 'add_db', + params: { + scene: this.currGroup + } + }) } } } @@ -443,4 +463,12 @@ export default { .form-item { margin-bottom: 0; } + + .title-css { + height: 26px; + } + + .title-text { + line-height: 26px; + } diff --git a/frontend/src/business/components/dataset/router.js b/frontend/src/business/components/dataset/router.js index cc1c3693c2..96da9392e9 100644 --- a/frontend/src/business/components/dataset/router.js +++ b/frontend/src/business/components/dataset/router.js @@ -18,12 +18,12 @@ export default { children: [ { path: 'home', - name: 'DataSetHome', + name: 'home', component: DataSetHome, }, { path: 'add_db', - name: 'DataSetAddDB', + name: 'add_db', component: DataSetAddDB, }, // { diff --git a/frontend/src/business/store.js b/frontend/src/business/store.js index c536ea0d38..c451521b63 100644 --- a/frontend/src/business/store.js +++ b/frontend/src/business/store.js @@ -3,6 +3,17 @@ import Vuex from 'vuex' Vue.use(Vuex); +const Dataset = { + state: { + sceneData: "" + }, + mutations: { + setSceneData(state, sceneData) { + state.sceneData = sceneData; + } + } +} + const Common = { state: { projectId: "" @@ -56,5 +67,6 @@ export default new Vuex.Store({ common: Common, switch: Switch, isReadOnly: IsReadOnly, + dataset: Dataset } }) diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 614a8b7618..61130f1c11 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -1543,6 +1543,8 @@ export default { sql_data: 'SQL Data', excel_data: 'Excel Data', custom_data: 'Custom Data', - pls_slc_tbl_left:'Please select table from left' + pls_slc_tbl_left:'Please select table from left', + add_db_table:'Add Table', + pls_slc_data_source:'Select Data Source' } }; diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index a0d6e3c408..aa636b7c8a 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -1552,7 +1552,9 @@ export default { sql_data: 'SQL数据集', excel_data: 'Excel数据集', custom_data: '自助数据集', - pls_slc_tbl_left:'请从左侧选择表' + pls_slc_tbl_left:'请从左侧选择表', + add_db_table:'添加数据库表', + pls_slc_data_source:'请选择数据库连接' }, datasource: { create: '新建数据连接', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index c4e5afc17a..7d52fdb170 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -1544,6 +1544,8 @@ export default { sql_data: 'SQL數據集', excel_data: 'Excel數據集', custom_data: '自助數據集', - pls_slc_tbl_left:'請從左側選擇表' + pls_slc_tbl_left:'請從左側選擇表', + add_db_table:'添加數據庫表', + pls_slc_data_source:'請選擇數據庫連接' } };