Browse Source

Merge pull request #8233 in DEC/decision-webui-dcm from feature/x to bugfix/11.0

* commit '39164b77998f80f05d3b31c3b9d89488f2ef414d':
  REPORT-99289 删除代码中的debugger
  REPORT-99289 数据连接适配加一个catalog配置项
bugfix/11.0
superman 1 year ago
parent
commit
edcfa64820
  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 {
host: result[1],
port: result[2] === 'port' ? '' : result[2],
databaseName: result[4] || '',
catalog: result[3],
databaseName: result[4],
urlInfo: result[0],
};
}
// 处理starRocks数据连接负载均衡模式
const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i);
if (loadBalance){
const database: string = loadBalance[2];
return {
host: '',
port: '',
databaseName: database,
catalog: loadBalance[1],
databaseName: loadBalance[2],
urlInfo: loadBalance[0],
}
}

8
src/modules/app.service.ts

@ -61,7 +61,7 @@ export function resolveUrlInfo(url: string, database?: string) {
}
// 拼接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')) {
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('=database', `=${database}`);
@ -75,6 +75,12 @@ export function splitUrl(host: string, port: string, database: string, baseUrl:
.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}` : '')
.replace('/database', `/${database}`)
.replace(':database', `:${database}`)

2
src/modules/constants/constant.ts

@ -722,7 +722,7 @@ export const DATA_BASE_TYPES = [
databaseType: 'starrocks',
driver: '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,
internal: true,
type: 'jdbc',

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

@ -57,7 +57,7 @@ export class ConnectionJdbc extends BI.Widget {
hdfs,
} = connectionData;
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;
const { hgap, vgap } = CONNECTION_LAYOUT;
@ -78,6 +78,12 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
},
{
type: FormItem.xtype,
name: 'catalog',
invisible: database !== 'starrocks',
value: catalog,
},
{
type: FormItem.xtype,
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,
version: null,
driver: null,
catalog: null,
database: null,
host: null,
port: null,
@ -160,7 +161,7 @@ export class FormJdbc extends BI.Widget {
} = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver);
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;
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,
@ -843,6 +871,7 @@ export class FormJdbc extends BI.Widget {
action: () => {
const urlInfo = resolveUrlInfo(this.form.url.getValue(), database);
this.form.host.setValue(urlInfo.host);
this.form.catalog.setValue(urlInfo.catalog);
this.form.database.setValue(urlInfo.databaseName);
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 host = this.form.host.getValue();
const port = this.form.port.getValue();
const catalog = this.form.catalog.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) {

Loading…
Cancel
Save