From 201c72f544eb307a85ea4a52da4b3393c0a1326a Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 20 Sep 2019 10:44:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-9777=20=E4=BF=AE=E6=94=B9=E5=85=B6?= =?UTF-8?q?=E4=BB=96jdbc=E9=BB=98=E8=AE=A4url=EF=BC=8C=E4=B8=94=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E9=A9=B1=E5=8A=A8=E5=8C=B9=E9=85=8D=E4=B8=8D=E5=90=8C?= =?UTF-8?q?url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.typings.d.ts | 3 +++ src/modules/constants/constant.ts | 22 +++++++++++++++++-- .../maintain/forms/components/form.jdbc.ts | 15 +++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/modules/app.typings.d.ts b/src/modules/app.typings.d.ts index 2d48bd8..67a5665 100644 --- a/src/modules/app.typings.d.ts +++ b/src/modules/app.typings.d.ts @@ -10,4 +10,7 @@ export interface DatabaseType { hasSchema?: boolean; kerberos?: boolean; iconUrl?: string; + urls?: { + [key: string]: string; + } } diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 1ededbe..993a0df 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -189,6 +189,10 @@ export const DATA_BASE_TYPES = [ type: 'jdbc', hasSchema: true, kerberos: false, + urls: { + 'com.amazon.redshift.jdbc4.Driver': 'jdbc:redshift://endpoint:port/database', + 'com.amazon.redshift.jdbc41.Driver': 'jdbc:postgresql://endpoint:port/database', + }, }, { text: 'APACHE IMPALA', @@ -412,6 +416,10 @@ export const DATA_BASE_TYPES = [ type: 'jdbc', hasSchema: false, kerberos: false, + urls: { + 'com.mysql.jdbc.Driver': 'jdbc:mysql://localhost/dbname', + 'org.gjt.mm.mysql.Driver': 'jdbc:mysql://localhost/dbname', + }, }, { text: 'Oracle', @@ -428,12 +436,17 @@ export const DATA_BASE_TYPES = [ text: 'Pivotal Greenplum Database', databaseType: 'pivotal-greenplum-database', driver: 'org.postgresql.Driver', + drivers: ['org.postgresql.Driver', 'com.pivotal.jdbc.GreenplumDriver'], url: 'jdbc:postgresql://hostname:port/database', commonly: false, internal: true, type: 'jdbc', hasSchema: true, kerberos: false, + urls: { + 'org.postgresql.Driver': 'jdbc:postgresql://hostname:port/dbname', + 'com.pivotal.jdbc.GreenplumDriver': 'jdbc:pivotal:greenplum://hostname:port;dbname', + }, }, { text: 'Postgresql', databaseType: 'postgresql', @@ -528,14 +541,19 @@ export const DATA_BASE_TYPES = [ { text: BI.i18nText('Dec-Dcm_Connection_JDBC_Other'), databaseType: 'other', - driver: 'org.ha.Driver', - drivers: ['org.ha.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'], + driver: 'org.h2.Driver', + drivers: ['org.h2.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'], url: 'jdbc:h2://hostname:port/database', commonly: false, internal: true, type: 'other', hasSchema: true, kerberos: false, + urls: { + 'org.h2.Driver': 'jdbc:h2://hostname:port/database', + 'com.fr.third.org.hsqldb.jdbcDriver': 'jdbc:hsqldb:file:[PATH_TO_DB_FILES]', + 'org.sqlite.JDBC': 'jdbc:sqlite:[PATH_TO_DB_FILES]', + }, }, ...BI.Constants.getConstant(CONSTANT_PLUGIN_TYPES).map(item => { return { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index bd5590a..c4a7dc9 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -108,6 +108,21 @@ export class FormJdbc extends BI.Widget { hasNext: false, }); }, + listeners: [{ + eventName: BI.SingleSelectInsertCombo.EVENT_CONFIRM, + action: () => { + const value = this.form.driver.getValue(); + const connectionData = this.options.formData.connectionData as ConnectionJDBC; + const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); + if (connectionType.urls) { + this.form.url.setValue(connectionType.urls[value]); + const urlInfo = resolveUrlInfo(connectionType.urls[value]); + this.form.host.setValue(urlInfo.host); + this.form.database.setValue(urlInfo.databaseName); + this.form.port.setValue(urlInfo.port); + } + }, + }], }], }, {