diff --git a/datax-admin/src/main/java/com/wugui/datax/admin/service/DatasourceQueryService.java b/datax-admin/src/main/java/com/wugui/datax/admin/service/DatasourceQueryService.java index 62c6bc4a..c0c661d8 100644 --- a/datax-admin/src/main/java/com/wugui/datax/admin/service/DatasourceQueryService.java +++ b/datax-admin/src/main/java/com/wugui/datax/admin/service/DatasourceQueryService.java @@ -1,7 +1,6 @@ package com.wugui.datax.admin.service; import java.io.IOException; -import java.net.UnknownHostException; import java.util.List; /** @@ -19,7 +18,7 @@ public interface DatasourceQueryService { * @param id * @return */ - List getDBs(Long id) throws UnknownHostException; + List getDBs(Long id) throws IOException; /** * 根据数据源表id查询出可用的表 @@ -34,7 +33,7 @@ public interface DatasourceQueryService { * @param dbName * @return */ - List getCollectionNames(long id,String dbName) throws UnknownHostException; + List getCollectionNames(long id,String dbName) throws IOException; /** * 根据数据源id,表名查询出该表所有字段 diff --git a/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/DatasourceQueryServiceImpl.java b/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/DatasourceQueryServiceImpl.java index 87d11040..af239b94 100644 --- a/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/DatasourceQueryServiceImpl.java +++ b/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/DatasourceQueryServiceImpl.java @@ -14,7 +14,6 @@ import org.springframework.stereotype.Service; import java.io.IOException; -import java.net.UnknownHostException; import java.util.List; /** @@ -32,10 +31,10 @@ public class DatasourceQueryServiceImpl implements DatasourceQueryService { private JobDatasourceService jobDatasourceService; @Override - public List getDBs(Long id) throws UnknownHostException { + public List getDBs(Long id) throws IOException { //获取数据源对象 JobDatasource datasource = jobDatasourceService.getById(id); - return MongoDBQueryTool.getInstance(datasource).getDBNames(); + return new MongoDBQueryTool(datasource).getDBNames(); } @@ -48,9 +47,9 @@ public List getTables(Long id) throws IOException { return Lists.newArrayList(); } if (JdbcConstants.HBASE.equals(datasource.getDatasource())) { - return HBaseQueryTool.getInstance(datasource).getTableNames(); + return new HBaseQueryTool(datasource).getTableNames(); } else if(JdbcConstants.MONGODB.equals(datasource.getDatasource())){ - return MongoDBQueryTool.getInstance(datasource).getCollectionNames(datasource.getDatabaseName()); + return new MongoDBQueryTool(datasource).getCollectionNames(datasource.getDatabaseName()); } else { BaseQueryTool qTool = QueryToolFactory.getByDbType(datasource); return qTool.getTableNames(); @@ -58,14 +57,14 @@ public List getTables(Long id) throws IOException { } @Override - public List getCollectionNames(long id,String dbName) throws UnknownHostException { + public List getCollectionNames(long id,String dbName) throws IOException { //获取数据源对象 JobDatasource datasource = jobDatasourceService.getById(id); //queryTool组装 if (ObjectUtil.isNull(datasource)) { return Lists.newArrayList(); } - return MongoDBQueryTool.getInstance(datasource).getCollectionNames(dbName); + return new MongoDBQueryTool(datasource).getCollectionNames(dbName); } @@ -78,9 +77,9 @@ public List getColumns(Long id, String tableName) throws IOException { return Lists.newArrayList(); } if (JdbcConstants.HBASE.equals(datasource.getDatasource())) { - return HBaseQueryTool.getInstance(datasource).getColumns(tableName); + return new HBaseQueryTool(datasource).getColumns(tableName); } else if (JdbcConstants.MONGODB.equals(datasource.getDatasource())) { - return MongoDBQueryTool.getInstance(datasource).getColumns(tableName); + return new MongoDBQueryTool(datasource).getColumns(tableName); } else { BaseQueryTool queryTool = QueryToolFactory.getByDbType(datasource); return queryTool.getColumnNames(tableName, datasource.getDatasource()); diff --git a/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/JobDatasourceServiceImpl.java b/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/JobDatasourceServiceImpl.java index 389b0ef9..e4b08f9d 100644 --- a/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/JobDatasourceServiceImpl.java +++ b/datax-admin/src/main/java/com/wugui/datax/admin/service/impl/JobDatasourceServiceImpl.java @@ -29,7 +29,7 @@ public class JobDatasourceServiceImpl extends ServiceImpl 0; } - } - /** - * 测试是否连接成功 - * - * @return - * @throws IOException - */ - public boolean dataSourceTest() throws IOException { - Admin admin =connection.getAdmin(); - HTableDescriptor[] tableDescriptor = admin.listTables(); - return tableDescriptor.length > 0; - } - /** - * 获取HBase表名称 - * @return - * @throws IOException - */ - public List getTableNames() throws IOException { - List list = new ArrayList<>(); - Admin admin = connection.getAdmin(); - TableName[] names=admin.listTableNames(); - for (int i = 0; i < names.length; i++) { - list.add(names[i].getNameAsString()); + /** + * 获取HBase表名称 + * + * @return + * @throws IOException + */ + public List getTableNames() throws IOException { + List list = new ArrayList<>(); + Admin admin = connection.getAdmin(); + TableName[] names = admin.listTableNames(); + for (int i = 0; i < names.length; i++) { + list.add(names[i].getNameAsString()); + } + return list; } - return list; - } - /** - * - * 通过表名查询所有l列祖和列 - * - * @param tableName - * @return - * @throws IOException - */ - public List getColumns(String tableName) throws IOException { - List list = new ArrayList<>(); - table = connection.getTable(TableName.valueOf(tableName)); - Scan scan = new Scan(); - //Filter filter = new PageFilter(1); - //scan.setFilter(filter); - scan.getStartRow(); - ResultScanner scanner = table.getScanner(scan); - Iterator it = scanner.iterator(); - if(it.hasNext()) { - Result re = it.next(); - List listCells = re.listCells(); - for (Cell cell : listCells) { - list.add(new String(CellUtil.cloneFamily(cell))+":"+new String(CellUtil.cloneQualifier(cell))); - } + /** + * 通过表名查询所有l列祖和列 + * + * @param tableName + * @return + * @throws IOException + */ + public List getColumns(String tableName) throws IOException { + List list = new ArrayList<>(); + table = connection.getTable(TableName.valueOf(tableName)); + Scan scan = new Scan(); + //Filter filter = new PageFilter(1); + //scan.setFilter(filter); + scan.getStartRow(); + ResultScanner scanner = table.getScanner(scan); + Iterator it = scanner.iterator(); + if (it.hasNext()) { + Result re = it.next(); + List listCells = re.listCells(); + for (Cell cell : listCells) { + list.add(new String(CellUtil.cloneFamily(cell)) + ":" + new String(CellUtil.cloneQualifier(cell))); + } + } + return list; } - return list; - } } diff --git a/datax-admin/src/main/java/com/wugui/datax/admin/tool/query/MongoDBQueryTool.java b/datax-admin/src/main/java/com/wugui/datax/admin/tool/query/MongoDBQueryTool.java index ee0f354e..7fe38dc9 100644 --- a/datax-admin/src/main/java/com/wugui/datax/admin/tool/query/MongoDBQueryTool.java +++ b/datax-admin/src/main/java/com/wugui/datax/admin/tool/query/MongoDBQueryTool.java @@ -5,10 +5,12 @@ import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoIterable; +import com.wugui.datax.admin.core.util.LocalCacheUtil; import com.wugui.datax.admin.entity.JobDatasource; import org.apache.commons.lang3.StringUtils; import org.bson.Document; +import java.io.IOException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; @@ -18,43 +20,37 @@ public class MongoDBQueryTool { - private static MongoClient mongoClient = null; - private static MongoDBQueryTool instance = null; + private static MongoClient connection = null; private static MongoDatabase collections; - MongoDBQueryTool(JobDatasource jobDatasource) throws UnknownHostException { - if (mongoClient == null) { - if (StringUtils.isBlank(jobDatasource.getJdbcUsername()) && StringUtils.isBlank(jobDatasource.getJdbcPassword())) { - mongoClient = new MongoClient(jobDatasource.getJdbcUrl()); - } else { - MongoCredential credential = MongoCredential.createCredential(jobDatasource.getJdbcUsername(), jobDatasource.getDatabaseName(), jobDatasource.getJdbcPassword().toCharArray()); - mongoClient = new MongoClient(parseServerAddress(jobDatasource.getJdbcUrl()), Arrays.asList(credential)); + public MongoDBQueryTool(JobDatasource jobDatasource) throws IOException { + if (LocalCacheUtil.get(jobDatasource.getDatasourceName()) == null) { + getDataSource(jobDatasource); + } else { + connection = (MongoClient) LocalCacheUtil.get(jobDatasource.getDatasourceName()); + if (connection == null) { + LocalCacheUtil.remove(jobDatasource.getDatasourceName()); + getDataSource(jobDatasource); } - } + LocalCacheUtil.set(jobDatasource.getDatasourceName(), connection, 4 * 60 * 60 * 1000); } - /** - * 获得该类的实例,单例模式 - * - * @return - */ - public static MongoDBQueryTool getInstance(JobDatasource jobDatasource) throws UnknownHostException { - if (instance == null) { - synchronized (MongoDBQueryTool.class) { - if (instance == null) { - instance = new MongoDBQueryTool(jobDatasource); - } - } + private void getDataSource(JobDatasource jobDatasource) throws IOException { + if (StringUtils.isBlank(jobDatasource.getJdbcUsername()) && StringUtils.isBlank(jobDatasource.getJdbcPassword())) { + connection = new MongoClient(jobDatasource.getJdbcUrl()); + } else { + MongoCredential credential = MongoCredential.createCredential(jobDatasource.getJdbcUsername(), jobDatasource.getDatabaseName(), jobDatasource.getJdbcPassword().toCharArray()); + connection = new MongoClient(parseServerAddress(jobDatasource.getJdbcUrl()), Arrays.asList(credential)); } - return instance; } + // 关闭连接 public static void sourceClose() { - if (mongoClient != null) { - mongoClient.close(); + if (connection != null) { + connection.close(); } } @@ -64,7 +60,7 @@ public static void sourceClose() { * @return */ public List getDBNames() { - MongoIterable dbs = mongoClient.listDatabaseNames(); + MongoIterable dbs = connection.listDatabaseNames(); List dbNames = new ArrayList<>(); dbs.forEach((Block) dbNames::add); return dbNames; @@ -76,7 +72,7 @@ public List getDBNames() { * @return */ public boolean dataSourceTest(String dbName) { - collections = mongoClient.getDatabase(dbName); + collections = connection.getDatabase(dbName); return collections.listCollectionNames().iterator().hasNext(); } @@ -86,7 +82,7 @@ public boolean dataSourceTest(String dbName) { * @return */ public List getCollectionNames(String dbName) { - collections = mongoClient.getDatabase(dbName); + collections = connection.getDatabase(dbName); List collectionNames = new ArrayList<>(); collections.listCollectionNames().forEach((Block) collectionNames::add); return collectionNames; diff --git a/datax-admin/src/main/java/com/wugui/datax/admin/util/AESUtil.java b/datax-admin/src/main/java/com/wugui/datax/admin/util/AESUtil.java index 9a86f61d..071e989d 100644 --- a/datax-admin/src/main/java/com/wugui/datax/admin/util/AESUtil.java +++ b/datax-admin/src/main/java/com/wugui/datax/admin/util/AESUtil.java @@ -57,7 +57,7 @@ public static String encrypt(String content, String key) { return new Base64().encodeToString(result); // 加密 } } catch (Exception e) { - log.error("content encrypt error {}",e.getMessage()); + log.warn("content encrypt error {}",e.getMessage()); } return null; } @@ -81,7 +81,7 @@ public static String decrypt(String content, String key) { return new String(result); // 解密 } } catch (Exception e) { - log.error("content decrypt error {}",e.getMessage()); + log.warn("content decrypt error {}",e.getMessage()); } return null; } diff --git a/datax-admin/src/main/resources/static/index.html b/datax-admin/src/main/resources/static/index.html index 90e43a72..51e2e08b 100644 --- a/datax-admin/src/main/resources/static/index.html +++ b/datax-admin/src/main/resources/static/index.html @@ -1 +1 @@ -Datax Web
\ No newline at end of file +Datax Web
\ No newline at end of file diff --git a/datax-admin/src/main/resources/static/static/js/app.d5cd9cd7.js b/datax-admin/src/main/resources/static/static/js/app.e4a96582.js similarity index 100% rename from datax-admin/src/main/resources/static/static/js/app.d5cd9cd7.js rename to datax-admin/src/main/resources/static/static/js/app.e4a96582.js diff --git a/datax-admin/src/main/resources/static/static/js/chunk-40c25403.a34eb8a7.js b/datax-admin/src/main/resources/static/static/js/chunk-40c25403.a34eb8a7.js deleted file mode 100644 index 87fbcace..00000000 --- a/datax-admin/src/main/resources/static/static/js/chunk-40c25403.a34eb8a7.js +++ /dev/null @@ -1 +0,0 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-40c25403"],{"1c64":function(e,t,a){},"1cc6":function(e,t,a){"use strict";var s=a("1c64"),r=a.n(s);r.a},"1cf5":function(e,t,a){"use strict";a.r(t);var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"app-container"},[a("div",{staticClass:"filter-container"},[a("el-input",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"数据源名称"},nativeOn:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleFilter(t)}},model:{value:e.listQuery.datasourceName,callback:function(t){e.$set(e.listQuery,"datasourceName",t)},expression:"listQuery.datasourceName"}}),e._v(" "),a("el-button",{directives:[{name:"waves",rawName:"v-waves"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-search"},on:{click:e.fetchData}},[e._v("\n 搜索\n ")]),e._v(" "),a("el-button",{staticClass:"filter-item",staticStyle:{"margin-left":"10px"},attrs:{type:"primary",icon:"el-icon-edit"},on:{click:e.handleCreate}},[e._v("\n 添加\n ")])],1),e._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.listLoading,expression:"listLoading"}],attrs:{data:e.list,"element-loading-text":"Loading",border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{label:"数据源",width:"200",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.datasource))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"数据源名称",width:"150",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.datasourceName))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"数据源分组",width:"200",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.datasourceGroup)+"\n ")]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"jdbc url",width:"200",align:"center","show-overflow-tooltip":!0},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.jdbcUrl?t.row.jdbcUrl:"-"))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"ZK地址",width:"200",align:"center","show-overflow-tooltip":!0},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.zkAdress?t.row.zkAdress:"-"))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"数据库名",width:"200",align:"center","show-overflow-tooltip":!0},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.databaseName?t.row.databaseName:"-"))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"注释",width:"150",align:"center"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(e._s(t.row.comments))]}}])}),e._v(" "),a("el-table-column",{attrs:{label:"Actions",align:"center",width:"230","class-name":"small-padding fixed-width"},scopedSlots:e._u([{key:"default",fn:function(t){var s=t.row;return[a("el-button",{attrs:{type:"primary",size:"mini"},on:{click:function(t){return e.handleUpdate(s)}}},[e._v("\n 编辑\n ")]),e._v(" "),"deleted"!=s.status?a("el-button",{attrs:{size:"mini",type:"danger"},on:{click:function(t){return e.handleDelete(s)}}},[e._v("\n 删除\n ")]):e._e()]}}])})],1),e._v(" "),a("pagination",{directives:[{name:"show",rawName:"v-show",value:e.total>0,expression:"total>0"}],attrs:{total:e.total,page:e.listQuery.current,limit:e.listQuery.size},on:{"update:page":function(t){return e.$set(e.listQuery,"current",t)},"update:limit":function(t){return e.$set(e.listQuery,"size",t)},pagination:e.fetchData}}),e._v(" "),a("el-dialog",{attrs:{title:e.textMap[e.dialogStatus],visible:e.dialogFormVisible,width:"800px"},on:{"update:visible":function(t){e.dialogFormVisible=t}}},[a("el-form",{ref:"dataForm",attrs:{rules:e.rules,model:e.temp,"label-position":"left","label-width":"100px"}},[a("el-form-item",{attrs:{label:"数据源",prop:"datasource"}},[a("el-select",{staticStyle:{width:"200px"},attrs:{placeholder:"数据源"},on:{change:function(t){return e.selectDataSource(e.temp.datasource)}},model:{value:e.temp.datasource,callback:function(t){e.$set(e.temp,"datasource",t)},expression:"temp.datasource"}},e._l(e.dataSources,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),e._v(" "),a("el-form-item",{attrs:{label:"数据源名称",prop:"datasourceName"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"数据源名称"},model:{value:e.temp.datasourceName,callback:function(t){e.$set(e.temp,"datasourceName",t)},expression:"temp.datasourceName"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"数据源分组",prop:"datasourceGroup"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"数据源分组"},model:{value:e.temp.datasourceGroup,callback:function(t){e.$set(e.temp,"datasourceGroup",t)},expression:"temp.datasourceGroup"}})],1),e._v(" "),e.jdbc||e.mongodb?a("el-form-item",{attrs:{label:"用户名",prop:"jdbcUsername"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"用户名"},model:{value:e.temp.jdbcUsername,callback:function(t){e.$set(e.temp,"jdbcUsername",t)},expression:"temp.jdbcUsername"}})],1):e._e(),e._v(" "),e.visible?a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.jdbc||e.mongodb,expression:"jdbc || mongodb"}],attrs:{label:"密码",prop:"jdbcPassword"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{type:"password",placeholder:"密码"},model:{value:e.temp.jdbcPassword,callback:function(t){e.$set(e.temp,"jdbcPassword",t)},expression:"temp.jdbcPassword"}},[a("i",{staticClass:"el-icon-view",staticStyle:{cursor:"pointer"},attrs:{slot:"suffix",title:"显示密码"},on:{click:function(t){return e.changePass("show")}},slot:"suffix"})])],1):a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.jdbc||e.mongodb,expression:"jdbc || mongodb"}],attrs:{label:"密码",prop:"jdbcPassword"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{type:"text",placeholder:"密码"},model:{value:e.temp.jdbcPassword,callback:function(t){e.$set(e.temp,"jdbcPassword",t)},expression:"temp.jdbcPassword"}},[a("i",{staticClass:"el-icon-check",staticStyle:{cursor:"pointer"},attrs:{slot:"suffix",title:"隐藏密码"},on:{click:function(t){return e.changePass("hide")}},slot:"suffix"})])],1),e._v(" "),e.jdbc?a("el-form-item",{attrs:{label:"jdbc url",prop:"jdbcUrl"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:3,maxRows:6},type:"textarea",placeholder:"jdbc url"},model:{value:e.temp.jdbcUrl,callback:function(t){e.$set(e.temp,"jdbcUrl",t)},expression:"temp.jdbcUrl"}})],1):e._e(),e._v(" "),e.mongodb?a("el-form-item",{attrs:{label:"地址",prop:"jdbcUrl"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:3,maxRows:6},type:"textarea",placeholder:"127.0.0.1:27017"},model:{value:e.temp.jdbcUrl,callback:function(t){e.$set(e.temp,"jdbcUrl",t)},expression:"temp.jdbcUrl"}})],1):e._e(),e._v(" "),e.jdbc?a("el-form-item",{attrs:{label:"jdbc驱动类",prop:"jdbcDriverClass"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"jdbc驱动类"},model:{value:e.temp.jdbcDriverClass,callback:function(t){e.$set(e.temp,"jdbcDriverClass",t)},expression:"temp.jdbcDriverClass"}})],1):e._e(),e._v(" "),e.hbase?a("el-form-item",{attrs:{label:"ZK地址",prop:"zkAdress"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"127.0.0.1:2181"},model:{value:e.temp.zkAdress,callback:function(t){e.$set(e.temp,"zkAdress",t)},expression:"temp.zkAdress"}})],1):e._e(),e._v(" "),e.mongodb?a("el-form-item",{attrs:{label:"数据库名称",prop:"databaseName"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"数据库名称"},model:{value:e.temp.databaseName,callback:function(t){e.$set(e.temp,"databaseName",t)},expression:"temp.databaseName"}})],1):e._e(),e._v(" "),a("el-form-item",{attrs:{label:"注释"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:2,maxRows:4},type:"textarea",placeholder:"Please input"},model:{value:e.temp.comments,callback:function(t){e.$set(e.temp,"comments",t)},expression:"temp.comments"}})],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.dialogFormVisible=!1}}},[e._v("\n 取消\n ")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){"create"===e.dialogStatus?e.createData():e.updateData()}}},[e._v("\n 确认\n ")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.testDataSource()}}},[e._v("\n 测试连接\n ")])],1)],1),e._v(" "),a("el-dialog",{attrs:{visible:e.dialogPluginVisible,title:"Reading statistics"},on:{"update:visible":function(t){e.dialogPluginVisible=t}}},[a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.pluginData,border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{prop:"key",label:"Channel"}}),e._v(" "),a("el-table-column",{attrs:{prop:"pv",label:"Pv"}})],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.dialogPvVisible=!1}}},[e._v("Confirm")])],1)],1)],1)},r=[],i=a("7e39"),o=a("6724"),l=a("ed08"),n=a("333d"),c={name:"DataxJdbcDatasource",components:{Pagination:n["a"]},directives:{waves:o["a"]},filters:{statusFilter:function(e){var t={published:"success",draft:"gray",deleted:"danger"};return t[e]}},data:function(){return{list:null,listLoading:!0,total:0,listQuery:{current:1,size:10},pluginTypeOptions:["reader","writer"],dialogPluginVisible:!1,pluginData:[],dialogFormVisible:!1,dialogStatus:"",textMap:{update:"Edit",create:"Create"},rules:{datasourceName:[{required:!0,message:"this is required",trigger:"blur"}],jdbcUsername:[{required:!0,message:"this is required",trigger:"blur"}],jdbcPassword:[{required:!0,message:"this is required",trigger:"blur"}],jdbcUrl:[{required:!0,message:"this is required",trigger:"blur"}],jdbcDriverClass:[{required:!0,message:"this is required",trigger:"blur"}],datasource:[{required:!0,message:"this is required",trigger:"change"}],zkAdress:[{required:!0,message:"this is required",trigger:"blur"}],databaseName:[{required:!0,message:"this is required",trigger:"blur"}]},temp:{id:void 0,datasourceName:"",datasourceGroup:"Default",jdbcUsername:"",jdbcPassword:"",jdbcUrl:"",jdbcDriverClass:"",comments:"",datasource:"",zkAdress:"",databaseName:""},visible:!0,dataSources:[{value:"mysql",label:"mysql"},{value:"oracle",label:"oracle"},{value:"postgresql",label:"postgresql"},{value:"sqlserver",label:"sqlserver"},{value:"hive",label:"hive"},{value:"hbase",label:"hbase"},{value:"mongodb",label:"mongodb"}],jdbc:!0,hbase:!1,mongodb:!1}},created:function(){this.fetchData()},methods:{selectDataSource:function(e){"mysql"===e?(this.temp.jdbcUrl="jdbc:mysql://{host}:{port}/{database}",this.temp.jdbcDriverClass="com.mysql.jdbc.Driver"):"oracle"===e?(this.temp.jdbcUrl="jdbc:oracle:thin:@//{host}:{port}/{database}",this.temp.jdbcDriverClass="oracle.jdbc.OracleDriver"):"postgresql"===e?(this.temp.jdbcUrl="jdbc:postgresql://{host}:{port}/{database}",this.temp.jdbcDriverClass="org.postgresql.Driver"):"sqlserver"===e?(this.temp.jdbcUrl="jdbc:sqlserver://{host}:{port};DatabaseName={database}",this.temp.jdbcDriverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"):"hive"===e&&(this.temp.jdbcUrl="jdbc:hive2://{host}:{port}/{database}",this.temp.jdbcDriverClass="org.apache.hive.jdbc.HiveDriver",this.hbase=this.mongodb=!1,this.jdbc=!0),this.getShowStrategy(e)},fetchData:function(){var e=this;this.listLoading=!0,i["d"](this.listQuery).then((function(t){var a=t.records,s=t.total;e.total=s,e.list=a,e.listLoading=!1}))},resetTemp:function(){this.temp={id:void 0,datasourceName:"",datasourceGroup:"Default",jdbcUsername:"",jdbcPassword:"",jdbcUrl:"",jdbcDriverClass:"",comments:""}},handleCreate:function(){var e=this;this.resetTemp(),this.dialogStatus="create",this.dialogFormVisible=!0,this.$nextTick((function(){e.$refs["dataForm"].clearValidate()}))},createData:function(){var e=this;this.$refs["dataForm"].validate((function(t){t&&i["a"](e.temp).then((function(){e.fetchData(),e.dialogFormVisible=!1,e.$notify({title:"Success",message:"Created Successfully",type:"success",duration:2e3})}))}))},testDataSource:function(){var e=this;this.$refs["dataForm"].validate((function(t){t&&i["e"](e.temp).then((function(t){!1===t.data?e.$notify({title:"Fail",message:t.data.msg,type:"fail",duration:2e3}):e.$notify({title:"Success",message:"Tested Successfully",type:"success",duration:2e3})}))}))},handleUpdate:function(e){var t=this;this.getShowStrategy(e.datasource),this.temp=Object.assign({},e),this.dialogStatus="update",this.dialogFormVisible=!0,this.$nextTick((function(){t.$refs["dataForm"].clearValidate()}))},updateData:function(){var e=this;this.$refs["dataForm"].validate((function(t){if(t){var a=Object.assign({},e.temp);i["f"](a).then((function(){e.fetchData(),e.dialogFormVisible=!1,e.$notify({title:"Success",message:"Update Successfully",type:"success",duration:2e3})}))}}))},getShowStrategy:function(e){"hbase"===e?(this.jdbc=this.mongodb=!1,this.hbase=!0):"mongodb"===e?(this.jdbc=this.hbase=!1,this.mongodb=!0,this.temp.jdbcUrl="{host}:{port}"):(this.hbase=this.mongodb=!1,this.jdbc=!0)},handleDelete:function(e){var t=this;console.log("删除");var a=[];a.push(e.id),i["b"]({idList:e.id}).then((function(e){t.fetchData(),t.$notify({title:"Success",message:"Delete Successfully",type:"success",duration:2e3})}))},handleFetchPv:function(e){var t=this;i["c"](e).then((function(e){t.pluginData=e,t.dialogPvVisible=!0}))},formatJson:function(e,t){return t.map((function(t){return e.map((function(e){return"timestamp"===e?Object(l["f"])(t[e]):t[e]}))}))},changePass:function(e){this.visible=!("show"===e)}}},u=c,d=a("2877"),p=Object(d["a"])(u,s,r,!1,null,null,null);t["default"]=p.exports},"333d":function(e,t,a){"use strict";var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"pagination-container",class:{hidden:e.hidden}},[a("el-pagination",e._b({attrs:{background:e.background,"current-page":e.currentPage,"page-size":e.pageSize,layout:e.layout,"page-sizes":e.pageSizes,total:e.total},on:{"update:currentPage":function(t){e.currentPage=t},"update:current-page":function(t){e.currentPage=t},"update:pageSize":function(t){e.pageSize=t},"update:page-size":function(t){e.pageSize=t},"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}},"el-pagination",e.$attrs,!1))],1)},r=[];a("c5f6");Math.easeInOutQuad=function(e,t,a,s){return e/=s/2,e<1?a/2*e*e+t:(e--,-a/2*(e*(e-2)-1)+t)};var i=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}();function o(e){document.documentElement.scrollTop=e,document.body.parentNode.scrollTop=e,document.body.scrollTop=e}function l(){return document.documentElement.scrollTop||document.body.parentNode.scrollTop||document.body.scrollTop}function n(e,t,a){var s=l(),r=e-s,n=20,c=0;t="undefined"===typeof t?500:t;var u=function e(){c+=n;var l=Math.easeInOutQuad(c,s,r,t);o(l),c0,expression:"total>0"}],attrs:{total:e.total,page:e.listQuery.current,limit:e.listQuery.size},on:{"update:page":function(t){return e.$set(e.listQuery,"current",t)},"update:limit":function(t){return e.$set(e.listQuery,"size",t)},pagination:e.fetchData}}),e._v(" "),a("el-dialog",{attrs:{title:e.textMap[e.dialogStatus],visible:e.dialogFormVisible,width:"800px"},on:{"update:visible":function(t){e.dialogFormVisible=t}}},[a("el-form",{ref:"dataForm",attrs:{rules:e.rules,model:e.temp,"label-position":"left","label-width":"100px"}},[a("el-form-item",{attrs:{label:"数据源",prop:"datasource"}},[a("el-select",{staticStyle:{width:"200px"},attrs:{placeholder:"数据源"},on:{change:function(t){return e.selectDataSource(e.temp.datasource)}},model:{value:e.temp.datasource,callback:function(t){e.$set(e.temp,"datasource",t)},expression:"temp.datasource"}},e._l(e.dataSources,(function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),e._v(" "),a("el-form-item",{attrs:{label:"数据源名称",prop:"datasourceName"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"数据源名称"},model:{value:e.temp.datasourceName,callback:function(t){e.$set(e.temp,"datasourceName",t)},expression:"temp.datasourceName"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"数据源分组",prop:"datasourceGroup"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"数据源分组"},model:{value:e.temp.datasourceGroup,callback:function(t){e.$set(e.temp,"datasourceGroup",t)},expression:"temp.datasourceGroup"}})],1),e._v(" "),e.jdbc||e.mongodb?a("el-form-item",{attrs:{label:"用户名"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{placeholder:"用户名"},model:{value:e.temp.jdbcUsername,callback:function(t){e.$set(e.temp,"jdbcUsername",t)},expression:"temp.jdbcUsername"}})],1):e._e(),e._v(" "),e.visible?a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.jdbc||e.mongodb,expression:"jdbc || mongodb"}],attrs:{label:"密码"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{type:"password",placeholder:"密码"},model:{value:e.temp.jdbcPassword,callback:function(t){e.$set(e.temp,"jdbcPassword",t)},expression:"temp.jdbcPassword"}},[a("i",{staticClass:"el-icon-view",staticStyle:{cursor:"pointer"},attrs:{slot:"suffix",title:"显示密码"},on:{click:function(t){return e.changePass("show")}},slot:"suffix"})])],1):a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.jdbc||e.mongodb,expression:"jdbc || mongodb"}],attrs:{label:"密码"}},[a("el-input",{staticStyle:{width:"40%"},attrs:{type:"text",placeholder:"密码"},model:{value:e.temp.jdbcPassword,callback:function(t){e.$set(e.temp,"jdbcPassword",t)},expression:"temp.jdbcPassword"}},[a("i",{staticClass:"el-icon-check",staticStyle:{cursor:"pointer"},attrs:{slot:"suffix",title:"隐藏密码"},on:{click:function(t){return e.changePass("hide")}},slot:"suffix"})])],1),e._v(" "),e.jdbc?a("el-form-item",{attrs:{label:"jdbc url",prop:"jdbcUrl"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:3,maxRows:6},type:"textarea",placeholder:"jdbc url"},model:{value:e.temp.jdbcUrl,callback:function(t){e.$set(e.temp,"jdbcUrl",t)},expression:"temp.jdbcUrl"}})],1):e._e(),e._v(" "),e.mongodb?a("el-form-item",{attrs:{label:"地址",prop:"jdbcUrl"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:3,maxRows:6},type:"textarea",placeholder:"127.0.0.1:27017"},model:{value:e.temp.jdbcUrl,callback:function(t){e.$set(e.temp,"jdbcUrl",t)},expression:"temp.jdbcUrl"}})],1):e._e(),e._v(" "),e.jdbc?a("el-form-item",{attrs:{label:"jdbc驱动类",prop:"jdbcDriverClass"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"jdbc驱动类"},model:{value:e.temp.jdbcDriverClass,callback:function(t){e.$set(e.temp,"jdbcDriverClass",t)},expression:"temp.jdbcDriverClass"}})],1):e._e(),e._v(" "),e.hbase?a("el-form-item",{attrs:{label:"ZK地址",prop:"zkAdress"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"127.0.0.1:2181"},model:{value:e.temp.zkAdress,callback:function(t){e.$set(e.temp,"zkAdress",t)},expression:"temp.zkAdress"}})],1):e._e(),e._v(" "),e.mongodb?a("el-form-item",{attrs:{label:"数据库名称",prop:"databaseName"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{placeholder:"数据库名称"},model:{value:e.temp.databaseName,callback:function(t){e.$set(e.temp,"databaseName",t)},expression:"temp.databaseName"}})],1):e._e(),e._v(" "),a("el-form-item",{attrs:{label:"注释"}},[a("el-input",{staticStyle:{width:"60%"},attrs:{autosize:{minRows:2,maxRows:4},type:"textarea",placeholder:"Please input"},model:{value:e.temp.comments,callback:function(t){e.$set(e.temp,"comments",t)},expression:"temp.comments"}})],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.dialogFormVisible=!1}}},[e._v("\n 取消\n ")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){"create"===e.dialogStatus?e.createData():e.updateData()}}},[e._v("\n 确认\n ")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.testDataSource()}}},[e._v("\n 测试连接\n ")])],1)],1),e._v(" "),a("el-dialog",{attrs:{visible:e.dialogPluginVisible,title:"Reading statistics"},on:{"update:visible":function(t){e.dialogPluginVisible=t}}},[a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.pluginData,border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{prop:"key",label:"Channel"}}),e._v(" "),a("el-table-column",{attrs:{prop:"pv",label:"Pv"}})],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.dialogPvVisible=!1}}},[e._v("Confirm")])],1)],1)],1)},i=[],r=a("7e39"),l=a("6724"),o=a("ed08"),n=a("333d"),c={name:"DataxJdbcDatasource",components:{Pagination:n["a"]},directives:{waves:l["a"]},filters:{statusFilter:function(e){var t={published:"success",draft:"gray",deleted:"danger"};return t[e]}},data:function(){return{list:null,listLoading:!0,total:0,listQuery:{current:1,size:10},pluginTypeOptions:["reader","writer"],dialogPluginVisible:!1,pluginData:[],dialogFormVisible:!1,dialogStatus:"",textMap:{update:"Edit",create:"Create"},rules:{datasourceName:[{required:!0,message:"this is required",trigger:"blur"}],jdbcUsername:[{required:!0,message:"this is required",trigger:"blur"}],jdbcPassword:[{required:!0,message:"this is required",trigger:"blur"}],jdbcUrl:[{required:!0,message:"this is required",trigger:"blur"}],jdbcDriverClass:[{required:!0,message:"this is required",trigger:"blur"}],datasource:[{required:!0,message:"this is required",trigger:"change"}],zkAdress:[{required:!0,message:"this is required",trigger:"blur"}],databaseName:[{required:!0,message:"this is required",trigger:"blur"}]},temp:{id:void 0,datasourceName:"",datasourceGroup:"Default",jdbcUsername:"",jdbcPassword:"",jdbcUrl:"",jdbcDriverClass:"",comments:"",datasource:"",zkAdress:"",databaseName:""},visible:!0,dataSources:[{value:"mysql",label:"mysql"},{value:"oracle",label:"oracle"},{value:"postgresql",label:"postgresql"},{value:"sqlserver",label:"sqlserver"},{value:"hive",label:"hive"},{value:"hbase",label:"hbase"},{value:"mongodb",label:"mongodb"}],jdbc:!0,hbase:!1,mongodb:!1}},created:function(){this.fetchData()},methods:{selectDataSource:function(e){"mysql"===e?(this.temp.jdbcUrl="jdbc:mysql://{host}:{port}/{database}",this.temp.jdbcDriverClass="com.mysql.jdbc.Driver"):"oracle"===e?(this.temp.jdbcUrl="jdbc:oracle:thin:@//{host}:{port}/{database}",this.temp.jdbcDriverClass="oracle.jdbc.OracleDriver"):"postgresql"===e?(this.temp.jdbcUrl="jdbc:postgresql://{host}:{port}/{database}",this.temp.jdbcDriverClass="org.postgresql.Driver"):"sqlserver"===e?(this.temp.jdbcUrl="jdbc:sqlserver://{host}:{port};DatabaseName={database}",this.temp.jdbcDriverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"):"hive"===e&&(this.temp.jdbcUrl="jdbc:hive2://{host}:{port}/{database}",this.temp.jdbcDriverClass="org.apache.hive.jdbc.HiveDriver",this.hbase=this.mongodb=!1,this.jdbc=!0),this.getShowStrategy(e)},fetchData:function(){var e=this;this.listLoading=!0,r["d"](this.listQuery).then((function(t){var a=t.records,s=t.total;e.total=s,e.list=a,e.listLoading=!1}))},resetTemp:function(){this.temp={id:void 0,datasourceName:"",datasourceGroup:"Default",jdbcUsername:"",jdbcPassword:"",jdbcUrl:"",jdbcDriverClass:"",comments:""}},handleCreate:function(){var e=this;this.resetTemp(),this.dialogStatus="create",this.dialogFormVisible=!0,this.$nextTick((function(){e.$refs["dataForm"].clearValidate()}))},createData:function(){var e=this;this.$refs["dataForm"].validate((function(t){t&&r["a"](e.temp).then((function(){e.fetchData(),e.dialogFormVisible=!1,e.$notify({title:"Success",message:"Created Successfully",type:"success",duration:2e3})}))}))},testDataSource:function(){var e=this;this.$refs["dataForm"].validate((function(t){t&&r["e"](e.temp).then((function(t){!1===t.data?e.$notify({title:"Fail",message:t.data.msg,type:"fail",duration:2e3}):e.$notify({title:"Success",message:"Tested Successfully",type:"success",duration:2e3})}))}))},handleUpdate:function(e){var t=this;this.getShowStrategy(e.datasource),this.temp=Object.assign({},e),this.dialogStatus="update",this.dialogFormVisible=!0,this.$nextTick((function(){t.$refs["dataForm"].clearValidate()}))},updateData:function(){var e=this;this.$refs["dataForm"].validate((function(t){if(t){var a=Object.assign({},e.temp);r["f"](a).then((function(){e.fetchData(),e.dialogFormVisible=!1,e.$notify({title:"Success",message:"Update Successfully",type:"success",duration:2e3})}))}}))},getShowStrategy:function(e){"hbase"===e?(this.jdbc=this.mongodb=!1,this.hbase=!0):"mongodb"===e?(this.jdbc=this.hbase=!1,this.mongodb=!0,this.temp.jdbcUrl="{host}:{port}"):(this.hbase=this.mongodb=!1,this.jdbc=!0)},handleDelete:function(e){var t=this;console.log("删除");var a=[];a.push(e.id),r["b"]({idList:e.id}).then((function(e){t.fetchData(),t.$notify({title:"Success",message:"Delete Successfully",type:"success",duration:2e3})}))},handleFetchPv:function(e){var t=this;r["c"](e).then((function(e){t.pluginData=e,t.dialogPvVisible=!0}))},formatJson:function(e,t){return t.map((function(t){return e.map((function(e){return"timestamp"===e?Object(o["f"])(t[e]):t[e]}))}))},changePass:function(e){this.visible=!("show"===e)}}},u=c,d=a("2877"),p=Object(d["a"])(u,s,i,!1,null,null,null);t["default"]=p.exports},"333d":function(e,t,a){"use strict";var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"pagination-container",class:{hidden:e.hidden}},[a("el-pagination",e._b({attrs:{background:e.background,"current-page":e.currentPage,"page-size":e.pageSize,layout:e.layout,"page-sizes":e.pageSizes,total:e.total},on:{"update:currentPage":function(t){e.currentPage=t},"update:current-page":function(t){e.currentPage=t},"update:pageSize":function(t){e.pageSize=t},"update:page-size":function(t){e.pageSize=t},"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}},"el-pagination",e.$attrs,!1))],1)},i=[];a("c5f6");Math.easeInOutQuad=function(e,t,a,s){return e/=s/2,e<1?a/2*e*e+t:(e--,-a/2*(e*(e-2)-1)+t)};var r=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}();function l(e){document.documentElement.scrollTop=e,document.body.parentNode.scrollTop=e,document.body.scrollTop=e}function o(){return document.documentElement.scrollTop||document.body.parentNode.scrollTop||document.body.scrollTop}function n(e,t,a){var s=o(),i=e-s,n=20,c=0;t="undefined"===typeof t?500:t;var u=function e(){c+=n;var o=Math.easeInOutQuad(c,s,i,t);l(o),c