diff --git a/babel.config.js b/babel.config.js index 9085ac7..092e4d1 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,13 @@ -module.exports = function (api) { - return require("@fui/babel-preset-fineui").configs.base(api) +module.exports = api => { + const { plugins, presets, sourceType } = require("@fui/babel-preset-fineui").configs.base(api); + + return { + compact: false, + presets, + sourceType, + plugins: [ + ...plugins, + "@babel/plugin-proposal-logical-assignment-operators", + ], + }; }; diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 7e5e8a1..1cb2866 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -85,10 +85,10 @@ Dec-Dcm_Connection_Form_Database_Max_Wait= 最大等待时间 Dec-Dcm_Connection_Form_Database_Validation_Query= SQL验证查询 Dec-Dcm_Connection_Form_Database_Test_On_Borrow= 获取连接前检验 Dec-Dcm_Connection_Form_Database_Test_On_Return= 归还连接前检验 -Dec-Dcm_Connection_Form_Database_Test_While_Idle= 开启空闲回收器检验 -Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis= 空闲连接回收器休眠时间 +Dec-Dcm_Connection_Form_Database_Test_While_Idle= 获取连接时空闲连接可用性校验 +Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis= 空闲连接回收器工作间隔 Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num= 空闲连接回收检查数 -Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis= 保持空闲最小时间值 +Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis= 空闲连接回收时间阈值 Dec-Dcm_Connection_Make_Sure_Delete= 确定删除该数据连接? Dec-Dcm_Connection_ReConnect= 重新连接 Dec-Dcm_Connection_JNDI_Form_ConnectionName= JNDI的名字 @@ -101,7 +101,7 @@ Dec-Dcm_Connection_JNDI= JNDI数据连接 Dec-Dcm_Connection_JNDI_Warning= 注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下 Dec-Dcm_Connection_Error= 接口访问错误 Dec-Dcm_Connection_Is_Using= 该连接正在被{R1}编辑,请稍后再试 -Dec-Dcm_Connection_Check_Integer= 请输入不小于0的整数 +Dec-Dcm_Connection_Check_Integer= 请输入不小于{}的整数 Dec-Dcm_Connection_Check_Number= 只允许为整数 Dec-Dcm_Connection_JDBC_Other=其他JDBC Dec-Dcm_Connection_JDBC_Warning= 请确认已经将krb5.Conf文件添加到/webapps/webroot/WEB_INF/resources目录 diff --git a/package.json b/package.json index 6d411c8..e59b383 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "author": "decision", "license": "MIT", "dependencies": { + "@babel/plugin-proposal-logical-assignment-operators": "^7.20.7", "@types/jss": "9.5.8", "autoprefixer": "^9.6.1", "es6-promise": "4.2.6", diff --git a/private/i18n.ts b/private/i18n.ts index 1a530af..eaf7e10 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -84,10 +84,10 @@ export default { 'Dec-Dcm_Connection_Form_Database_Validation_Query': 'SQL验证查询', 'Dec-Dcm_Connection_Form_Database_Test_On_Borrow': '获取连接前检验', 'Dec-Dcm_Connection_Form_Database_Test_On_Return': '归还连接前检验', - 'Dec-Dcm_Connection_Form_Database_Test_While_Idle': '开启空闲回收器检验', - 'Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis': '空闲连接回收器休眠时间', + 'Dec-Dcm_Connection_Form_Database_Test_While_Idle': '获取连接时空闲连接可用性校验', + 'Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis': '空闲连接回收器工作间隔', 'Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num': '空闲连接回收检查数', - 'Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis': '保持空闲最小时间值', + 'Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis': '空闲连接回收时间阈值', 'Dec-Dcm_Connection_Make_Sure_Delete': '确定删除该数据连接?', 'Dec-Dcm_Connection_ReConnect': '重新连接', 'Dec-Dcm_Connection_JNDI_Form_ConnectionName': 'JNDI的名字', @@ -100,7 +100,7 @@ export default { 'Dec-Dcm_Connection_JNDI_Warning': '注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下', 'Dec-Dcm_Connection_Error': '接口访问错误', 'Dec-Dcm_Connection_Is_Using': '该连接正在被{R1}编辑,请稍后再试', - 'Dec-Dcm_Connection_Check_Integer': '请输入不小于0的整数', + 'Dec-Dcm_Connection_Check_Integer': '请输入不小于{}的整数', 'Dec-Dcm_Connection_Check_Number': '只允许为整数', 'Dec-Dcm_Connection_JDBC_Other': '其他JDBC', 'Dec-Dcm_Connection_JDBC_Warning': '请确认已经将krb5.Conf文件添加到/webapps/webroot/WEB_INF/resources目录', diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index d38fdc5..b236bb2 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -1,4 +1,10 @@ -import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER, DESIGN_DRIVER_TYPE, OTHER_JDBC } from '@constants/constant'; +import { + DATA_BASE_TYPES, + DATA_BASE_TYPES_OTHER, + DESIGN_DRIVER_TYPE, + OTHER_JDBC, + DATABASE_TYPE, +} from '@constants/constant'; import { DatabaseType } from './app.typings'; import { Connection } from './crud/crud.typings'; export function getAllDatabaseTypes(): DatabaseType[] { @@ -75,7 +81,7 @@ export function splitUrl(host: string, port: string, catalog: string, database: .replace(':INFORMIXSERVER={server}', ''); } - if (databaseType === 'starrocks') { + if (databaseType === DATABASE_TYPE.STAR_ROCKS) { let databaseStr = ''; if (!catalog || !database) { databaseStr = catalog + database; @@ -86,6 +92,12 @@ export function splitUrl(host: string, port: string, catalog: string, database: .replace('default_catalog.database', databaseStr); } + if (databaseType === DATABASE_TYPE.SAP_HANA) { + return baseUrl.replace('hostname', host) + .replace('port', port || '') + .replace('=database', `=${database}`); + } + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') .replace('/database', `/${database}`) .replace(':database', `:${database}`) diff --git a/src/modules/app.typings.d.ts b/src/modules/app.typings.d.ts index c0c9320..3eda6f3 100644 --- a/src/modules/app.typings.d.ts +++ b/src/modules/app.typings.d.ts @@ -11,6 +11,10 @@ export interface DatabaseType { hasSchemas?: { [key: string]: boolean; }; + fetchSize: number; + versionConfig?: { + [key: string]: DatabaseType; + }, kerberos?: boolean; iconUrl?: string; versions?: string[]; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 2e12817..e36e16a 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -5,6 +5,11 @@ export const PAGE_INDEX = { POOL: 'pool', }; +export const DATABASE_TYPE = { + SAP_HANA: "sap-hana", + STAR_ROCKS :'starrocks', +}; + export const OTHER_JDBC = 'otherJDBC'; export const DEFAULT_HELP_LINK = 'databaseHelpLink'; @@ -609,7 +614,7 @@ export const DATA_BASE_TYPES = [ text: 'SAP HANA', databaseType: 'sap-hana', driver: 'com.sap.db.jdbc.Driver', - url: 'jdbc:sap://hostname:port?reconnect=true', + url: 'jdbc:sap://hostname:port?databaseName=database&reconnect=true', commonly: false, internal: true, type: 'jdbc', @@ -829,11 +834,14 @@ export const DEFAULT_JDBC_POOL = { minIdle: 0, maxWait: 10000, testOnBorrow: true, + keepAlive: true, testOnReturn: false, testWhileIdle: false, timeBetweenEvictionRunsMillis: 60000, numTestsPerEvictionRun: 3, minEvictableIdleTimeMillis: 1800, + maxEvictableIdleTimeMillis: 25200, + keepAliveBetweenTimeMillis: 120000, }; export const CONNECTION_LAYOUT = { diff --git a/src/modules/crud/crud.typings.d.ts b/src/modules/crud/crud.typings.d.ts index 8a5c8b9..8bc01bd 100644 --- a/src/modules/crud/crud.typings.d.ts +++ b/src/modules/crud/crud.typings.d.ts @@ -87,6 +87,10 @@ export interface ConnectionPoolJDBC { */ testOnBorrow?: boolean; + /** + * 空闲连接可用性定期检查 + */ + keepAlive?: boolean; /** * 归还前校验 */ @@ -108,6 +112,14 @@ export interface ConnectionPoolJDBC { * 连接在池中保持空闲而不被空闲连接回收器回收的最小时间,单位毫秒 */ minEvictableIdleTimeMillis?: number; + /** + * 连接在池中保持空闲而不被空闲连接回收器回收的最小时间,单位毫秒 + */ + maxEvictableIdleTimeMillis?: number; + /** + * 空闲连接可用性定期检查时间阈值 + */ + keepAliveBetweenTimeMillis?: number; } export type ConnectionJDBC = { diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 6b1094c..f06dcc5 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -24,24 +24,13 @@ export class Connection extends BI.Widget { title: HTapeLayout; watch = { - connectionSelected: (name: string) => { - if (name) { - const canEdit = connectionCanEdit(this.model.connectionSelectedOne); - const type = this.getSelectConnectionType(); - this.connectionTitleWidget.setText(`${name}(${getTextByDatabaseType(type)})`); - this.connectionEditWidget.setVisible(canEdit); - const hasRegistered = this.hasRegistered(); - this.title.setVisible(hasRegistered); - if (!hasRegistered) { - this.listView.populate(BI.createItems(this.renderNoRegistered())); - } else { - this.listView.populate(BI.createItems(this.renderItems())); - } - } else { - this.listView.populate(BI.createItems(this.renderEmpty())); - this.connectionTitleWidget.setText(''); - this.connectionEditWidget.setVisible(false); - } + connectionSelected: { + immediate: true, + handler: (name: string) => { + BI.nextTick(() => { + name ? this.renderConnectionListView(name) : this.renderEmptyListView(); + }); + }, }, }; @@ -50,8 +39,6 @@ export class Connection extends BI.Widget { } render() { - this.store.setConnectionSelected(''); - return { type: BI.HTapeLayout.xtype, hgap: 10, @@ -214,12 +201,6 @@ export class Connection extends BI.Widget { }]; } - private renderEmpty() { - return [{ - type: BI.Layout.xtype, - }]; - } - private hasRegistered() { const allDatabaseTypes = getAllDatabaseTypes(); switch (this.model.connectionSelectedOne.connectionType) { @@ -246,4 +227,32 @@ export class Connection extends BI.Widget { this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setDatebaseTypeSelected(''); } + + private renderConnectionListView(name: string) { + const canEdit = connectionCanEdit(this.model.connectionSelectedOne), + type = this.getSelectConnectionType(), + hasRegistered = this.hasRegistered(); + + this.connectionTitleWidget.setText(`${name}(${getTextByDatabaseType(type)})`); + this.connectionEditWidget.setVisible(canEdit); + + this.title.setVisible(hasRegistered); + + hasRegistered + ? this.listView.populate(BI.createItems(this.renderItems())) + : this.listView.populate(BI.createItems(this.renderNoRegistered())); + } + + private renderEmptyListView() { + this.listView.populate( + BI.createItems([ + { + type: BI.Layout.xtype, + } + ]) + ); + + this.connectionTitleWidget.setText(''); + this.connectionEditWidget.setVisible(false); + } } diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 09990ec..893e960 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -197,6 +197,11 @@ export class ConnectionJdbc extends BI.Widget { 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_Regular_Check_On_Borrow'), + value: connectionPoolAttr.keepAlive ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), + }, { type: FormItem.xtype, name: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'), @@ -374,6 +379,18 @@ export class ConnectionJdbc extends BI.Widget { value: connectionPoolAttr.minEvictableIdleTimeMillis, unit: BI.i18nText('BI-Basic_Seconds'), }, + { + type: FormItem.xtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Evictable_Idle_Time_Millis'), + value: connectionPoolAttr.maxEvictableIdleTimeMillis, + unit: BI.i18nText('BI-Basic_Seconds'), + }, + { + type: FormItem.xtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow_Threshold'), + value: connectionPoolAttr.keepAliveBetweenTimeMillis, + unit: BI.i18nText('Dec-Dcm_Millisecond'), + }, { type: FormItem.xtype, name: 'Fetchsize', diff --git a/src/modules/pages/connection/list/list.model.ts b/src/modules/pages/connection/list/list.model.ts index f00396a..3d30378 100644 --- a/src/modules/pages/connection/list/list.model.ts +++ b/src/modules/pages/connection/list/list.model.ts @@ -1,10 +1,11 @@ import { model, Model } from '@core/core'; import { ApiFactory } from '../../..//crud/apiFactory'; import { AppModel } from '../../../app.model'; +import type { ConnectionJDBC } from '../../../crud/crud.typings'; const api = new ApiFactory().create(); @model() export class ConnectionListModel extends Model<{ - types : { + types: { connections: AppModel['TYPE']['connections']; connectionSelected: AppModel['TYPE']['connectionSelected']; }, @@ -19,22 +20,40 @@ export class ConnectionListModel extends Model<{ } actions = { - setConnections: ():Promise => api.getConnectionList().then(data => { + setConnections: (): Promise => api.getConnectionList().then(data => { data.data.push(...BI.Constants.getConstant('dec.constant.connection.list')); if (BI.size(data.data) > 0) { this.model.connections = data.data; + let defaultDatabaseName, + defaultDatabaseId = BI.Services.getService("dec.service.global") + .getHashSearchParams("databaseId"); + this.model.connections.forEach(item => { - // 后端传过来的是字符串,转为对象 + // REPORT-111534 有些环境存在脏数据,补下容错 + if (BI.isNull(item.connectionData)) return; + + // 后端传过来的是字符串,转为对象 BI.isString(item.connectionData) && (item.connectionData = JSON.parse(item.connectionData as string)); + + // 目前只有jdbc存在identity,后期拓展 + if ((item.connectionData as ConnectionJDBC).identity === defaultDatabaseId) { + defaultDatabaseName = item.connectionName; + } }); - this.model.connectionSelected = data.data[0].connectionName; - } else { - this.model.connectionSelected = ''; + + // 仅首次进入时从url中读取参数,其他情况保留选中状态 + defaultDatabaseName ||= data.data[0].connectionName; + + this.setSelectedConnection(this.model.connectionSelected || defaultDatabaseName); } return new Promise(resolve => { resolve(); }); }), + + setSelectedConnection(name: string) { + this.model.connectionSelected = name; + } } } diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index f23de66..fa43a36 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/src/modules/pages/connection/list/list_item/list_item.model.ts @@ -139,8 +139,9 @@ export class ListItemModel extends Model<{ // 后端传过来的是字符串,转为对象 item.connectionData = JSON.parse(item.connectionData as string); }); + if (name === this.model.connectionSelected) { - this.model.connectionSelected = BI.size(this.model.connections) > 0 ? this.model.connections[0].connectionName : ''; + this.setConnectionSelected(this.model.connections?.[0]?.connectionName || ''); } api.shutdownConnectionStatus(name); }); diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 6a9c097..430a7aa 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -86,12 +86,15 @@ export class FormJdbc extends BI.Widget { // more validationQuery: null, testOnBorrow: null, + keepAlive: null, testOnReturn: null, testWhileIdle: null, timeBetweenEvictionRunsMillis: null, numTestsPerEvictionRun: null, minIdle: null, minEvictableIdleTimeMillis: null, + maxEvictableIdleTimeMillis: null, + keepAliveBetweenTimeMillis: null, fetchSize: null, // 并行装载 parallelLoad: { @@ -152,12 +155,15 @@ export class FormJdbc extends BI.Widget { maxWait, validationQuery, testOnBorrow, + keepAlive, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minIdle, minEvictableIdleTimeMillis, + maxEvictableIdleTimeMillis, + keepAliveBetweenTimeMillis, } = connectionPoolAttr as ConnectionPoolJDBC; const databaseType = getJdbcDatabaseType(database, driver); this.databaseType = databaseType; @@ -222,6 +228,7 @@ export class FormJdbc extends BI.Widget { this.sslCollapse.setCollapse(true); this.sslCollapse.setVisible(this.getSslSetEnabled()); !BI.isUndefined(databaseType.hasSchemas) && this.schemaForm.setVisible(databaseType.hasSchemas[version]); + !BI.isUndefined(databaseType.versionConfig?.[version]?.fetchSize) && this.form.fetchSize.setValue(databaseType.versionConfig[version].fetchSize); this.form.driver.setDefaultDrivers(version); }, }, @@ -356,7 +363,7 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -894,7 +901,7 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -925,6 +932,25 @@ export class FormJdbc extends BI.Widget { }, ], }, + // 空闲连接可用性定期检查 + { + type: FormItem.xtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow'), + forms: [ + { + type: BI.TextValueCombo.xtype, + $value: 'keep-alive-check', + width: EDITOR_WIDTH, + allowBlank: true, + value: keepAlive, + items: this.getBooleanItem(), + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow'), + ref: (_ref: TextValueCombo) => { + this.form.keepAlive = _ref; + }, + }, + ], + }, // 校验语句 { type: FormItem.xtype, @@ -959,7 +985,7 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -1068,7 +1094,7 @@ export class FormJdbc extends BI.Widget { allowBlank: false, validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -1331,7 +1357,7 @@ export class FormJdbc extends BI.Widget { value: initialSize, validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -1357,7 +1383,7 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -1422,6 +1448,11 @@ export class FormJdbc extends BI.Widget { checker: (value: string) => this.checkNumber(value), autoFix: true, }, + { + errorText: BI.i18nText('Dec-Util-Must_Less_Than', BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow_Threshold')), + checker: (value: string) => this.checkNumber(value) && (parseInt(value) < parseInt(this.form.keepAliveBetweenTimeMillis.getValue())), + autoFix: true, + }, valueRangeConfig, ], ref: (_ref: TextChecker) => { @@ -1449,7 +1480,7 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), checker: (value: string) => this.checkInteger(value), autoFix: true, }, @@ -1474,8 +1505,13 @@ export class FormJdbc extends BI.Widget { watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), validationChecker: [ { - errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), - checker: (value: string) => this.checkInteger(value), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 30), + checker: (value: string) => this.checkNumber(value) && (parseInt(value) >= 30), + autoFix: true, + }, + { + errorText: BI.i18nText('Dec-Util-Must_Less_Than', BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Evictable_Idle_Time_Millis')), + checker: (value: string) => parseInt(value) < parseInt(this.form.maxEvictableIdleTimeMillis.getValue()), autoFix: true, }, valueRangeConfig, @@ -1492,6 +1528,80 @@ export class FormJdbc extends BI.Widget { }, ], }, + + { + type: FormItem.xtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Evictable_Idle_Time_Millis'), + forms: [ + { + type: TextChecker.xtype, + $value: 'max-evictable-idle-time-millis', + width: EDITOR_WIDTH, + allowBlank: false, + value: maxEvictableIdleTimeMillis, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Evictable_Idle_Time_Millis'), + validationChecker: [ + { + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 0), + checker: (value: string) => this.checkInteger(value), + autoFix: true, + }, + { + errorText: BI.i18nText('Dec-Util-Must_More_Than', BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Evictable_Idle_Time_Millis'), BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis')), + checker: (value: string) => parseInt(value) > parseInt(this.form.minEvictableIdleTimeMillis.getValue()), + autoFix: true, + }, + valueRangeConfig, + ], + ref: (_ref: TextChecker) => { + this.form.maxEvictableIdleTimeMillis = _ref; + }, + }, + { + type: BI.Label.xtype, + lgap: 5, + height: CONNECTION_LAYOUT.labelHeight, + text: BI.i18nText('BI-Basic_Seconds'), + }, + ], + }, + + { + type: FormItem.xtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow_Threshold'), + forms: [ + { + type: TextChecker.xtype, + $value: 'keep-live-between-time-millis', + width: EDITOR_WIDTH, + allowBlank: false, + value: keepAliveBetweenTimeMillis, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow_Threshold'), + validationChecker: [ + { + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer', 30000), + checker: (value: string) => this.checkNumber(value) && (parseInt(value) > 30000), + autoFix: true, + }, + { + errorText: BI.i18nText('Dec-Util-Must_More_Than', BI.i18nText('Dec-Dcm_Connection_Form_Database_Regular_Check_On_Borrow_Threshold'), BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis')), + checker: (value: string) => this.checkNumber(value) && (parseInt(value) > parseInt(this.form.timeBetweenEvictionRunsMillis.getValue())), + autoFix: true, + }, + valueRangeConfig, + ], + ref: (_ref: TextChecker) => { + this.form.keepAliveBetweenTimeMillis = _ref; + }, + }, + { + type: BI.Label.xtype, + lgap: 5, + height: CONNECTION_LAYOUT.labelHeight, + text: BI.i18nText('Dec-Dcm_Millisecond'), + }, + ], + }, { el: { type: BI.VerticalLayout.xtype, @@ -1740,11 +1850,14 @@ export class FormJdbc extends BI.Widget { maxWait: this.form.maxWait.getValue(), validationQuery: api.getCipher(this.form.validationQuery.getValue()), testOnBorrow: BI.size(this.form.testOnBorrow.getValue()) > 0 ? this.form.testOnBorrow.getValue()[0] : connectionPoolAttr.testOnBorrow, + keepAlive: BI.size(this.form.keepAlive.getValue()) > 0 ? this.form.keepAlive.getValue()[0] : connectionPoolAttr.keepAlive, testOnReturn: BI.size(this.form.testOnReturn.getValue()) > 0 ? this.form.testOnReturn.getValue()[0] : connectionPoolAttr.testOnReturn, testWhileIdle: BI.size(this.form.testWhileIdle.getValue()) > 0 ? this.form.testWhileIdle.getValue()[0] : connectionPoolAttr.testWhileIdle, timeBetweenEvictionRunsMillis: this.form.timeBetweenEvictionRunsMillis.getValue(), numTestsPerEvictionRun: this.form.numTestsPerEvictionRun.getValue(), minEvictableIdleTimeMillis: this.form.minEvictableIdleTimeMillis.getValue(), + maxEvictableIdleTimeMillis: this.form.maxEvictableIdleTimeMillis.getValue(), + keepAliveBetweenTimeMillis: this.form.keepAliveBetweenTimeMillis.getValue(), }, // 并行装载 parallelLoad: { diff --git a/src/modules/pages/maintain/forms/form.model.ts b/src/modules/pages/maintain/forms/form.model.ts index 3bbc66e..7947b15 100644 --- a/src/modules/pages/maintain/forms/form.model.ts +++ b/src/modules/pages/maintain/forms/form.model.ts @@ -17,6 +17,7 @@ export class MaintainFormModel extends Model<{ pageIndex: AppModel['TYPE']['pageIndex']; connections: AppModel['TYPE']['connections']; isCopy: AppModel['TYPE']['isCopy']; + connectionSelected: AppModel['TYPE']['connectionSelected']; }, context: MaintainFormModel['context']; }> { @@ -31,6 +32,7 @@ export class MaintainFormModel extends Model<{ 'testEvent', 'connections', 'isCopy', + 'connectionSelected', ]; actions = { @@ -51,5 +53,8 @@ export class MaintainFormModel extends Model<{ goFirstPage() { this.model.pageIndex = PAGE_INDEX.CONNECTION; }, + setConnectionSelected(name: string) { + this.model.connectionSelected = name; + } } } diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index c989f1c..2e6248b 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -295,6 +295,8 @@ export class MaintainForm extends BI.Widget { return; } + // 新增之后connections待更新,connectionSelected先置空 + this.store.setConnectionSelected(''); this.store.goFirstPage(); this.store.setIsCopy(false); });