Browse Source

Merge pull request #1984 in DEC/decision-webui-dcm from release/10.0 to final/10.0

* commit '0a5f8d60de7bc62bbf53bfdce972e9a6be9e63ea':
  DEC-18427 fix: 国际化问题
  DEC-18126 fix: 【自动化】平台新增插件类型数据连接(redis/json),均无法保存
  DEC-18013 fix: 【自动化】最新redis数据集插件,新建redis数据连接,默认名称是widget7127这种带随机数
  DEC-17971 feat: 服务器数据集sql传输加密-前端
  DEC-18013 fix: 【自动化】最新redis数据集插件,新建redis数据连接,默认名称是widget7127这种带随机数
  DEC-17971 feat: 服务器数据集sql传输加密-前端
  update demo
  DEC-17991 chore: 甘老师插件接口问题反馈--数据连接支持创建时添加connectionname
final/10.0
superman 4 years ago
parent
commit
0259a6a0be
  1. 349
      README.md
  2. 9
      src/modules/crud/api.ts
  3. 24
      src/modules/crud/decision.api.ts
  4. 31
      src/modules/crud/design.api.ts
  5. 16
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  6. 21
      src/modules/pages/maintain/forms/components/form.plugin.ts
  7. 6
      src/modules/pages/maintain/forms/form.server.ts

349
README.md

