Browse Source

Pull request #8232: REPORT-99289 数据连接适配加一个catalog配置项

Merge in DEC/decision-webui-dcm from ~FANGLEI/decision-webui-dcm:feature/x to feature/x

* commit '2f42ff94a540c6a44c6c6cf0879632226a2d71a7':
  REPORT-99289 删除代码中的debugger
  REPORT-99289 数据连接适配加一个catalog配置项
feature/x
fanglei-方磊 1 year ago
parent
commit
39164b7799
  1. 7
      src/modules/app.provider.ts
  2. 8
      src/modules/app.service.ts
  3. 2
      src/modules/constants/constant.ts
  4. 8
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  5. 34
      src/modules/pages/maintain/forms/components/form.jdbc.ts

7
src/modules/app.provider.ts

@ -11,18 +11,19 @@ BI.provider('dec.connection.provider.datebase', function () {
return { return {
host: result[1], host: result[1],
port: result[2] === 'port' ? '' : result[2], port: result[2] === 'port' ? '' : result[2],
databaseName: result[4] || '', catalog: result[3],
databaseName: result[4],
urlInfo: result[0], urlInfo: result[0],
}; };
} }
// 处理starRocks数据连接负载均衡模式 // 处理starRocks数据连接负载均衡模式
const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i);
if (loadBalance){ if (loadBalance){
const database: string = loadBalance[2];
return { return {
host: '', host: '',
port: '', port: '',
databaseName: database, catalog: loadBalance[1],
databaseName: loadBalance[2],
urlInfo: loadBalance[0], urlInfo: loadBalance[0],
} }
} }

8
src/modules/app.service.ts

@ -61,7 +61,7 @@ export function resolveUrlInfo(url: string, database?: string) {
} }
// 拼接url // 拼接url
export function splitUrl(host: string, port: string, database: string, baseUrl: string) { export function splitUrl(host: string, port: string, catalog: string, database: string, baseUrl: string) {
if (baseUrl.startsWith('jdbc:sqlserver')) { if (baseUrl.startsWith('jdbc:sqlserver')) {
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('=database', `=${database}`); .replace('=database', `=${database}`);
@ -75,6 +75,12 @@ export function splitUrl(host: string, port: string, database: string, baseUrl:
.replace(':INFORMIXSERVER={server}', ''); .replace(':INFORMIXSERVER={server}', '');
} }
if (catalog) {
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('default_catalog', catalog)
.replace('database', database)
}
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('/database', `/${database}`) .replace('/database', `/${database}`)
.replace(':database', `:${database}`) .replace(':database', `:${database}`)

2
src/modules/constants/constant.ts

@ -722,7 +722,7 @@ export const DATA_BASE_TYPES = [
databaseType: 'starrocks', databaseType: 'starrocks',
driver: 'com.mysql.jdbc.Driver', driver: 'com.mysql.jdbc.Driver',
drivers: ['com.mysql.jdbc.Driver'], drivers: ['com.mysql.jdbc.Driver'],
url: 'jdbc:mysql://hostname:port/database', url: 'jdbc:mysql://hostname:port/default_catalog.database',
commonly: false, commonly: false,
internal: true, internal: true,
type: 'jdbc', type: 'jdbc',

8
src/modules/pages/connection/connection_jdbc/connection_jdbc.ts

@ -57,7 +57,7 @@ export class ConnectionJdbc extends BI.Widget {
hdfs, hdfs,
} = connectionData; } = connectionData;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName, version } = resolveUrlInfo(url, database); const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
@ -78,6 +78,12 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver, value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
}, },
{
type: FormItem.xtype,
name: 'catalog',
invisible: database !== 'starrocks',
value: catalog,
},
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),

34
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -51,6 +51,7 @@ export class FormJdbc extends BI.Widget {
connectionName: null, connectionName: null,
version: null, version: null,
driver: null, driver: null,
catalog: null,
database: null, database: null,
host: null, host: null,
port: null, port: null,
@ -160,7 +161,7 @@ export class FormJdbc extends BI.Widget {
} = connectionPoolAttr as ConnectionPoolJDBC; } = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
this.databaseType = databaseType; this.databaseType = databaseType;
const { host, port, databaseName, version } = resolveUrlInfo(url, database); const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
@ -262,6 +263,33 @@ export class FormJdbc extends BI.Widget {
}, },
], ],
}, },
// catalog
{
type: FormItem.xtype,
name: 'catalog',
invisible: database !== 'starrocks',
forms: [
{
type: BI.TextEditor.xtype,
$value: 'database-catalog',
width: EDITOR_WIDTH,
allowBlank: true,
watermark: 'catalog',
value: catalog,
ref: (_ref: any) => {
this.form.catalog = _ref;
},
listeners: [
{
eventName: BI.Editor.EVENT_CHANGE,
action: () => {
this.onHostPortChange(databaseType);
},
},
],
},
],
},
// 数据库名称 // 数据库名称
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -843,6 +871,7 @@ export class FormJdbc extends BI.Widget {
action: () => { action: () => {
const urlInfo = resolveUrlInfo(this.form.url.getValue(), database); const urlInfo = resolveUrlInfo(this.form.url.getValue(), database);
this.form.host.setValue(urlInfo.host); this.form.host.setValue(urlInfo.host);
this.form.catalog.setValue(urlInfo.catalog);
this.form.database.setValue(urlInfo.databaseName); this.form.database.setValue(urlInfo.databaseName);
this.form.port.setValue(urlInfo.port); this.form.port.setValue(urlInfo.port);
}, },
@ -1578,8 +1607,9 @@ export class FormJdbc extends BI.Widget {
const selectUrl = BI.get(urls, driver.driver) || url; const selectUrl = BI.get(urls, driver.driver) || url;
const host = this.form.host.getValue(); const host = this.form.host.getValue();
const port = this.form.port.getValue(); const port = this.form.port.getValue();
const catalog = this.form.catalog.getValue();
const database = this.form.database.getValue(); const database = this.form.database.getValue();
this.form.url.setValue(splitUrl(host, port, database, selectUrl)); this.form.url.setValue(splitUrl(host, port, catalog, database, selectUrl));
} }
private onSshTypeChange(sshType) { private onSshTypeChange(sshType) {

Loading…
Cancel
Save