From 35a4a78e8237738de976b8c7c2288c462751a88c Mon Sep 17 00:00:00 2001 From: langwenda Date: Tue, 18 Feb 2020 15:34:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20DEC-11221=20=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=AF=B9=E5=8F=AF=E8=BE=93=E5=85=A5=E6=95=B0=E5=80=BC=E7=9A=84?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/zh_cn.properties | 3 +- private/i18n.ts | 1 + src/modules/constants/constant.ts | 2 ++ .../maintain/forms/components/form.jdbc.ts | 30 ++++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 33db53d..2010d77 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -301,4 +301,5 @@ BI-Basic_Billion= 亿 BI-Basic_Quarter= 季度 BI-Basic_No_Select= 不选 BI-Basic_Now= 此刻 -Dec-Dcm_Connection_Analytic_DB=阿里云AnalyticDB \ No newline at end of file +Dec-Dcm_Connection_Analytic_DB=阿里云AnalyticDB +Dec-Dcm_Connection_Value_Out_Range=数值超出范围 \ No newline at end of file diff --git a/private/i18n.ts b/private/i18n.ts index 97b308f..369845f 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -301,4 +301,5 @@ export default { 'BI-Basic_No_Select': '不选', 'BI-Basic_Now': '此刻', 'Dec-Dcm_Connection_Analytic_DB': '阿里云AnalyticDB', + 'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围', }; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 445b57d..d9ad8f7 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -707,3 +707,5 @@ export const JNDI_FACTORYS = [ ]; export const PAGE_SIZE = 50; +export const INT_MAX_VALUE = 2147483647; +export const INT_MIN_VALUE = -2147483648; diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 7badcea..2b45df6 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -4,7 +4,7 @@ import { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/col import { FormItemXtype } from '../../components/form_item/form_item'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; import { connectionType } from '@constants/env'; -import { CONNECT_CHARSET, CONNECTION_LAYOUT } from '@constants/constant'; +import { CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE } from '@constants/constant'; import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service'; import { TextCheckerXtype } from '../../../../components/text_checker/text_checker'; export const FormJdbcXtype = 'dec.dcm.maintain.form.jdbc'; @@ -62,6 +62,12 @@ export class FormJdbc extends BI.Widget { const { host, port, databaseName } = resolveUrlInfo(url); const { hgap, vgap } = CONNECTION_LAYOUT; + const valueRangeConfig = { + errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'), + checker: (value: string) => this.checkValueRange(value), + autoFix: true, + }; + return { type: Vertical, hgap, @@ -161,7 +167,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.port = _ref; }, @@ -408,7 +414,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'), ref: (_ref: any) => { this.form.initialSize = _ref; @@ -428,7 +434,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.maxActive = _ref; }, @@ -447,7 +453,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.maxIdle = _ref; }, @@ -466,7 +472,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.minIdle = _ref; }, @@ -486,7 +492,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.maxWait = _ref; }, @@ -574,7 +580,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Number'), checker: (value: string) => this.checkNumber(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.timeBetweenEvictionRunsMillis = _ref; }, @@ -600,7 +606,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.numTestsPerEvictionRun = _ref; }, @@ -620,7 +626,7 @@ export class FormJdbc extends BI.Widget { errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), checker: (value: string) => this.checkInteger(value), autoFix: true, - }], + }, valueRangeConfig], ref: (_ref: any) => { this.form.minEvictableIdleTimeMillis = _ref; }, @@ -651,6 +657,10 @@ export class FormJdbc extends BI.Widget { return /^[(\-|\+)?\d]+$/.test(value); } + private checkValueRange(value: string) { + return Number(value) <= INT_MAX_VALUE && Number(value) >= INT_MIN_VALUE; + } + private getDrivers() { const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); From cfd715825a37d502c11e58f61b38f8bd961bbffd Mon Sep 17 00:00:00 2001 From: langwenda Date: Tue, 18 Feb 2020 15:46:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=94=B1=E4=BA=8E=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E7=8E=87=E7=9A=84=E5=85=B3=E7=B3=BB=EF=BC=8CNumber=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=94=B9=E6=88=90parseInt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/components/form.jdbc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index d8a0a37..3af4cf6 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -658,7 +658,7 @@ export class FormJdbc extends BI.Widget { } private checkValueRange(value: string) { - return Number(value) <= INT_MAX_VALUE && Number(value) >= INT_MIN_VALUE; + return parseInt(value, 0) <= INT_MAX_VALUE && parseInt(value, 0) >= INT_MIN_VALUE; } private getDrivers() {