@ -25,196 +25,193 @@ yarn dev
BI.config(ConstantPluginTyps, (datas: string[]) => [...datas, { BI.config(ConstantPluginTyps, (datas: string[]) => [...datas, {
text: 'Redis', text: 'Redis',
databaseType: 'Redis', databaseType: 'Redis',
edit: '',
show: '',
}]); }]);
``` ```
### 数据连接填写页面 ### 数据连接填写页面
ConstantName名称为`dec.constant.database.conf.connect.form.${name}.edit`,值为组件shortcut的名称 edit属性值为填写组件shortcut的名称
### 数据连接展示页面 ### 数据连接展示页面
ConstantName名称为`dec.constant.database.conf.connect.form.${name}.show`,值为组件shortcut的名称 show属性值为组件shortcut的名称
### 示例 ### 示例
``` ```
const ConstantRedisType = 'dec.constant.database.conf.connect.types'; const DataBaseConfigProvider = 'dec.connection.provider.datebase';
const ConstantRedisShow = 'dec.constant.database.conf.connect.form.Redis.show';
const ConstantRedisEdit = 'dec.constant.database.conf.connect.form.Redis.edit'; const RedisShowName = 'dec.dcm.connection.plugin.redis.show';
const RedisEditName = 'dec.dcm.connection.plugin.redis.edit';
BI.DOM.ready(() => { BI.config(DataBaseConfigProvider, function (provider) {
BI.config(ConstantRedisType, datas => [...datas, { provider.registerDatabaseType({
text: 'Redis', text: "Redis",
databaseType: 'Redis', databaseType: "Redis",
}]); edit: "dec.dcm.connection.plugin.demo.edit",
show: "dec.dcm.connection.plugin.demo.show",
const RedisShowName = 'dec.dcm.connection.plugin.redis.show';
const RedisShow = BI.inherit(BI.Widget, {
props: {
formData: {
url: '',
port: '6379',
password: '',
},
},
render() {
const o = this.options;
return {
type: 'bi.vertical',
hgap: 15,
vgap: 10,
items: [
{
type: 'bi.left',
items: [
{
type: 'bi.label',
cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '数据库地址',
},
{
type: 'bi.label',
text: o.formData.url,
},
],
},
{
type: 'bi.left',
items: [
{
type: 'bi.label',
cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '端口号',
},
{
type: 'bi.label',
text: o.formData.port,
},
],
},
{
type: 'bi.left',
items: [
{
type: 'bi.label',
cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '密码',
},
{
type: 'bi.label',
text: o.formData.password,
},
],
},
],
};
},
}); });
});
BI.shortcut(RedisShowName, RedisShow); const RedisShow = BI.inherit(BI.Widget, {
BI.constant(ConstantRedisShow, RedisShowName); props: {
formData: {
url: '',
const RedisEditName = 'dec.dcm.connection.plugin.redis.edit'; port: '6379',
const RedisEdit = BI.inherit(BI.Widget, { password: '',
props: {
formData: {
url: '',
port: '6379',
password: '',
},
}, },
render() { },
const o = this.options; render() {
const o = this.options;
return {
type: 'bi.vertical', return {
hgap: 15, type: 'bi.vertical',
vgap: 10, hgap: 15,
items: [ vgap: 10,
{ items: [
type: 'bi.left', {
items: [ type: 'bi.left',
{ items: [
type: 'bi.label', {
cls: 'bi-font-bold', type: 'bi.label',
width: 100, cls: 'bi-font-bold',
textAlign: 'left', width: 100,
text: '数据库地址', textAlign: 'left',
}, text: '数据库地址',
{ },
type: 'bi.text_editor', {
width: 300, type: 'bi.label',
allowBlank: true, text: o.formData.url,
ref: _ref => { },
this.url = _ref; ],
}, },
text: o.formData.url, {
}, type: 'bi.left',
], items: [
}, {
{ type: 'bi.label',
type: 'bi.left', cls: 'bi-font-bold',
items: [ width: 100,
{ textAlign: 'left',
type: 'bi.label', text: '端口号',
cls: 'bi-font-bold', },
width: 100, {
textAlign: 'left', type: 'bi.label',
text: '端口号', text: o.formData.port,
}, },
{ ],
type: 'bi.text_editor', },
width: 300, {
allowBlank: true, type: 'bi.left',
ref: _ref => { items: [
this.port = _ref; {
}, type: 'bi.label',
text: o.formData.port, cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '密码',
},
{
type: 'bi.label',
text: o.formData.password,
},
],
},
],
};
},
});
BI.shortcut(RedisShowName, RedisShow);
const RedisEdit = BI.inherit(BI.Widget, {
props: {
value: {
url: '',
port: '6379',
password: '',
},
},
render() {
const o = this.options;
return {
type: 'bi.vertical',
hgap: 15,
vgap: 10,
items: [
{
type: 'bi.left',
items: [
{
type: 'bi.label',
cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '数据库地址',
},
{
type: 'bi.text_editor',
width: 300,
allowBlank: true,
ref: _ref => {
this.url = _ref;
}, },
], text: o.value.url,
}, },
{ ],
type: 'bi.left', },
items: [ {
{ type: 'bi.left',
type: 'bi.label', items: [
cls: 'bi-font-bold', {
width: 100, type: 'bi.label',
textAlign: 'left', cls: 'bi-font-bold',
text: '密码', width: 100,
textAlign: 'left',
text: '端口号',
},
{
type: 'bi.text_editor',
width: 300,
allowBlank: true,
ref: _ref => {
this.port = _ref;
}, },
{ text: o.value.port,
type: 'bi.text_editor', },
width: 300, ],
allowBlank: true, },
inputType: 'password', {
ref: _ref => { type: 'bi.left',
this.password = _ref; items: [
}, {
text: o.formData.password, type: 'bi.label',
cls: 'bi-font-bold',
width: 100,
textAlign: 'left',
text: '密码',
},
{
type: 'bi.text_editor',
width: 300,
allowBlank: true,
inputType: 'password',
ref: _ref => {
this.password = _ref;
}, },
], text: o.value.password,
}, },
], ],
}; },
}, ],
getSubmitValue() { };
return { },
url: this.url.getValue(), getValue() {
port: this.port.getValue(), return {
password: this.password.getValue(), url: this.url.getValue(),
}; port: this.port.getValue(),
}, password: this.password.getValue(),
}); };
},
BI.shortcut(RedisEditName, RedisEdit);
BI.constant(ConstantRedisEdit, RedisEditName);
}); });
BI.shortcut(RedisEditName, RedisEdit);
``` ```

9
src/modules/crud/api.ts

