Browse Source

Merge pull request #2782 in DEC/decision-webui-dcm from bugfix/10.0 to release/10.0

* commit '02b0b3799536b3399ef702d203151a8b1f38684b':
  DEC-19760 feat: 【BI配合】驱动管理
  DEC-20237 fix: 【迭代】【驱动管理】使用某个自定义驱动新建数据连接,下拉框选中后再次下拉,使用相同驱动文件的的所有自定义驱动都会标蓝选中
  DEC-20235 fix: 【迭代】【驱动管理】新建数据连接选择自定义驱动,点击添加驱动再退出,所有没有选择驱动类的自定义驱动标蓝显示
  DEC-20201 fix: 【迭代】【驱动管理】切换为自定义驱动,已经填好的数据库信息不会保存
  DEC-19760 feat: 【BI配合】驱动管理,war包部署不支持提醒
  DEC-20204 fix: 【迭代】【驱动管理】次管权限没有限制,可以进入驱动管理页面
  DEC-20200 fix: 【迭代】【驱动管理】新建数据连接,选择自定义驱动,保存后显示默认驱动
  DEC-20201 fix: 【迭代】【驱动管理】切换为自定义驱动,已经填好的数据库信息不会保存
  DEC-20047 fix: 【迭代】【部分数据连接支持fetchSize】平台设置fetchSize为空回填数值为0
  DEC-20026 fix: 【自动化】数据连接-新增JNDI类型数据连接无法保存和测试连接
  DEC-20036 fix: 【自动化】数据连接管理-其他JDBC类型,切换驱动类型后URL没有联动变化
  DEC-20078 fix: 【迭代】【部分数据连接支持fetchSize】JNDI数据连接新建、编辑页面的「测试连接」、「保存」按钮点击无反应
  DEC-19879 feat: 驱动管理-前端
  DEC-19762 feat:【FR配合】部分数据连接支持fetchsize
  DEC-19934 fix: 【迭代】数据连接出错提示-数据连接点击复制按钮没有反应
  DEC-19762 feat: 【FR配合】部分数据连接支持fetchsize
  DEC-19867 feat: 数据lic受限连接出错提示-前端
  DEC-19867 feat: 数据lic受限连接出错提示-前端
release/10.0
superman 3 years ago
parent
commit
509855bac0
  1. 10
      package.json
  2. 3
      private/i18n.ts
  3. 12
      src/modules/app.model.ts
  4. 6
      src/modules/app.ts
  5. 30
      src/modules/constants/constant.ts
  6. 21
      src/modules/crud/api.ts
  7. 15
      src/modules/crud/crud.typings.d.ts
  8. 65
      src/modules/crud/decision.api.ts
  9. 9
      src/modules/crud/design.api.ts
  10. 36
      src/modules/pages/connection/connection.model.ts
  11. 53
      src/modules/pages/connection/connection.ts
  12. 23
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  13. 2
      src/modules/pages/connection/list/list.model.ts
  14. 4
      src/modules/pages/connection/list/list.ts
  15. 72
      src/modules/pages/connection/list/list_item/list_item.model.ts
  16. 11
      src/modules/pages/connection/list/list_item/list_item.ts
  17. 33
      src/modules/pages/connection_pool/connection_pool.ts
  18. 126
      src/modules/pages/maintain/components/driverselector/driverselector.model.ts
  19. 185
      src/modules/pages/maintain/components/driverselector/driverselector.ts
  20. 131
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  21. 29
      src/modules/pages/maintain/forms/form.ts

10
package.json

@ -48,15 +48,14 @@
"source-map-loader": "0.2.4",
"style-loader": "0.23.1",
"ts-jest": "24.0.2",
"typescript": "3.5.1",
"typescript": "^4.3.5",
"webpack": "4.35.2",
"webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2",
"webpack-merge": "4.2.1"
},
"optionalDependencies": {
"@fui/core": "^2.0.0",
"@fui/materials": "10.0.0-release - 10.0.0-release.99999999999999"
"@fui/core": "^2.0.20210721103227"
},
"scripts": {
"dev": "cross-env NODE_ENV=mock webpack-dev-server -p --progress --config=webpack/webpack.dev.js --mode development --open",
@ -67,10 +66,5 @@
"i18n": "node ./lib/transform-i18n/transform-i18n.js",
"test": "jest --passWithNoTests",
"upgrade": "node lib/upgrade"
},
"husky": {
"hooks": {
"pre-push": "npm run eslint && npm run test"
}
}
}

3
private/i18n.ts

@ -303,4 +303,7 @@ export default {
'Dec-Dcm_Connection_Analytic_DB': '阿里云AnalyticDB',
'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围',
'Dec-Dcm_Socket_Unable_Connect_Tip': '可能出现编辑冲突',
'Dec-Connection_Lic_Limit_Approach_Tip': '当前数据连接数量超过注册lic限制({}个),所有数据连接都不可用,请删除多余的数据连接',
'Dec-Connection_Lic_Limit_Approach_Prevent_Tip': '当前数据连接数量已经达到注册lic限制({}个),无法新增',
'Dec-Dcm_Connection_Check_Fetch_Size_Range': '请输入0-1000000之间的值',
};

12
src/modules/app.model.ts

