diff --git a/.eslintrc b/.eslintrc index 8016d83..0a25792 100644 --- a/.eslintrc +++ b/.eslintrc @@ -83,7 +83,7 @@ "template-curly-spacing": ["error", "never"], // 强制模板字符串中花括号内不能出现空格 "no-path-concat": "error", // 当使用 _dirname 和 _filename 时不允许字符串拼接 "no-useless-concat": "error", // 禁止没有必要的字符拼接 - "no-useless-escape": "error", // 禁用不必要的转义 + "no-useless-escape": "off", // 禁用不必要的转义 // 函数 "no-dupe-args": "error", // 禁止在 function 定义中出现重复的参数 // "no-new-func": "error", // 禁用Function构造函数 diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 4978f39..01bbc92 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -95,6 +95,8 @@ 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= 只允许为正整数 +Dec-Dcm_Connection_Check_Number= 只允许为数字 BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Month_Begin= 月初 diff --git a/private/i18n.ts b/private/i18n.ts index 6e2f4b3..ffd9a11 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -93,6 +93,9 @@ export default { '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': '只允许为正整数', + 'Dec-Dcm_Connection_Check_Number': '只允许为数字', 'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_YMD': '年月日', diff --git a/src/modules/app.typings.d.ts b/src/modules/app.typings.d.ts index 2e1513f..2d48bd8 100644 --- a/src/modules/app.typings.d.ts +++ b/src/modules/app.typings.d.ts @@ -9,4 +9,5 @@ export interface DatabaseType { type: string; hasSchema?: boolean; kerberos?: boolean; + iconUrl?: string; } diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index c4122e5..db19616 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -387,6 +387,18 @@ export const DATA_BASE_TYPES = [ hasSchema: false, kerberos: false, }, + { + text: BI.i18nText('Dec-Dcm_Other'), + databaseType: 'other', + driver: 'org.ha.Driver', + drivers: ['org.ha.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'], + url: 'jdbc:h2://hostname:port/../databaseName', + commonly: false, + internal: false, + type: 'jdbc', + hasSchema: false, + kerberos: false, + }, ...BI.Constants.getConstant(CONSTANT_PLUGIN_TYPES).map(item => { return { ...item, diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 0bfcb73..91c2de3 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -16,7 +16,7 @@ export class ConnectionJdbc extends BI.Widget { render () { const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; - const { driver, database, host, user, newCharsetName, schema, connectionPool, port, authType, principal, keyPath } = connectionData; + const { driver, database, host, user, newCharsetName, schema, connectionPool, port, authType, principal, keyPath, url } = connectionData; const databaseType = getJdbcDatabaseType(database, driver); return { @@ -54,6 +54,11 @@ export class ConnectionJdbc extends BI.Widget { name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'), value: authType ? keyPath : '******', }, + { + type: FormItemXtype, + name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'), + value: url, + }, { type: FormItemXtype, name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), diff --git a/src/modules/pages/connection/list/list.service.ts b/src/modules/pages/connection/list/list.service.ts index de29806..aa8d490 100644 --- a/src/modules/pages/connection/list/list.service.ts +++ b/src/modules/pages/connection/list/list.service.ts @@ -4,6 +4,9 @@ import { getAllDatabaseTypes, getJdbcDatabaseType } from 'src/modules/app.servic import { DATA_BASE_TYPES_OTHER } from '@constants/constant'; export function getCreator(connection: Connection) { + if (!connection.connectionData) { + return ''; + } switch (connection.connectionType) { case connectionType.JDBC: return (connection.connectionData as ConnectionJDBC).creator; diff --git a/src/modules/pages/database/database.ts b/src/modules/pages/database/database.ts index a8fb786..8202c99 100644 --- a/src/modules/pages/database/database.ts +++ b/src/modules/pages/database/database.ts @@ -216,6 +216,7 @@ export class Datebase extends BI.Widget { value: item.databaseType, keyword: this.model.search, databaseType: item.databaseType, + iconUrl: item.iconUrl, }; }); } diff --git a/src/modules/pages/database/database_type/database_type.ts b/src/modules/pages/database/database_type/database_type.ts index 309cdd3..d528c05 100644 --- a/src/modules/pages/database/database_type/database_type.ts +++ b/src/modules/pages/database/database_type/database_type.ts @@ -16,13 +16,14 @@ export class DatebaseType extends BI.BasicButton { width: 130, keyword: '', databaseType: '', + iconUrl: '', baseCls: 'dec-dcm-datebase-type', } store: DatebaseTypeModel['store']; render() { - const { text, keyword, databaseType } = this.options; + const { text, keyword, databaseType, iconUrl } = this.options; return { type: Absolute, @@ -35,7 +36,7 @@ export class DatebaseType extends BI.BasicButton { { el: { type: Img, - src: `${ImgPrefix}${databaseType}.jpg`, + src: iconUrl ? iconUrl : `${ImgPrefix}${databaseType}.jpg`, }, height: 90, }, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 9ab16e5..57a8347 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -1,5 +1,5 @@ import { shortcut } from '@core/core'; -import { Vertical, TextEditor, TextValueCombo, Label, TextAreaEditor, Editor } from 'ui'; +import { Vertical, TextEditor, TextValueCombo, Label, TextAreaEditor, Editor, SingleSelectInsertCombo } from 'ui'; import { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; import { FormItemXtype } from '../../components/form_item/form_item'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; @@ -70,7 +70,6 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextEditor, width: 300, - allowBlank: true, value: connectionName, ref: (_ref: any) => { this.form.connectionName = _ref; @@ -82,13 +81,27 @@ export class FormJdbc extends BI.Widget { type: FormItemXtype, name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), forms: [{ - type: TextValueCombo, + type: SingleSelectInsertCombo, width: 300, value: driver, ref: (_ref: any) => { this.form.driver = _ref; }, - items: this.getDrivers(), + itemsCreator: (options: { + keywords?: string[], + selectedValues: string[], + times: number, + type: number, + }, callback: Function) => { + let drivers = this.getDrivers(); + if (options.selectedValues.length > 0) { + drivers = drivers.filter(item => item.text !== options.selectedValues[0]); + } + callback({ + items: drivers, + hasNext: false, + }); + }, }], }, { @@ -327,6 +340,8 @@ export class FormJdbc extends BI.Widget { width: 300, allowBlank: true, value: initialSize, + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'), ref: (_ref: any) => { this.form.initialSize = _ref; @@ -342,6 +357,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: maxActive, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), ref: (_ref: any) => { this.form.maxActive = _ref; }, @@ -356,6 +373,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: maxIdle, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), ref: (_ref: any) => { this.form.maxIdle = _ref; }, @@ -371,6 +390,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: maxWait, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), ref: (_ref: any) => { this.form.maxWait = _ref; }, @@ -453,6 +474,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: timeBetweenEvictionRunsMillis, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Number'), + validationChecker: (value: string) => this.checkNumber(value), ref: (_ref: any) => { this.form.timeBetweenEvictionRunsMillis = _ref; }, @@ -473,6 +496,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: numTestsPerEvictionRun, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), ref: (_ref: any) => { this.form.numTestsPerEvictionRun = _ref; }, @@ -488,6 +513,8 @@ export class FormJdbc extends BI.Widget { allowBlank: true, value: minEvictableIdleTimeMillis, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), + errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), + validationChecker: (value: string) => this.checkInteger(value), ref: (_ref: any) => { this.form.minEvictableIdleTimeMillis = _ref; }, @@ -505,6 +532,14 @@ export class FormJdbc extends BI.Widget { }; } + private checkInteger(value: string) { + return /^[\d]+$/.test(value); + } + + private checkNumber(value: string) { + return /^[(\-|\+)?\d]+$/.test(value); + } + private getDrivers() { const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); diff --git a/src/modules/pages/maintain/forms/components/form.jndi.ts b/src/modules/pages/maintain/forms/components/form.jndi.ts index eb9d822..e76a278 100644 --- a/src/modules/pages/maintain/forms/components/form.jndi.ts +++ b/src/modules/pages/maintain/forms/components/form.jndi.ts @@ -50,7 +50,6 @@ export class FormJndi extends BI.Widget { forms: [{ type: TextEditor, width: 300, - allowBlank: true, value: connectionName, ref: (_ref: any) => { this.form.connectionName = _ref; diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index a61a5a5..a25b9d3 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/src/modules/pages/maintain/forms/components/form.plugin.ts @@ -23,12 +23,12 @@ export class FormPlugin extends BI.Widget { } public getSubmitValue(): Connection { - const { connectionType } = this.options.formData; + const { connectionType, connectionId, connectionName } = this.options.formData; return { - connectionId: '1', + connectionId, connectionType, - connectionName: '1', + connectionName, connectionData: this.plugin.getSubmitValue(), }; } diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 703b5cc..eebbbf6 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -193,6 +193,16 @@ export class MaintainForm extends BI.Widget { return false; } + if (this.connectionName !== value.connectionName) { + const hasNamed = this.model.connections.some(item => item.connectionName === value.connectionName); + if (hasNamed) { + BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Existence'), { + level: 'error', + }); + + return false; + } + } return true; }