Browse Source

DEC-21498 fix: 【FR配合】连接池配置优化

feature/x
dailer 3 years ago
parent
commit
bef463ad19
  1. 390
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  2. 1758
      src/modules/pages/maintain/forms/components/form.jdbc.ts

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

@ -1,195 +1,195 @@
import { shortcut, store } from '@core/core'; import { shortcut, store } from '@core/core';
import { FormItem } from '../components/form_item/form_item'; import { FormItem } from '../components/form_item/form_item';
import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import { ConnectionJdecModel } from './connection_jdbc.model'; import { ConnectionJdecModel } from './connection_jdbc.model';
import { ConnectionJDBC } from 'src/modules/crud/crud.typings'; import { ConnectionJDBC } from 'src/modules/crud/crud.typings';
import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../app.service'; import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../app.service';
import { CONNECTION_LAYOUT } from '@constants/constant'; import { CONNECTION_LAYOUT } from '@constants/constant';
import { VerticalLayout } from '@fui/core'; import { VerticalLayout } from '@fui/core';
import { ApiFactory } from '../../../crud/apiFactory'; import { ApiFactory } from '../../../crud/apiFactory';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@shortcut() @shortcut()
@store(ConnectionJdecModel) @store(ConnectionJdecModel)
export class ConnectionJdbc extends BI.Widget { export class ConnectionJdbc extends BI.Widget {
static xtype = 'dec.dcm.connection_jdbc'; static xtype = 'dec.dcm.connection_jdbc';
advancedSet: any; advancedSet: any;
model: ConnectionJdecModel['model']; model: ConnectionJdecModel['model'];
allDatabaseTypes = getAllDatabaseTypes(); allDatabaseTypes = getAllDatabaseTypes();
render() { render() {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { const {
driver, driver,
driverSource, driverSource,
database, database,
user, user,
originalCharsetName, originalCharsetName,
schema, schema,
connectionPoolAttr, connectionPoolAttr,
authType, authType,
principal, principal,
url, url,
fetchSize, fetchSize,
} = connectionData; } = connectionData;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName } = resolveUrlInfo(url, database); const { host, port, databaseName } = resolveUrlInfo(url, database);
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
return { return {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
hgap, hgap,
vgap, vgap,
items: [ items: [
{ {
type: FormItem.xtype, type: FormItem.xtype,
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, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),
value: databaseName, value: databaseName,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Host'), name: BI.i18nText('Dec-Dcm_Connection_Form_Host'),
value: host, value: host,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'),
value: port, value: port,
}, },
authType ? authType ?
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_AuthType'), name: BI.i18nText('Dec-Dcm_Connection_Form_AuthType'),
value: authType, value: authType,
} : { } : {
type: BI.Layout.xtype, type: BI.Layout.xtype,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_Principal') : BI.i18nText('Dec-Dcm_Connection_Form_UserName'), name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_Principal') : BI.i18nText('Dec-Dcm_Connection_Form_UserName'),
value: authType ? principal : user, value: authType ? principal : user,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'), name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'),
value: '******', value: '******',
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),
value: originalCharsetName ? originalCharsetName : BI.i18nText('Dec-Dcm_Connection_Form_Default'), value: originalCharsetName ? originalCharsetName : BI.i18nText('Dec-Dcm_Connection_Form_Default'),
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'), name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
value: schema, value: schema,
invisible: !databaseType.hasSchema, invisible: !databaseType.hasSchema,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'),
value: url, value: url,
}, },
{ {
type: Collapse.xtype, type: FormItem.xtype,
width: 70, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'),
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Advanced_Setting'), value: connectionPoolAttr.maxActive,
listeners: [ },
{ {
eventName: EVENT_CHANGE, type: FormItem.xtype,
action: (isCollapse: boolean) => { name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'),
this.advancedSet.setVisible(!isCollapse); value: connectionPoolAttr.testOnBorrow ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'),
}, },
}, {
], type: FormItem.xtype,
}, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Validation_Query'),
{ value: api.getPlain(connectionPoolAttr.validationQuery || ''),
type: BI.VerticalLayout.xtype, },
tgap: -15, {
vgap, type: FormItem.xtype,
invisible: true, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'),
ref: (_ref: VerticalLayout) => { value: connectionPoolAttr.maxWait,
this.advancedSet = _ref; unit: BI.i18nText('Dec-Dcm_Millisecond'),
}, },
items: [ {
{ type: Collapse.xtype,
type: FormItem.xtype, width: 70,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Advanced_Setting'),
value: connectionPoolAttr.initialSize, listeners: [
}, {
{ eventName: EVENT_CHANGE,
type: FormItem.xtype, action: (isCollapse: boolean) => {
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), this.advancedSet.setVisible(!isCollapse);
value: connectionPoolAttr.maxActive, },
}, },
{ ],
type: FormItem.xtype, },
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'), {
value: connectionPoolAttr.maxIdle, type: BI.VerticalLayout.xtype,
}, tgap: -15,
{ vgap,
type: FormItem.xtype, invisible: true,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'), ref: (_ref: VerticalLayout) => {
value: connectionPoolAttr.minIdle, this.advancedSet = _ref;
}, },
{ items: [
type: FormItem.xtype, {
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), type: FormItem.xtype,
value: connectionPoolAttr.maxWait, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'),
unit: BI.i18nText('Dec-Dcm_Millisecond'), value: connectionPoolAttr.initialSize,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Validation_Query'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'),
value: api.getPlain(connectionPoolAttr.validationQuery || ''), value: connectionPoolAttr.maxIdle,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'),
value: connectionPoolAttr.testOnBorrow ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), value: connectionPoolAttr.minIdle,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Return'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Return'),
value: connectionPoolAttr.testOnReturn ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), value: connectionPoolAttr.testOnReturn ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'),
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_While_Idle'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_While_Idle'),
value: connectionPoolAttr.testWhileIdle ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), value: connectionPoolAttr.testWhileIdle ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'),
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'),
value: connectionPoolAttr.timeBetweenEvictionRunsMillis, value: connectionPoolAttr.timeBetweenEvictionRunsMillis,
unit: BI.i18nText('Dec-Dcm_Millisecond'), unit: BI.i18nText('Dec-Dcm_Millisecond'),
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'),
value: connectionPoolAttr.numTestsPerEvictionRun, value: connectionPoolAttr.numTestsPerEvictionRun,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'),
value: connectionPoolAttr.minEvictableIdleTimeMillis, value: connectionPoolAttr.minEvictableIdleTimeMillis,
unit: BI.i18nText('BI-Basic_Seconds'), unit: BI.i18nText('BI-Basic_Seconds'),
}, { }, {
type: FormItem.xtype, type: FormItem.xtype,
invisible: fetchSize < 0 && fetchSize !== -2, invisible: fetchSize < 0 && fetchSize !== -2,
name: 'Fetchsize', name: 'Fetchsize',
value: fetchSize === -2 ? '' : fetchSize, value: fetchSize === -2 ? '' : fetchSize,
}, },
], ],
}, },
], ],
}; };
} }
} }

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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save