Browse Source

Merge pull request #17 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:feature/10.0 to feature/10.0

* commit 'e12736738d5006a96041935cc92c062ab2bb30b0':
  feat: DEC-9068 加入表单验证,添加other类型数据连接
qufenxi
alan 5 years ago
parent
commit
cafa43aeaf
  1. 2
      .eslintrc
  2. 2
      i18n/zh_cn.properties
  3. 3
      private/i18n.ts
  4. 1
      src/modules/app.typings.d.ts
  5. 12
      src/modules/constants/constant.ts
  6. 7
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  7. 3
      src/modules/pages/connection/list/list.service.ts
  8. 1
      src/modules/pages/database/database.ts
  9. 5
      src/modules/pages/database/database_type/database_type.ts
  10. 43
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  11. 1
      src/modules/pages/maintain/forms/components/form.jndi.ts
  12. 6
      src/modules/pages/maintain/forms/components/form.plugin.ts
  13. 10
      src/modules/pages/maintain/forms/form.ts

2
.eslintrc

@ -83,7 +83,7 @@
"template-curly-spacing": ["error", "never"], // 强制模板字符串中花括号内不能出现空格 "template-curly-spacing": ["error", "never"], // 强制模板字符串中花括号内不能出现空格
"no-path-concat": "error", // 当使用 _dirname 和 _filename 时不允许字符串拼接 "no-path-concat": "error", // 当使用 _dirname 和 _filename 时不允许字符串拼接
"no-useless-concat": "error", // 禁止没有必要的字符拼接 "no-useless-concat": "error", // 禁止没有必要的字符拼接
"no-useless-escape": "error", // 禁用不必要的转义 "no-useless-escape": "off", // 禁用不必要的转义
// 函数 // 函数
"no-dupe-args": "error", // 禁止在 function 定义中出现重复的参数 "no-dupe-args": "error", // 禁止在 function 定义中出现重复的参数
// "no-new-func": "error", // 禁用Function构造函数 // "no-new-func": "error", // 禁用Function构造函数

2
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_JNDI_Warning= 注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下
Dec-Dcm_Connection_Error= 接口访问错误 Dec-Dcm_Connection_Error= 接口访问错误
Dec-Dcm_Connection_Is_Using= 该连接正在被{R1}编辑,请稍后再试 Dec-Dcm_Connection_Is_Using= 该连接正在被{R1}编辑,请稍后再试
Dec-Dcm_Connection_Check_Integer= 只允许为正整数
Dec-Dcm_Connection_Check_Number= 只允许为数字
BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Quarter_End= 季度末
BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_Month_Begin= 月初

3
private/i18n.ts

@ -93,6 +93,9 @@ export default {
'Dec-Dcm_Connection_JNDI': 'JNDI数据连接', 'Dec-Dcm_Connection_JNDI': 'JNDI数据连接',
'Dec-Dcm_Connection_JNDI_Warning': '注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下', 'Dec-Dcm_Connection_JNDI_Warning': '注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下',
'Dec-Dcm_Connection_Error': '接口访问错误', '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_Quarter_End': '季度末',
'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_Month_Begin': '月初',
'BI-Multi_Date_YMD': '年月日', 'BI-Multi_Date_YMD': '年月日',

1
src/modules/app.typings.d.ts vendored

@ -9,4 +9,5 @@ export interface DatabaseType {
type: string; type: string;
hasSchema?: boolean; hasSchema?: boolean;
kerberos?: boolean; kerberos?: boolean;
iconUrl?: string;
} }

12
src/modules/constants/constant.ts

