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