@ -9,7 +9,7 @@ export interface Api {
/** /**
* *
*/ */
getConnectionlist(): Promise<{data?: Connection[]}>; getConnectionlist(): Promise<{ data?: Connection[] }>;
/** /**
* *
@ -38,7 +38,7 @@ export interface Api {
* *
* @param name * @param name
*/ */
getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}>; getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>;
/** /**
* *
@ -67,6 +67,11 @@ export interface Api {
*/ */
getCipher(password: string): string; getCipher(password: string): string;
/**
*
*/
getPlain(cipher: string): string;
/** /**
* *
*/ */

24
src/modules/crud/decision.api.ts

@ -6,7 +6,7 @@ import { editStatusEvent, errorCode } from '@constants/env';
export class DecisionApi implements Api { export class DecisionApi implements Api {
isDec = true; isDec = true;
getConnectionlist(): Promise<{data?: Connection[]}> { getConnectionlist(): Promise<{ data?: Connection[] }> {
return requestGet('list', {}); return requestGet('list', {});
} }
@ -20,31 +20,31 @@ export class DecisionApi implements Api {
const form = { const form = {
...data, ...data,
connectionId: data.connectionId || data.connectionName, connectionId: data.connectionId || data.connectionName,
connectionData : JSON.stringify(data.connectionData), connectionData: JSON.stringify(data.connectionData),
}; };
return requestPost('', form); return requestPost('', form);
} }
updateConnection(data: Connection) { updateConnection(data: Connection) {
const form = { const form = {
...data, ...data,
connectionData : JSON.stringify(data.connectionData), connectionData: JSON.stringify(data.connectionData),
}; };
return requestPut('', form); return requestPut('', form);
} }
testConnection(data: Connection): Promise<TestRequest> { testConnection(data: Connection): Promise<TestRequest> {
const form = { const form = {
...data, ...data,
connectionData : JSON.stringify(data.connectionData), connectionData: JSON.stringify(data.connectionData),
}; };
return requestPost('test', form); return requestPost('test', form);
} }
getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}> { getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }> {
return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {}); return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {});
} }
@ -81,7 +81,7 @@ export class DecisionApi implements Api {
if (Dec) { if (Dec) {
return Dec.socket.connected; return Dec.socket.connected;
} }
return false; return false;
} }
@ -89,7 +89,7 @@ export class DecisionApi implements Api {
if (Dec) { if (Dec) {
return DecCst.ErrorCode.LACK_DRIVER === errorCode; return DecCst.ErrorCode.LACK_DRIVER === errorCode;
} }
return false; return false;
} }
@ -97,6 +97,10 @@ export class DecisionApi implements Api {
return BI.Providers.getProvider('dec.provider.cipher').getCipher(password); return BI.Providers.getProvider('dec.provider.cipher').getCipher(password);
} }
getPlain(cipher: string) {
return BI.Providers.getProvider('dec.provider.cipher').getPlain(cipher);
}
getHyperlink(name: string) { getHyperlink(name: string) {
return Dec.system[DecCst.Hyperlink.DECISION_HYPERLINK_CONFIG][name]; return Dec.system[DecCst.Hyperlink.DECISION_HYPERLINK_CONFIG][name];
} }

31
src/modules/crud/design.api.ts