@ -387,6 +387,18 @@ export const DATA_BASE_TYPES = [
hasSchema: false, hasSchema: false,
kerberos: 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 => { ...BI.Constants.getConstant(CONSTANT_PLUGIN_TYPES).map(item => {
return { return {
...item, ...item,

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

@ -16,7 +16,7 @@ export class ConnectionJdbc extends BI.Widget {
render () { render () {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; 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); const databaseType = getJdbcDatabaseType(database, driver);
return { 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'), name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'),
value: authType ? keyPath : '******', value: authType ? keyPath : '******',
}, },
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'),
value: url,
},
{ {
type: FormItemXtype, type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),

3
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'; import { DATA_BASE_TYPES_OTHER } from '@constants/constant';
export function getCreator(connection: Connection) { export function getCreator(connection: Connection) {
if (!connection.connectionData) {
return '';
}
switch (connection.connectionType) { switch (connection.connectionType) {
case connectionType.JDBC: case connectionType.JDBC:
return (connection.connectionData as ConnectionJDBC).creator; return (connection.connectionData as ConnectionJDBC).creator;

1
src/modules/pages/database/database.ts

@ -216,6 +216,7 @@ export class Datebase extends BI.Widget {
value: item.databaseType, value: item.databaseType,
keyword: this.model.search, keyword: this.model.search,
databaseType: item.databaseType, databaseType: item.databaseType,
iconUrl: item.iconUrl,
}; };
}); });
} }

5
src/modules/pages/database/database_type/database_type.ts

@ -16,13 +16,14 @@ export class DatebaseType extends BI.BasicButton {
width: 130, width: 130,
keyword: '', keyword: '',
databaseType: '', databaseType: '',
iconUrl: '',
baseCls: 'dec-dcm-datebase-type', baseCls: 'dec-dcm-datebase-type',
} }
store: DatebaseTypeModel['store']; store: DatebaseTypeModel['store'];
render() { render() {
const { text, keyword, databaseType } = this.options; const { text, keyword, databaseType, iconUrl } = this.options;
return { return {
type: Absolute, type: Absolute,
@ -35,7 +36,7 @@ export class DatebaseType extends BI.BasicButton {
{ {
el: { el: {
type: Img, type: Img,
src: `${ImgPrefix}${databaseType}.jpg`, src: iconUrl ? iconUrl : `${ImgPrefix}${databaseType}.jpg`,
}, },
height: 90, height: 90,
}, },

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

@ -1,5 +1,5 @@
import { shortcut } from '@core/core'; 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 { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import { FormItemXtype } from '../../components/form_item/form_item'; import { FormItemXtype } from '../../components/form_item/form_item';
import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings';
@ -70,7 +70,6 @@ export class FormJdbc extends BI.Widget {
forms: [{ forms: [{
type: TextEditor, type: TextEditor,
width: 300, width: 300,
allowBlank: true,
value: connectionName, value: connectionName,
ref: (_ref: any) => { ref: (_ref: any) => {
this.form.connectionName = _ref; this.form.connectionName = _ref;
@ -82,13 +81,27 @@ export class FormJdbc extends BI.Widget {
type: FormItemXtype, type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
forms: [{ forms: [{
type: TextValueCombo, type: SingleSelectInsertCombo,
width: 300, width: 300,
value: driver, value: driver,
ref: (_ref: any) => { ref: (_ref: any) => {
this.form.driver = _ref; 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, width: 300,
allowBlank: true, allowBlank: true,
value: initialSize, 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'), watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'),
ref: (_ref: any) => { ref: (_ref: any) => {
this.form.initialSize = _ref; this.form.initialSize = _ref;
@ -342,6 +357,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: maxActive, value: maxActive,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), 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) => { ref: (_ref: any) => {
this.form.maxActive = _ref; this.form.maxActive = _ref;
}, },
@ -356,6 +373,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: maxIdle, value: maxIdle,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'), 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) => { ref: (_ref: any) => {
this.form.maxIdle = _ref; this.form.maxIdle = _ref;
}, },
@ -371,6 +390,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: maxWait, value: maxWait,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), 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) => { ref: (_ref: any) => {
this.form.maxWait = _ref; this.form.maxWait = _ref;
}, },
@ -453,6 +474,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: timeBetweenEvictionRunsMillis, value: timeBetweenEvictionRunsMillis,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), 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) => { ref: (_ref: any) => {
this.form.timeBetweenEvictionRunsMillis = _ref; this.form.timeBetweenEvictionRunsMillis = _ref;
}, },
@ -473,6 +496,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: numTestsPerEvictionRun, value: numTestsPerEvictionRun,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), 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) => { ref: (_ref: any) => {
this.form.numTestsPerEvictionRun = _ref; this.form.numTestsPerEvictionRun = _ref;
}, },
@ -488,6 +513,8 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: minEvictableIdleTimeMillis, value: minEvictableIdleTimeMillis,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), 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) => { ref: (_ref: any) => {
this.form.minEvictableIdleTimeMillis = _ref; 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() { private getDrivers() {
const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);

1
src/modules/pages/maintain/forms/components/form.jndi.ts

@ -50,7 +50,6 @@ export class FormJndi extends BI.Widget {
forms: [{ forms: [{
type: TextEditor, type: TextEditor,
width: 300, width: 300,
allowBlank: true,
value: connectionName, value: connectionName,
ref: (_ref: any) => { ref: (_ref: any) => {
this.form.connectionName = _ref; this.form.connectionName = _ref;

6
src/modules/pages/maintain/forms/components/form.plugin.ts

@ -23,12 +23,12 @@ export class FormPlugin extends BI.Widget {
} }
public getSubmitValue(): Connection { public getSubmitValue(): Connection {
const { connectionType } = this.options.formData; const { connectionType, connectionId, connectionName } = this.options.formData;
return { return {
connectionId: '1', connectionId,
connectionType, connectionType,
connectionName: '1', connectionName,
connectionData: this.plugin.getSubmitValue(), connectionData: this.plugin.getSubmitValue(),
}; };
} }

10
src/modules/pages/maintain/forms/form.ts

@ -193,6 +193,16 @@ export class MaintainForm extends BI.Widget {
return false; 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; return true;
} }

Loading…
Cancel
Save