@ -7,7 +7,7 @@ import { getAllDatabaseTypes } from './app.service';
export class AppModel extends Model {
static xtype = 'dec.dcm.model.main';
childContext = <const>['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy'];
childContext = <const>['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy', 'connectionLicInfo'];
state() {
return {
@ -19,23 +19,27 @@ export class AppModel extends Model {
saveEvent: '',
testEvent: '',
isCopy: false,
connectionLicInfo: {
currentConnectionNum: 0,
maxConnectionNum: 0,
},
};
}
computed = {
connectionSelectedOne: () => this.model.connections.find(item => item.connectionName === this.model.connectionSelected),
datebaseTypeSelectedOne: () => getAllDatabaseTypes().find(item => item.databaseType === this.model.datebaseTypeSelected),
}
};
actions = {
setPageIndex: (index: string) => {
this.model.pageIndex = index;
},
setFilter:(filter: string) => {
setFilter: (filter: string) => {
this.model.filter = filter;
},
setDatebaseTypeSelected: (datebaseTypeSelected: string) => {
this.model.datebaseTypeSelected = datebaseTypeSelected;
},
}
};
}

6
src/modules/app.ts

@ -15,6 +15,10 @@ import '../less/index.less';
export class App extends BI.Widget {
static xtype = 'dec.dcm.main';
props = {
baseCls: 'dec-dcm',
};
tab: Tab;
store: AppModel['store'];
@ -24,7 +28,7 @@ export class App extends BI.Widget {
pageIndex: (index: string) => {
this.tab.setSelect(index);
},
}
};
render() {
return {

30
src/modules/constants/constant.ts

@ -19,17 +19,17 @@ export const DATEBASE_FILTER_TYPE = {
};
export const DATA_BASE_TYPES_OTHER =
{
text: OTHER_JDBC,
databaseType: OTHER_JDBC,
driver: '',
url: '',
commonly: false,
internal: false,
type: 'jdbc',
hasSchema: true,
kerberos: false,
};
{
text: OTHER_JDBC,
databaseType: OTHER_JDBC,
driver: '',
url: '',
commonly: false,
internal: false,
type: 'jdbc',
hasSchema: true,
kerberos: false,
};
export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [
{
databaseType: 'ads',
@ -444,6 +444,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc',
hasSchema: true,
kerberos: false,
fetchSize: 50,
}, {
text: 'INFORMIX',
databaseType: 'informix',
@ -521,6 +522,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc',
hasSchema: true,
kerberos: false,
fetchSize: 128,
},
{
text: 'Pivotal Greenplum Database',
@ -547,6 +549,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc',
hasSchema: true,
kerberos: false,
fetchSize: 10000,
}, {
text: 'Presto',
databaseType: 'presto',
@ -648,7 +651,6 @@ export const DATA_BASE_TYPES = [
];
export const CONNECT_CHARSET = [
{
text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'),
@ -740,10 +742,10 @@ export const CONNECTION_LAYOUT = {
export const JNDI_FACTORYS = [
{
factory:'',
factory: '',
url: '',
}, {
factory:'weblogic.jndi.WLInitialContextFactory',
factory: 'weblogic.jndi.WLInitialContextFactory',
url: 't3://localhost:7001',
}, {
factory: 'com.ibm.websphere.naming.WsnInitialContextFactory',

21
src/modules/crud/api.ts

@ -1,4 +1,11 @@
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ResultType } from './crud.typings';
import {
Connection,
ConnectionLicInfo,
TestRequest,
ConnectionPoolType,
SocketResult,
ResultType,
} from './crud.typings';
export interface Api {
/**
@ -9,7 +16,12 @@ export interface Api {
/**
*
*/
getConnectionlist(): Promise<{ data?: Connection[] }>;
getConnectionList(): Promise<{ data?: Connection[] }>;
/**
* lic限制信息
*/
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }>;
/**
*
@ -40,6 +52,11 @@ export interface Api {
*/
getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>;
/**
*
*/
getSimpleDriverList(): Promise<{ data?: any[] }>;
/**
*
* @param name

15
src/modules/crud/crud.typings.d.ts vendored

@ -22,7 +22,12 @@ export interface Connection {
privilegeDetailBeanList?: {
privilegeType: number;
privilegeValue: number;
}[]
}[];
}
export interface ConnectionLicInfo {
currentConnectionNum: number;
maxConnectionNum: number;
}
export interface ConnectionJDBC {
@ -103,6 +108,14 @@ export interface ConnectionJDBC {
*
*/
keyPath?: string;
/**
* fetchSize
*/
fetchSize?: number;
/**
* id
*/
identity?: string;
connectionPoolAttr: ConnectionPoolJDBC;
}

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

@ -1,15 +1,19 @@
import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings';
import { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent, errorCode } from '@constants/env';
export class DecisionApi implements Api {
isDec = true;
getConnectionlist(): Promise<{ data?: Connection[] }> {
getConnectionList(): Promise<{ data?: Connection[] }> {
return requestGet('list', {});
}
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
deleteConnection(connectionName: string) {
return requestDelete('', {
connectionName,
@ -48,29 +52,38 @@ export class DecisionApi implements Api {
return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {});
}
getSimpleDriverList(): Promise<{ data: any[] }> {
return new Promise(resolve => {
Dec.reqGet('/v10/drivers/simple/list', '', re => {
resolve(re);
});
});
}
getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => {
if (re.errorCode) {
let errorMessage = '';
switch (re.errorCode) {
case errorCode.CONNECTION_DELETED:
errorMessage = 'Dec-Dcm_Connection_Deleted';
break;
case errorCode.CONNECTION_UNDER_EDIT:
errorMessage = 'Dec-Dcm_Connection_Is_Using';
break;
default:
errorMessage = re.errorMsg;
break;
return this.sendEditStatusEvent(name, editStatusEvent.OPEN)
.then(re => {
if (re.errorCode) {
let errorMessage = '';
switch (re.errorCode) {
case errorCode.CONNECTION_DELETED:
errorMessage = 'Dec-Dcm_Connection_Deleted';
break;
case errorCode.CONNECTION_UNDER_EDIT:
errorMessage = 'Dec-Dcm_Connection_Is_Using';
break;
default:
errorMessage = re.errorMsg;
break;
}
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), {
level: 'error',
});
throw re;
} else {
return re;
}
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), {
level: 'error',
});
throw re;
} else {
return re;
}
});
});
}
shutdownConnectionStatus(name: string): Promise<SocketResult> {
@ -94,11 +107,13 @@ export class DecisionApi implements Api {
}
getCipher(password: string) {
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);
return BI.Providers.getProvider('dec.provider.cipher')
.getPlain(cipher);
}
getHyperlink(name: string) {

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

@ -1,16 +1,21 @@
import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings';
import { requestGet } from './crud.service';
// TODO: 此页面的接口等待设计器提供相应的方法
export class DesignApi implements Api {
isDec = false;
getConnectionlist(): Promise<{ data: Connection[] }> {
getConnectionList(): Promise<{ data: Connection[] }> {
return new Promise(resolve => {
resolve({ data: [] });
});
}
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
deleteConnection(connectionName: string): Promise<{ data: string }> {
return new Promise(resolve => {
resolve({ data: 'success' });

36
src/modules/pages/connection/connection.model.ts

@ -1,24 +1,49 @@
import { model, Model } from '@core/core';
import { AppModel } from '../../app.model';
import { ApiFactory } from 'src/modules/crud/apiFactory';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create();
@model()
export class ConnectionModel extends Model<{
types : {
types: {
pageIndex: AppModel['TYPE']['pageIndex'];
connections: AppModel['TYPE']['connections'];
connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
},
childContext: ConnectionModel['childContext'];
context: ConnectionModel['context'];
}> {
static xtype = 'dec.dcm.model.connection';
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected'];
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo'];
actions = {
setPageIndex:(index: string) => {
initConnectionLicInfo: (cb: Function) => {
return api.getConnectionLicInfo()
.then(res => {
this.model.connectionLicInfo = res.data;
if (res.data.currentConnectionNum > res.data.maxConnectionNum) {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Tip', res.data.maxConnectionNum),
});
}
cb();
});
},
createNewConnection: () => {
if (this.model.connectionLicInfo.currentConnectionNum < this.model.connectionLicInfo.maxConnectionNum) {
this.setPageIndex(PAGE_INDEX.DATEBASE);
} else {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum),
});
}
},
setPageIndex: (index: string) => {
this.model.pageIndex = index;
},
setDatebaseTypeSelected(name: string) {
@ -30,5 +55,8 @@ export class ConnectionModel extends Model<{
getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected);
},
}
checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
},
};
}

53
src/modules/pages/connection/connection.ts

@ -24,7 +24,7 @@ export class Connection extends BI.Widget {
title: HTapeLayout;
watch = {
connectionSelected:(name: string) => {
connectionSelected: (name: string) => {
if (name) {
const canEdit = connectionCanEdit(this.model.connectionSelectedOne);
const type = this.getSelectConnectionType();
@ -43,6 +43,10 @@ export class Connection extends BI.Widget {
this.connectionEditWidget.setVisible(false);
}
},
};
beforeRender(cb: Function) {
this.store.initConnectionLicInfo(cb);
}
render() {
@ -60,15 +64,34 @@ export class Connection extends BI.Widget {
items: [
{
el: {
type: BI.VerticalAdaptLayout.xtype,
type: BI.LeftRightVerticalAdaptLayout.xtype,
cls: 'bi-border-bottom',
items: [{
type: BI.Button.xtype,
text: BI.i18nText('Dec-Dcm_Connection_New'),
handler: () => {
this.store.setPageIndex(PAGE_INDEX.DATEBASE);
},
}],
items: {
left: [
{
type: BI.Button.xtype,
text: BI.i18nText('Dec-Dcm_Connection_New'),
handler: () => {
this.store.createNewConnection();
},
},
],
right: [
{
type: 'dec.connection.driver.entry',
invisible: !BI.Services.getService('dec.service.global').isAdmin(),
from: '.dec-dcm',
listeners: [
{
eventName: 'EVENT_CLOSE',
action: () => {
this.reset();
},
},
],
},
],
},
},
height: 40,
},
@ -110,11 +133,13 @@ export class Connection extends BI.Widget {
this.connectionEditWidget = _ref;
},
handler: () => {
this.store.getConnectionStatus().then(re => {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
})
.catch(() => {});
this.store.getConnectionStatus()
.then(re => {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
})
.catch(() => {
});
},
}],
},

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

@ -19,9 +19,21 @@ export class ConnectionJdbc extends BI.Widget {
model: ConnectionJdecModel['model'];
allDatabaseTypes = getAllDatabaseTypes();
render () {
render() {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { driver, database, user, originalCharsetName, schema, connectionPoolAttr, authType, principal, url } = connectionData;
const {
driver,
driverSource,
database,
user,
originalCharsetName,
schema,
connectionPoolAttr,
authType,
principal,
url,
fetchSize,
} = connectionData;
const databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName } = resolveUrlInfo(url, database);
const { hgap, vgap } = CONNECTION_LAYOUT;
@ -34,7 +46,7 @@ export class ConnectionJdbc extends BI.Widget {
{
type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: driver,
value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
},
{
type: FormItem.xtype,
@ -169,6 +181,11 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'),
value: connectionPoolAttr.minEvictableIdleTimeMillis,
unit: BI.i18nText('BI-Basic_Seconds'),
}, {
type: FormItem.xtype,
invisible: fetchSize < 0 && fetchSize !== -2,
name: 'Fetchsize',
value: fetchSize === -2 ? '' : fetchSize,
},
],
},

2
src/modules/pages/connection/list/list.model.ts

@ -19,7 +19,7 @@ export class ConnectionListModel extends Model<{
}
actions = {
setConnections: ():Promise<void> => api.getConnectionlist().then(data => {
setConnections: ():Promise<void> => api.getConnectionList().then(data => {
if (BI.size(data.data) > 0) {
this.model.connections = data.data;
this.model.connections.forEach(item => {

4
src/modules/pages/connection/list/list.ts

@ -6,7 +6,7 @@ import { Tab } from '@fui/core';
@shortcut()
@store(ConnectionListModel)
export class ConnectionList extends BI.LoadingPane {
export class ConnectionList extends BI.Pane {
static xtype = 'dec.dcm.connection.list';
store: ConnectionListModel['store'];
@ -15,7 +15,7 @@ export class ConnectionList extends BI.LoadingPane {
groupWidget: any;
tab: Tab;
beforeInit(cb: Function) {
beforeRender(cb: Function) {
this.store.setConnections().then(() => {
cb();
});

72
src/modules/pages/connection/list/list_item/list_item.model.ts

@ -4,11 +4,13 @@ import { ApiFactory } from '../../../../crud/apiFactory';
import { ResultType } from '../../../../crud/crud.typings';
import { getChartLength } from '../../../../app.service';
import { NAME_MAX_LENGTH } from '../../../../app.constant';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create();
@model()
export class ListItemModel extends Model<{
types : {
types: {
connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne'];
@ -21,7 +23,7 @@ export class ListItemModel extends Model<{
}> {
static xtype = 'dec.dcm.model.connection.list_item';
context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy'];
context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo'];
state() {
return {
@ -52,10 +54,12 @@ export class ListItemModel extends Model<{
},
setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) {
api.getConnectionStatus(name).then(re => {
this.model.isEdit = true;
})
.catch(() => {});
api.getConnectionStatus(name)
.then(re => {
this.model.isEdit = true;
})
.catch(() => {
});
} else {
api.shutdownConnectionStatus(name);
this.model.isEdit = false;
@ -69,7 +73,10 @@ export class ListItemModel extends Model<{
}
if (getChartLength(newName) > NAME_MAX_LENGTH) {
return new Promise(resolve => {
resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) });
resolve({
errorCode: '1',
errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH),
});
});
}
const hasNamed = this.model.connections.some(item => item.connectionName === newName);
@ -83,30 +90,49 @@ export class ListItemModel extends Model<{
connection.connectionName = newName;
return api.updateConnection(connection).then(re => {
if (!re.errorCode) {
this.model.connections = this.model.connections.map(item => {
return {
...item,
connectionName: item.connectionName === oldName ? newName : item.connectionName,
connectionId: item.connectionName === oldName ? newName : item.connectionName,
};
});
if (this.model.connectionSelected === oldName) {
this.model.connectionSelected = newName;
return api.updateConnection(connection)
.then(re => {
if (!re.errorCode) {
this.model.connections = this.model.connections.map(item => {
return {
...item,
connectionName: item.connectionName === oldName ? newName : item.connectionName,
connectionId: item.connectionName === oldName ? newName : item.connectionName,
};
});
if (this.model.connectionSelected === oldName) {
this.model.connectionSelected = newName;
}
}
}
return re;
});
return re;
});
},
copyConnection(connectionName) {
if (this.model.connectionLicInfo.currentConnectionNum >= this.model.connectionLicInfo.maxConnectionNum) {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum),
});
return;
}
this.setConnectionSelected(connectionName);
this.setIsCopy(true);
this.setPageIndex(PAGE_INDEX.MAINTAIN);
},
setIsCopy: (isCopy: boolean) => {
this.model.isCopy = isCopy;
},
isDriverError: (errorCode: string) => api.isDriverError(errorCode),
}
};
removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist())
api.deleteConnection(name)
.then(re => {
this.model.connectionLicInfo.currentConnectionNum -= 1;
return api.getConnectionList();
})
.then(connections => {
this.model.connections = connections.data;
this.model.connections.forEach(item => {

11
src/modules/pages/connection/list/list_item/list_item.ts

@ -19,7 +19,7 @@ export class ListItem extends BI.BasicButton {
height: 25,
baseCls: 'dec-dcm-connection-list-item bi-list-item-active2',
$testId: 'dec-dcm-connection-list-item',
}
};
store: ListItemModel['store'];
model: ListItemModel['model'];
@ -36,7 +36,7 @@ export class ListItem extends BI.BasicButton {
this.nameEditor.focus();
}
},
}
};
render() {
const { name, databaseType } = this.options;
@ -220,15 +220,14 @@ export class ListItem extends BI.BasicButton {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
})
.catch(() => { });
.catch(() => {
});
},
changeName: () => {
this.store.setIsEdit(true, name);
},
copy: () => {
this.store.setConnectionSelected(name);
this.store.setIsCopy(true);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.copyConnection(name);
},
delete: () => {
this.store.deleteConnection(name);

33
src/modules/pages/connection_pool/connection_pool.ts

@ -4,6 +4,7 @@ import { ListItem } from './list_item/list_item';
import { Pool } from './pool/pool';
import { PAGE_SIZE } from '@constants/constant';
import { Label } from '@fui/core';
@shortcut()
@store(ConnectionPoolModel)
export class ConnectionPool extends BI.Widget {
@ -18,7 +19,7 @@ export class ConnectionPool extends BI.Widget {
selected: (selected: string) => {
this.title.setText(selected);
},
}
};
mounted() {
const defaultSelected = this.model.connectionJDBC.length > 0 ? this.model.connectionJDBC[0].connectionName : '';
@ -37,6 +38,7 @@ export class ConnectionPool extends BI.Widget {
el: {
type: BI.VTapeLayout.xtype,
cls: 'bi-border-right',
hgap: 10,
items: [
{
el: {
@ -44,16 +46,18 @@ export class ConnectionPool extends BI.Widget {
cls: 'bi-border-bottom',
textAlign: 'left',
text: BI.i18nText('Dec-Dcm_Data_Connections'),
lgap: 10,
},
height: 40,
},
{
type: BI.Loader.xtype,
itemsCreator: (options: {times: number}, populate) => {
populate(this.renderList((options.times - 1) * PAGE_SIZE, options.times * PAGE_SIZE));
el: {
type: BI.Loader.xtype,
itemsCreator: (options: { times: number }, populate) => {
populate(this.renderList((options.times - 1) * PAGE_SIZE, options.times * PAGE_SIZE));
},
hasNext: options => options.times * PAGE_SIZE < BI.size(this.model.connectionJDBC),
},
hasNext: options => options.times * PAGE_SIZE < BI.size(this.model.connectionJDBC),
vgap: 10,
},
],
},
@ -117,13 +121,14 @@ export class ConnectionPool extends BI.Widget {
private renderList(start = 0, end = 0) {
const defaultSelected = this.model.connectionJDBC.length > 0 ? this.model.connectionJDBC[0].connectionName : '';
return this.model.connectionJDBC.slice(start, end).map(item => {
return {
type: ListItem.xtype,
name: item.connectionName,
value: item.connectionName,
selected: item.connectionName === defaultSelected,
};
});
return this.model.connectionJDBC.slice(start, end)
.map(item => {
return {
type: ListItem.xtype,
name: item.connectionName,
value: item.connectionName,
selected: item.connectionName === defaultSelected,
};
});
}
}

126
src/modules/pages/maintain/components/driverselector/driverselector.model.ts

@ -0,0 +1,126 @@
import { model, Model } from '@core/core';
import { ConnectionJDBC } from '../../../../crud/crud.typings';
import { getJdbcDatabaseType } from '../../../../app.service';
import { ApiFactory } from '../../../../crud/apiFactory';
const api = new ApiFactory().create();
@model()
export class DriverSelectorModel extends Model {
static xtype = 'dec.dcm.model.maintain.form.jdbc.driver_selector';
state = () => {
const defaultDrivers = this.getDrivers();
const [driverSource, selectedDriver] = this.resolveSelectedDriverType();
return {
defaultDrivers,
driverSource,
selectedDriverType: driverSource === '' ? 'default' : 'custom',
customDrivers: [],
defaultDriver: {
driver: driverSource === '' ? selectedDriver : '',
},
customDriver: {
driver: driverSource !== '' ? selectedDriver : '',
value: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '',
},
};
};
computed = {
driverClassItems: () => this.model.customDrivers.map(driver => {
return {
text: `${driver.driverClass} (${driver.name})`,
value: `${driver.driverClass} (${driver.name})`,
driverClass: driver.driverClass,
};
}),
driverTypeComboValue: () => this.model.driverSource === '' ? 'default' : 'custom',
driverManageEntryVisible: () => this.model.selectedDriverType === 'custom' && BI.Services.getService('dec.service.global').isAdmin(),
};
actions = {
initDriverClassList: cb => {
api.getSimpleDriverList().then(res => {
this.model.customDrivers = res.data.filter(driver => {
return BI.isKey(driver.driverClass);
});
cb();
});
},
changeDefaultDriver: driver => {
this.model.defaultDriver.driver = driver;
this.model.driverSource = '';
},
changeCustomDriver: value => {
const item = this.model.driverClassItems.find(item => {
return item.value === value;
});
const driver = item.driverClass;
this.model.customDriver.driver = driver;
this.model.customDrivers.some(customDriver => {
if (customDriver.driverClass === driver) {
this.model.driverSource = customDriver.name;
this.model.customDriver.value = `${driver} (${customDriver.name})`;
return true;
}
return false;
});
},
changeSelectedDriverType: driverTypeComboValue => {
this.model.selectedDriverType = driverTypeComboValue;
this.model.driverSource = driverTypeComboValue === 'default' ? '' : this.model.driverSource;
},
changeDriverSource: driverTypeComboValue => {
this.model.driverSource = driverTypeComboValue === 'default' ? '' : this.model.driverSource;
},
};
private resolveSelectedDriverType = () => {
if (BI.isNotEmptyString(this.options.driverSource)) {
return [this.options.driverSource, this.options.driver];
}
return [this.options.driverSource, this.options.driver];
};
private getDrivers = () => {
const connectionData = this.options.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);
const drivers = connectionType.drivers ?
connectionType.drivers.map(item => {
return {
text: item,
value: item,
};
}) :
[{
text: connectionType.driver,
value: connectionType.driver,
}];
if (!drivers.some(item => item.text === connectionData.driver)) {
return [
{
text: connectionData.driver,
value: connectionData.driver,
},
...drivers,
];
}
return drivers;
};
}

185
src/modules/pages/maintain/components/driverselector/driverselector.ts

@ -0,0 +1,185 @@
import { shortcut, store } from '@core/core';
import {
Button,
EditorIconCheckCombo,
SearchTextValueCombo,
TextValueCombo,
} from '@fui/core';
import { ConnectionJDBC } from '../../../../crud/crud.typings';
import { getJdbcDatabaseType } from '../../../../app.service';
import { DriverSelectorModel } from './driverselector.model';
@shortcut()
@store(DriverSelectorModel, {
props(this: DriverSelector) {
return this.options;
},
})
export class DriverSelector extends BI.Widget {
static xtype = 'dec.dcm.maintain.form.jdbc.driver_selector';
props = {
driver: '',
driverSource: '',
connectionData: {} as ConnectionJDBC,
};
defaultDrivers: EditorIconCheckCombo = null;
customDrivers: SearchTextValueCombo = null;
beforeRender(cb: Function) {
this.store.initDriverClassList(cb);
}
watch = {
driverClassItems: items => {
this.customDrivers.populate(items);
this.customDrivers.setValue(this.model.customDriver.value);
},
driverManageEntryVisible: b => {
this.driverManageEntry.setVisible(b);
},
};
private driverManageEntry = null;
render() {
const { driver } = this.options.connectionData;
return {
type: BI.VerticalAdaptLayout.xtype,
rgap: 10,
items: [
{
el: {
type: BI.TextValueCombo.xtype,
width: 86,
value: this.model.selectedDriverType,
items: [
{
text: BI.i18nText('Dec-Basic_Default'),
value: 'default',
}, {
text: BI.i18nText('Dec-Basic_Custom'),
value: 'custom',
},
],
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: value => {
this.store.changeSelectedDriverType(value);
if (value === 'default') {
this.defaultDrivers.setVisible(true);
this.customDrivers.setVisible(false);
this.fireEvent('EVENT_CHANGE');
return;
}
this.defaultDrivers.setVisible(false);
this.customDrivers.setVisible(true);
if (BI.isKey(this.customDrivers.getValue()[0])) {
this.fireEvent('EVENT_CHANGE');
}
},
},
],
},
}, {
el: {
type: BI.EditorIconCheckCombo.xtype,
$testId: 'dec-editor-icon-check-combo',
$value: 'driver',
ref: _ref => {
this.defaultDrivers = _ref;
},
invisible: this.model.driverSource !== '',
width: 204,
items: this.model.defaultDrivers,
value: this.model.defaultDriver.driver,
listeners: [
{
eventName: BI.EditorIconCheckCombo.EVENT_CHANGE,
action: () => {
this.store.changeDefaultDriver(this.defaultDrivers.getValue());
this.fireEvent('EVENT_CHANGE');
},
},
],
},
}, {
el: {
type: BI.SearchTextValueCombo.xtype,
$testId: 'dec-editor-icon-check-combo',
$value: 'driver',
ref: _ref => {
this.customDrivers = _ref;
},
invisible: this.model.driverSource === '',
width: 204,
watermark: BI.i18nText('Dec-Please_Input'),
items: this.model.driverClassItems,
value: this.model.customDriver.value,
text: () => this.model.customDriver.value || '',
defaultText: BI.i18nText('Dec-Please_Select'),
warningTitle: BI.i18nText('Dec-Dcm-Driver_Driver_File_Lost'),
listeners: [
{
eventName: BI.SearchTextValueCombo.EVENT_CHANGE,
action: () => {
this.store.changeCustomDriver(this.customDrivers.getValue()[0]);
this.fireEvent('EVENT_CHANGE');
},
},
],
},
}, {
el: {
type: 'dec.connection.driver.entry',
ref: (_ref: Button) => {
this.driverManageEntry = _ref;
},
el: {
type: BI.Button.xtype,
level: 'ignore',
text: BI.i18nText('Dec-Dcm_Create_New_Driver'),
},
from: '.dec-dcm',
invisible: !this.model.driverManageEntryVisible,
listeners: [
{
eventName: 'EVENT_CLOSE',
action: () => {
this.store.initDriverClassList(BI.emptyFn);
},
},
],
},
},
],
};
}
validation(): boolean {
if (this.model.selectedDriverType === 'default' && BI.isKey(this.model.defaultDriver.driver)) {
return true;
}
if (this.model.selectedDriverType === 'custom' && BI.isKey(this.model.customDriver.driver)) {
return true;
}
BI.Msg.toast(BI.i18nText('Dec-Dcm_Driver_Class_Not_Allow_Empty'), { level: 'error' });
return false;
}
getValue() {
return {
driverSource: this.model.driverSource,
driver: this.model.driverSource === '' ? this.model.defaultDriver.driver : this.model.customDriver.driver,
};
}
}

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

@ -1,12 +1,12 @@
import {shortcut} from '@core/core';
import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse';
import {FormItem} 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, INT_MAX_VALUE, INT_MIN_VALUE} from '@constants/constant';
import {getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl} from '../../../../app.service';
import {TextChecker} from '../../../../components/text_checker/text_checker';
import {ApiFactory} from 'src/modules/crud/apiFactory';
import { shortcut } from '@core/core';
import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import { FormItem } 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, INT_MAX_VALUE, INT_MIN_VALUE } from '@constants/constant';
import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service';
import { TextChecker } from '../../../../components/text_checker/text_checker';
import { ApiFactory } from 'src/modules/crud/apiFactory';
import {
Editor,
EditorIconCheckCombo,
@ -14,8 +14,9 @@ import {
TextAreaEditor,
TextEditor,
TextValueCombo,
VerticalLayout
VerticalLayout,
} from '@fui/core';
import { DriverSelector } from '../../components/driverselector/driverselector';
const api = new ApiFactory().create();
@ -25,7 +26,7 @@ export class FormJdbc extends BI.Widget {
props = {
formData: {} as Connection,
}
};
oldPassword = '';
allDatabaseTypes = getAllDatabaseTypes();
@ -63,12 +64,14 @@ export class FormJdbc extends BI.Widget {
numTestsPerEvictionRun: null,
minIdle: null,
minEvictableIdleTimeMillis: null,
fetchSize: null,
};
render() {
const {connectionName, connectionData} = this.options.formData;
const { connectionName, connectionData } = this.options.formData;
const {
driver,
driverSource,
user,
password,
originalCharsetName,
@ -78,7 +81,8 @@ export class FormJdbc extends BI.Widget {
database,
authType,
principal,
keyPath
keyPath,
fetchSize,
} = connectionData as ConnectionJDBC;
const {
initialSize,
@ -92,12 +96,12 @@ export class FormJdbc extends BI.Widget {
timeBetweenEvictionRunsMillis,
numTestsPerEvictionRun,
minIdle,
minEvictableIdleTimeMillis
minEvictableIdleTimeMillis,
} = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver);
this.oldPassword = password;
const {host, port, databaseName} = resolveUrlInfo(url, database);
const {hgap, vgap} = CONNECTION_LAYOUT;
const { host, port, databaseName } = resolveUrlInfo(url, database);
const { hgap, vgap } = CONNECTION_LAYOUT;
const valueRangeConfig = {
errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'),
@ -128,31 +132,34 @@ export class FormJdbc extends BI.Widget {
{
type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
forms: [{
type: BI.EditorIconCheckCombo.xtype,
$testId: 'dec-editor-icon-check-combo',
$value: 'driver',
width: 300,
value: driver,
ref: (_ref: EditorIconCheckCombo) => {
this.form.driver = _ref;
},
items: this.getDrivers(),
listeners: [{
eventName: BI.EditorIconCheckCombo.EVENT_CHANGE,
action: () => {
const value = this.form.driver.getValue();
const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);
const url = connectionType.urls ? connectionType.urls[value] : connectionType.url;
this.form.url.setValue(url);
const urlInfo = resolveUrlInfo(url, connectionData.database);
this.form.host.setValue(urlInfo.host);
this.form.database.setValue(urlInfo.databaseName);
this.form.port.setValue(urlInfo.port);
forms: [
{
type: DriverSelector.xtype,
ref: (_ref: DriverSelector) => {
this.form.driver = _ref;
},
}],
}],
driver,
driverSource,
connectionData,
listeners: [
{
eventName: 'EVENT_CHANGE',
action: () => {
const value = this.form.driver.getValue();
const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);
// DEC-2020
const url = (connectionType.urls && connectionType.urls[value.driver]) || connectionType.url;
this.form.url.setValue(url);
const urlInfo = resolveUrlInfo(url, connectionData.database);
this.form.host.setValue(urlInfo.host);
this.form.database.setValue(urlInfo.databaseName);
this.form.port.setValue(urlInfo.port);
},
},
],
},
],
},
{
type: FormItem.xtype,
@ -394,7 +401,7 @@ export class FormJdbc extends BI.Widget {
vgap: 15,
disabled: true,
value: schema,
items: schema ? [{text: schema, value: schema}] : [],
items: schema ? [{ text: schema, value: schema }] : [],
ref: (_ref: TextValueCombo) => {
this.form.schema = _ref;
},
@ -702,6 +709,37 @@ export class FormJdbc extends BI.Widget {
text: BI.i18nText('BI-Basic_Seconds'),
},
],
}, {
el: {
type: BI.VerticalLayout.xtype,
cls: 'bi-border-top',
invisible: fetchSize < 0 && fetchSize !== -2,
items: [
{
el: {
type: FormItem.xtype,
name: 'Fetchsize',
forms: [{
type: TextChecker.xtype,
$value: 'fetch-size',
width: 300,
allowBlank: true,
value: fetchSize === -2 ? '' : fetchSize,
watermark: 'Fetchsize',
validationChecker: [{
errorText: BI.i18nText('Dec-Dcm_Connection_Check_Fetch_Size_Range'),
checker: (value: string) => BI.isInteger(value) && BI.parseInt(value) >= 0 && BI.parseInt(value) <= 1000000,
autoFix: true,
}],
ref: (_ref: TextChecker) => {
this.form.fetchSize = _ref;
},
}],
},
vgap: 15,
},
],
},
},
],
},
@ -767,9 +805,9 @@ export class FormJdbc extends BI.Widget {
}
private onHostPortChange(databaseType) {
const {urls, url} = databaseType;
const { urls, url } = databaseType;
const driver = this.form.driver.getValue();
const selectUrl = BI.get(urls, driver) || url;
const selectUrl = BI.get(urls, driver.driver) || url;
const host = this.form.host.getValue();
const port = this.form.port.getValue();
const database = this.form.database.getValue();
@ -790,6 +828,10 @@ export class FormJdbc extends BI.Widget {
}
}
public validation(): boolean {
return this.form.driver.validation();
}
public getSubmitValue(): Connection {
const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionPoolAttr = connectionData.connectionPoolAttr;
@ -803,7 +845,7 @@ export class FormJdbc extends BI.Widget {
connectionData: <ConnectionJDBC>BI.extend({}, connectionData, {
database: connectionData.database,
connectionName: this.form.connectionName.getValue(),
driver: this.form.driver.getValue(),
...this.form.driver.getValue(),
url: this.form.url.getValue(),
user: this.form.user.getValue(),
password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()),
@ -816,6 +858,7 @@ export class FormJdbc extends BI.Widget {
creator: Dec ? Dec.personal.username : '',
principal: this.form.principal.getValue(),
keyPath: this.form.keyPath.getValue(),
fetchSize: BI.isEmptyString(this.form.fetchSize.getValue()) ? -2 : BI.parseInt(this.form.fetchSize.getValue()),
connectionPoolAttr: {
initialSize: this.form.initialSize.getValue(),
maxActive: this.form.maxActive.getValue(),

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

@ -16,7 +16,7 @@ export class MaintainForm extends BI.Widget {
props = {
connectionType: '',
}
};
isEdit = false;
connectionName = '';
@ -55,7 +55,7 @@ export class MaintainForm extends BI.Widget {
testEvent: () => {
this.testConnection();
},
}
};
render() {
const formData = BI.clone(this.getFormData());
@ -98,7 +98,7 @@ export class MaintainForm extends BI.Widget {
}
}
private getFormData():Connection {
private getFormData(): Connection {
switch (this.options.connectionType) {
case connectionType.JDBC:
return this.getJdbcConnection();
@ -111,7 +111,7 @@ export class MaintainForm extends BI.Widget {
}
}
private getJdbcConnection():Connection {
private getJdbcConnection(): Connection {
const connectionName = this.getConnectionName();
let editConnection: Connection;
let connectionData: ConnectionJDBC;
@ -122,8 +122,10 @@ export class MaintainForm extends BI.Widget {
database: this.model.datebaseTypeSelectedOne.databaseType,
connectionName,
connectionPoolAttr: DEFAULT_JDBC_POOL,
port:'',
port: '',
host: 'localhost',
fetchSize: this.model.datebaseTypeSelectedOne.fetchSize ?? -1,
identity: BI.UUID(),
};
editConnection = {
connectionId: '',
@ -143,7 +145,7 @@ export class MaintainForm extends BI.Widget {
return connection;
}
private getJndiConnection():Connection {
private getJndiConnection(): Connection {
if (this.model.datebaseTypeSelected) {
return {
connectionId: '',
@ -158,7 +160,7 @@ export class MaintainForm extends BI.Widget {
return this.model.connectionSelectedOne;
}
private getPluginConnection():Connection {
private getPluginConnection(): Connection {
if (!this.model.datebaseTypeSelected) {
this.connectionName = this.model.connectionSelectedOne.connectionName;
this.isEdit = true;
@ -174,7 +176,7 @@ export class MaintainForm extends BI.Widget {
};
}
private testValue():boolean {
private testValue(): boolean {
const value = this.form.getSubmitValue();
if (!value.connectionName) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'));
@ -195,6 +197,10 @@ export class MaintainForm extends BI.Widget {
return false;
}
if (this.form.validation && !this.form.validation()) {
return false;
}
return true;
}
@ -221,13 +227,18 @@ export class MaintainForm extends BI.Widget {
if (!formValue.connectionName) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'));
return;
return false;
}
if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH));
return false;
}
if (this.form.validation && !this.form.validation()) {
return false;
}
if (this.isEdit || this.model.isCopy) {
formValue.connectionId = this.connectionName;
}

Loading…
Cancel
Save