@ -4,26 +4,26 @@ import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './cru
export class DesignApi implements Api { export class DesignApi implements Api {
isDec = false; isDec = false;
getConnectionlist(): Promise<{data: Connection[]}> { getConnectionlist(): Promise<{ data: Connection[] }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: [] }); resolve({ data: [] });
}); });
} }
deleteConnection(connectionName: string): Promise<{data: string}> { deleteConnection(connectionName: string): Promise<{ data: string }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: 'success' }); resolve({ data: 'success' });
}); });
} }
addConnection(data: Connection): Promise<{data: string}> { addConnection(data: Connection): Promise<{ data: string }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: 'success' }); resolve({ data: 'success' });
}); });
} }
updateConnection(data: Connection): Promise<{data: string}> { updateConnection(data: Connection): Promise<{ data: string }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: 'success' }); resolve({ data: 'success' });
}); });
@ -34,14 +34,16 @@ export class DesignApi implements Api {
}); });
} }
getConnectionPool(name: string): Promise<{data: ConnectionPoolType}> { getConnectionPool(name: string): Promise<{ data: ConnectionPoolType }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: { resolve({
maxActive: 1, data: {
maxIdle: 1, maxActive: 1,
numActive: 1, maxIdle: 1,
numIdle: 1, numActive: 1,
} }); numIdle: 1,
}
});
}); });
} }
@ -72,6 +74,11 @@ export class DesignApi implements Api {
return password; return password;
} }
getPlain(cipher: string) {
// 设计器解密方法
return cipher;
}
getHyperlink(name: string) { getHyperlink(name: string) {
// 设计器获取超链 // 设计器获取超链
return ''; return '';

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

@ -64,13 +64,13 @@ export class FormJdbc extends BI.Widget {
this.oldPassword = password; this.oldPassword = password;
const { host, port, databaseName } = resolveUrlInfo(url, database); const { host, port, databaseName } = resolveUrlInfo(url, database);
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
const valueRangeConfig = { const valueRangeConfig = {
errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'), errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'),
checker: (value: string) => this.checkValueRange(value), checker: (value: string) => this.checkValueRange(value),
autoFix: true, autoFix: true,
}; };
return { return {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
hgap, hgap,
@ -360,7 +360,7 @@ export class FormJdbc extends BI.Widget {
vgap: 15, vgap: 15,
disabled: true, disabled: true,
value: schema, value: schema,
items: schema ? [{ text: schema, value:schema }] : [], items: schema ? [{ text: schema, value: schema }] : [],
ref: (_ref: TextValueCombo) => { ref: (_ref: TextValueCombo) => {
this.form.schema = _ref; this.form.schema = _ref;
}, },
@ -537,7 +537,7 @@ export class FormJdbc extends BI.Widget {
cls: 'bi-border', cls: 'bi-border',
allowBlank: true, allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
value: validationQuery, value: api.getPlain(validationQuery || ''),
width: 300, width: 300,
height: 100, height: 100,
ref: (_ref: TextAreaEditor) => { ref: (_ref: TextAreaEditor) => {
@ -715,7 +715,7 @@ export class FormJdbc extends BI.Widget {
...drivers, ...drivers,
]; ];
} }
return drivers; return drivers;
} }
@ -756,12 +756,12 @@ export class FormJdbc extends BI.Widget {
} }
} }
public getSubmitValue():Connection { public getSubmitValue(): Connection {
const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionPoolAttr = connectionData.connectionPoolAttr; const connectionPoolAttr = connectionData.connectionPoolAttr;
const originalCharsetName = this.form.originalCharsetName.getValue()[0] || ''; const originalCharsetName = this.form.originalCharsetName.getValue()[0] || '';
// TODO 获取表单数据这里待优化 // TODO 获取表单数据这里待优化
return { return {
connectionType: connectionType.JDBC, connectionType: connectionType.JDBC,
connectionId: this.form.connectionName.getValue(), connectionId: this.form.connectionName.getValue(),
@ -788,7 +788,7 @@ export class FormJdbc extends BI.Widget {
maxIdle: this.form.maxIdle.getValue(), maxIdle: this.form.maxIdle.getValue(),
minIdle: this.form.minIdle.getValue(), minIdle: this.form.minIdle.getValue(),
maxWait: this.form.maxWait.getValue(), maxWait: this.form.maxWait.getValue(),
validationQuery: this.form.validationQuery.getValue(), validationQuery: api.getCipher(this.form.validationQuery.getValue()),
testOnBorrow: BI.size(this.form.testOnBorrow.getValue()) > 0 ? this.form.testOnBorrow.getValue()[0] : connectionPoolAttr.testOnBorrow, testOnBorrow: BI.size(this.form.testOnBorrow.getValue()) > 0 ? this.form.testOnBorrow.getValue()[0] : connectionPoolAttr.testOnBorrow,
testOnReturn: BI.size(this.form.testOnReturn.getValue()) > 0 ? this.form.testOnReturn.getValue()[0] : connectionPoolAttr.testOnReturn, 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, testWhileIdle: BI.size(this.form.testWhileIdle.getValue()) > 0 ? this.form.testWhileIdle.getValue()[0] : connectionPoolAttr.testWhileIdle,

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

@ -1,6 +1,7 @@
import { shortcut } from '@core/core'; import {shortcut} from '@core/core';
import { Connection } from 'src/modules/crud/crud.typings'; import {Connection} from 'src/modules/crud/crud.typings';
import { getPluginWidgetEdit } from '../../../../app.service'; import {getPluginWidgetEdit} from '../../../../app.service';
@shortcut() @shortcut()
export class FormPlugin extends BI.Widget { export class FormPlugin extends BI.Widget {
static xtype = 'dec.dcm.maintain_plugin'; static xtype = 'dec.dcm.maintain_plugin';
@ -11,24 +12,28 @@ export class FormPlugin extends BI.Widget {
plugin: any; plugin: any;
render() { render() {
const { connectionType } = this.options.formData; const { connectionType, connectionId, connectionName, connectionData } = this.options.formData;
return { return {
type: getPluginWidgetEdit(connectionType), type: getPluginWidgetEdit(connectionType),
ref: (_ref: any) => { ref: (_ref: any) => {
this.plugin = _ref; this.plugin = _ref;
}, },
value: this.options.formData.connectionData, value: connectionData, // 兼容
connectionData,
connectionId,
connectionType,
connectionName,
}; };
} }
public getSubmitValue(): Connection { public getSubmitValue(): Connection {
const { connectionType, connectionId, connectionName } = this.options.formData; const { connectionType, connectionId, connectionName } = this.options.formData;
return { return {
connectionId, connectionId,
connectionType, connectionType,
connectionName, connectionName: this.plugin.getConnectionName ? this.plugin.getConnectionName() : connectionName,
connectionData: this.plugin.getValue(), connectionData: this.plugin.getValue(),
}; };
} }

6
src/modules/pages/maintain/forms/form.server.ts

@ -12,7 +12,7 @@ export function testConnection(value: Connection): Promise<string[]> {
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'), { BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'), {
level: 'error', level: 'error',
}); });
return false; return false;
} }
const id = BI.UUID(); const id = BI.UUID();
@ -27,7 +27,7 @@ export function testConnection(value: Connection): Promise<string[]> {
// DEC-14009 1.8以上版本JDK支持ODBC连接 // DEC-14009 1.8以上版本JDK支持ODBC连接
if (driver === JDBC_ODBC_DRIVER) { if (driver === JDBC_ODBC_DRIVER) {
testStatus.setFail(re.errorMsg, driver, Dec.system[DecCst.Hyperlink.DECISION_HYPERLINK_CONFIG][JDBC_ODBC_DRIVER_HELP_LINK]); testStatus.setFail(re.errorMsg, driver, Dec.system[DecCst.Hyperlink.DECISION_HYPERLINK_CONFIG][JDBC_ODBC_DRIVER_HELP_LINK]);
return; return;
} }
const databaseType = (formValue.connectionData as ConnectionJDBC).database; const databaseType = (formValue.connectionData as ConnectionJDBC).database;
@ -63,7 +63,7 @@ export function testConnection(value: Connection): Promise<string[]> {
loadingCls: 'upload-loading-icon', loadingCls: 'upload-loading-icon',
successText: BI.i18nText('Dec-Dcm_Connection_Test_Success'), successText: BI.i18nText('Dec-Dcm_Connection_Test_Success'),
successCls: 'upload-success-icon', successCls: 'upload-success-icon',
failText: BI.i18nText('Dec-Dcm_Connection_Test_Fail', name), failText: BI.i18nText('Dec-Dcm_Connection_Test_Fail', ''),
failCls: 'upload-fail-icon', failCls: 'upload-fail-icon',
retryText: BI.i18nText('Dec-Dcm_Connection_ReConnect'), retryText: BI.i18nText('Dec-Dcm_Connection_ReConnect'),
ref: (_ref: any) => { ref: (_ref: any) => {

Loading…
Cancel
Save