Browse Source

Merge branch 'release/10.0' of ssh://cloud.finedevelop.com:7999/~dailer/decision-webui-dcm into release/10.0

release/10.0
dailer 3 years ago
parent
commit
2cf86e9eab
  1. 10
      package.json
  2. 3
      private/i18n.ts
  3. 12
      src/modules/app.model.ts
  4. 6
      src/modules/app.ts
  5. 57
      src/modules/constants/constant.ts
  6. 28
      src/modules/crud/api.ts
  7. 18
      src/modules/crud/crud.typings.d.ts
  8. 85
      src/modules/crud/decision.api.ts
  9. 38
      src/modules/crud/design.api.ts
  10. 36
      src/modules/pages/connection/connection.model.ts
  11. 57
      src/modules/pages/connection/connection.ts
  12. 31
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  13. 2
      src/modules/pages/connection/connection_jndi/connection_jndi.ts
  14. 4
      src/modules/pages/connection/list/list.model.ts
  15. 6
      src/modules/pages/connection/list/list.ts
  16. 76
      src/modules/pages/connection/list/list_item/list_item.model.ts
  17. 11
      src/modules/pages/connection/list/list_item/list_item.ts
  18. 37
      src/modules/pages/connection_pool/connection_pool.ts
  19. 126
      src/modules/pages/maintain/components/driverselector/driverselector.model.ts
  20. 182
      src/modules/pages/maintain/components/driverselector/driverselector.ts
  21. 161
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  22. 34
      src/modules/pages/maintain/forms/components/form.jndi.ts
  23. 12
      src/modules/pages/maintain/forms/components/form.plugin.ts
  24. 6
      src/modules/pages/maintain/forms/form.server.ts
  25. 61
      src/modules/pages/maintain/forms/form.ts
  26. 9021
      yarn.lock

10
package.json

@ -48,15 +48,14 @@
"source-map-loader": "0.2.4", "source-map-loader": "0.2.4",
"style-loader": "0.23.1", "style-loader": "0.23.1",
"ts-jest": "24.0.2", "ts-jest": "24.0.2",
"typescript": "3.5.1", "typescript": "^4.3.5",
"webpack": "4.35.2", "webpack": "4.35.2",
"webpack-cli": "3.3.5", "webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2", "webpack-dev-server": "3.7.2",
"webpack-merge": "4.2.1" "webpack-merge": "4.2.1"
}, },
"optionalDependencies": { "optionalDependencies": {
"@fui/core": "^2.0.0", "@fui/core": "^2.0.20210721103227"
"@fui/materials": "10.0.0-release - 10.0.0-release.99999999999999"
}, },
"scripts": { "scripts": {
"dev": "cross-env NODE_ENV=mock webpack-dev-server -p --progress --config=webpack/webpack.dev.js --mode development --open", "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", "i18n": "node ./lib/transform-i18n/transform-i18n.js",
"test": "jest --passWithNoTests", "test": "jest --passWithNoTests",
"upgrade": "node lib/upgrade" "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_Analytic_DB': '阿里云AnalyticDB',
'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围', 'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围',
'Dec-Dcm_Socket_Unable_Connect_Tip': '可能出现编辑冲突', '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 { export class AppModel extends Model {
static xtype = 'dec.dcm.model.main'; 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() { state() {
return { return {
@ -19,23 +19,27 @@ export class AppModel extends Model {
saveEvent: '', saveEvent: '',
testEvent: '', testEvent: '',
isCopy: false, isCopy: false,
connectionLicInfo: {
currentConnectionNum: 0,
maxConnectionNum: 0,
},
}; };
} }
computed = { computed = {
connectionSelectedOne: () => this.model.connections.find(item => item.connectionName === this.model.connectionSelected), connectionSelectedOne: () => this.model.connections.find(item => item.connectionName === this.model.connectionSelected),
datebaseTypeSelectedOne: () => getAllDatabaseTypes().find(item => item.databaseType === this.model.datebaseTypeSelected), datebaseTypeSelectedOne: () => getAllDatabaseTypes().find(item => item.databaseType === this.model.datebaseTypeSelected),
} };
actions = { actions = {
setPageIndex: (index: string) => { setPageIndex: (index: string) => {
this.model.pageIndex = index; this.model.pageIndex = index;
}, },
setFilter:(filter: string) => { setFilter: (filter: string) => {
this.model.filter = filter; this.model.filter = filter;
}, },
setDatebaseTypeSelected: (datebaseTypeSelected: string) => { setDatebaseTypeSelected: (datebaseTypeSelected: string) => {
this.model.datebaseTypeSelected = datebaseTypeSelected; this.model.datebaseTypeSelected = datebaseTypeSelected;
}, },
} };
} }

6
src/modules/app.ts

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

57
src/modules/constants/constant.ts

@ -19,17 +19,17 @@ export const DATEBASE_FILTER_TYPE = {
}; };
export const DATA_BASE_TYPES_OTHER = export const DATA_BASE_TYPES_OTHER =
{ {
text: OTHER_JDBC, text: OTHER_JDBC,
databaseType: OTHER_JDBC, databaseType: OTHER_JDBC,
driver: '', driver: '',
url: '', url: '',
commonly: false, commonly: false,
internal: false, internal: false,
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
}; };
export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [ export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [
{ {
databaseType: 'ads', databaseType: 'ads',
@ -45,7 +45,7 @@ export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [
}, },
{ {
databaseType: 'apache-kylin', databaseType: 'apache-kylin',
link: DecCst.Hyperlink.Database.PHOENIX, link: DecCst.Hyperlink.Database.KYLIN,
}, },
{ {
databaseType: 'apache-phoenix', databaseType: 'apache-phoenix',
@ -99,6 +99,10 @@ export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [
databaseType: 'hbase', databaseType: 'hbase',
link: DecCst.Hyperlink.Database.HBASE, link: DecCst.Hyperlink.Database.HBASE,
}, },
{
databaseType: 'hologres',
link: DecCst.Hyperlink.Database.HOLOGRES,
},
{ {
databaseType: 'hp-vertica', databaseType: 'hp-vertica',
link: DecCst.Hyperlink.Database.VERTICA, link: DecCst.Hyperlink.Database.VERTICA,
@ -400,6 +404,16 @@ export const DATA_BASE_TYPES = [
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: true, kerberos: true,
}, {
text: 'Hologres',
databaseType: 'hologres',
driver: 'org.postgresql.Driver',
url: 'jdbc:postgresql://hostname:port/database',
commonly: false,
internal: true,
type: 'jdbc',
hasSchema: true,
kerberos: false,
}, { }, {
text: 'HP Vertica', text: 'HP Vertica',
databaseType: 'hp-vertica', databaseType: 'hp-vertica',
@ -430,6 +444,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
fetchSize: 50,
}, { }, {
text: 'INFORMIX', text: 'INFORMIX',
databaseType: 'informix', databaseType: 'informix',
@ -507,6 +522,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
fetchSize: 128,
}, },
{ {
text: 'Pivotal Greenplum Database', text: 'Pivotal Greenplum Database',
@ -533,6 +549,18 @@ export const DATA_BASE_TYPES = [
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
fetchSize: 10000,
}, {
text: 'Tidb',
databaseType: 'tidb',
driver: 'com.mysql.jdbc.Driver',
drivers: ['com.mysql.jdbc.Driver'],
url: 'jdbc:mysql://hostname:port/database',
commonly: false,
internal: true,
type: 'jdbc',
hasSchema: false,
kerberos: false,
}, { }, {
text: 'Presto', text: 'Presto',
databaseType: 'presto', databaseType: 'presto',
@ -634,7 +662,6 @@ export const DATA_BASE_TYPES = [
]; ];
export const CONNECT_CHARSET = [ export const CONNECT_CHARSET = [
{ {
text: BI.i18nText('Dec-Dcm_Connection_Form_Default'), text: BI.i18nText('Dec-Dcm_Connection_Form_Default'),
@ -726,10 +753,10 @@ export const CONNECTION_LAYOUT = {
export const JNDI_FACTORYS = [ export const JNDI_FACTORYS = [
{ {
factory:'', factory: '',
url: '', url: '',
}, { }, {
factory:'weblogic.jndi.WLInitialContextFactory', factory: 'weblogic.jndi.WLInitialContextFactory',
url: 't3://localhost:7001', url: 't3://localhost:7001',
}, { }, {
factory: 'com.ibm.websphere.naming.WsnInitialContextFactory', factory: 'com.ibm.websphere.naming.WsnInitialContextFactory',

28
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 { export interface Api {
/** /**
@ -9,7 +16,12 @@ export interface Api {
/** /**
* *
*/ */
getConnectionlist(): Promise<{data?: Connection[]}>; getConnectionList(): Promise<{ data?: Connection[] }>;
/**
* lic限制信息
*/
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }>;
/** /**
* *
@ -38,7 +50,12 @@ export interface Api {
* *
* @param name * @param name
*/ */
getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}>; getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>;
/**
*
*/
getSimpleDriverList(): Promise<{ data?: any[] }>;
/** /**
* *
@ -67,6 +84,11 @@ export interface Api {
*/ */
getCipher(password: string): string; getCipher(password: string): string;
/**
*
*/
getPlain(cipher: string): string;
/** /**
* *
*/ */

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

@ -1,4 +1,3 @@
export interface CrudReqOpts { export interface CrudReqOpts {
url?: string; url?: string;
type?: 'GET' | 'POST' | 'DELETE' | 'PUT'; type?: 'GET' | 'POST' | 'DELETE' | 'PUT';
@ -23,7 +22,12 @@ export interface Connection {
privilegeDetailBeanList?: { privilegeDetailBeanList?: {
privilegeType: number; privilegeType: number;
privilegeValue: number; privilegeValue: number;
}[] }[];
}
export interface ConnectionLicInfo {
currentConnectionNum: number;
maxConnectionNum: number;
} }
export interface ConnectionJDBC { export interface ConnectionJDBC {
@ -83,7 +87,7 @@ export interface ConnectionJDBC {
/** /**
* *
*/ */
port?: number|''; port?: number | '';
/** /**
* *
*/ */
@ -104,6 +108,14 @@ export interface ConnectionJDBC {
* *
*/ */
keyPath?: string; keyPath?: string;
/**
* fetchSize
*/
fetchSize?: number;
/**
* id
*/
identity?: string;
connectionPoolAttr: ConnectionPoolJDBC; connectionPoolAttr: ConnectionPoolJDBC;
} }

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

@ -1,15 +1,19 @@
import { Api } from './api'; 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 { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent, errorCode } from '@constants/env'; 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', {});
} }
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
deleteConnection(connectionName: string) { deleteConnection(connectionName: string) {
return requestDelete('', { return requestDelete('', {
connectionName, connectionName,
@ -20,57 +24,66 @@ 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)}`, {});
} }
getSimpleDriverList(): Promise<{ data: any[] }> {
return new Promise(resolve => {
Dec.reqGet('/v10/drivers/simple/list', '', re => {
resolve(re);
});
});
}
getConnectionStatus(name: string): Promise<SocketResult> { getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => { return this.sendEditStatusEvent(name, editStatusEvent.OPEN)
if (re.errorCode) { .then(re => {
let errorMessage = ''; if (re.errorCode) {
switch (re.errorCode) { let errorMessage = '';
case errorCode.CONNECTION_DELETED: switch (re.errorCode) {
errorMessage = 'Dec-Dcm_Connection_Deleted'; case errorCode.CONNECTION_DELETED:
break; errorMessage = 'Dec-Dcm_Connection_Deleted';
case errorCode.CONNECTION_UNDER_EDIT: break;
errorMessage = 'Dec-Dcm_Connection_Is_Using'; case errorCode.CONNECTION_UNDER_EDIT:
break; errorMessage = 'Dec-Dcm_Connection_Is_Using';
default: break;
errorMessage = re.errorMsg; default:
break; 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> { shutdownConnectionStatus(name: string): Promise<SocketResult> {
@ -81,7 +94,7 @@ export class DecisionApi implements Api {
if (Dec) { if (Dec) {
return Dec.socket.connected; return Dec.socket.connected;
} }
return false; return false;
} }
@ -89,12 +102,18 @@ 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;
} }
getCipher(password: string) { 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);
} }
getHyperlink(name: string) { getHyperlink(name: string) {

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

@ -1,29 +1,34 @@
import { Api } from './api'; 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: 此页面的接口等待设计器提供相应的方法 // TODO: 此页面的接口等待设计器提供相应的方法
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}> { getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
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 +39,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 +79,11 @@ export class DesignApi implements Api {
return password; return password;
} }
getPlain(cipher: string) {
// 设计器解密方法
return cipher;
}
getHyperlink(name: string) { getHyperlink(name: string) {
// 设计器获取超链 // 设计器获取超链
return ''; return '';

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

@ -1,24 +1,49 @@
import { model, Model } from '@core/core'; import { model, Model } from '@core/core';
import { AppModel } from '../../app.model'; import { AppModel } from '../../app.model';
import { ApiFactory } from 'src/modules/crud/apiFactory'; import { ApiFactory } from 'src/modules/crud/apiFactory';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@model() @model()
export class ConnectionModel extends Model<{ export class ConnectionModel extends Model<{
types : { types: {
pageIndex: AppModel['TYPE']['pageIndex']; pageIndex: AppModel['TYPE']['pageIndex'];
connections: AppModel['TYPE']['connections']; connections: AppModel['TYPE']['connections'];
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
}, },
childContext: ConnectionModel['childContext'];
context: ConnectionModel['context']; context: ConnectionModel['context'];
}> { }> {
static xtype = 'dec.dcm.model.connection'; static xtype = 'dec.dcm.model.connection';
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected']; context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo'];
actions = { 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; this.model.pageIndex = index;
}, },
setDatebaseTypeSelected(name: string) { setDatebaseTypeSelected(name: string) {
@ -30,5 +55,8 @@ export class ConnectionModel extends Model<{
getConnectionStatus() { getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected); return api.getConnectionStatus(this.model.connectionSelected);
}, },
} checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
},
};
} }

57
src/modules/pages/connection/connection.ts

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

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

@ -6,6 +6,10 @@ import { ConnectionJDBC } from 'src/modules/crud/crud.typings';
import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../app.service'; import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../app.service';
import { CONNECTION_LAYOUT } from '@constants/constant'; import { CONNECTION_LAYOUT } from '@constants/constant';
import { VerticalLayout } from '@fui/core'; import { VerticalLayout } from '@fui/core';
import { ApiFactory } from '../../../crud/apiFactory';
const api = new ApiFactory().create();
@shortcut() @shortcut()
@store(ConnectionJdecModel) @store(ConnectionJdecModel)
export class ConnectionJdbc extends BI.Widget { export class ConnectionJdbc extends BI.Widget {
@ -15,13 +19,25 @@ export class ConnectionJdbc extends BI.Widget {
model: ConnectionJdecModel['model']; model: ConnectionJdecModel['model'];
allDatabaseTypes = getAllDatabaseTypes(); allDatabaseTypes = getAllDatabaseTypes();
render () { render() {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; 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 databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName } = resolveUrlInfo(url, database); const { host, port, databaseName } = resolveUrlInfo(url, database);
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
return { return {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
hgap, hgap,
@ -30,7 +46,7 @@ export class ConnectionJdbc extends BI.Widget {
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: driver, value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -132,7 +148,7 @@ export class ConnectionJdbc extends BI.Widget {
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Validation_Query'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Validation_Query'),
value: connectionPoolAttr.validationQuery, value: api.getPlain(connectionPoolAttr.validationQuery || ''),
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -165,6 +181,11 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'),
value: connectionPoolAttr.minEvictableIdleTimeMillis, value: connectionPoolAttr.minEvictableIdleTimeMillis,
unit: BI.i18nText('BI-Basic_Seconds'), 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/connection_jndi/connection_jndi.ts

@ -19,7 +19,7 @@ export class ConnectionJndi extends BI.Widget {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJNDI; const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJNDI;
const { jndiName, contextHashtable, originalCharsetName } = connectionData; const { jndiName, contextHashtable, originalCharsetName } = connectionData;
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
return { return {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
$testId: 'dec-dcm-connection-jndi', $testId: 'dec-dcm-connection-jndi',

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

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

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

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

76
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 { ResultType } from '../../../../crud/crud.typings';
import { getChartLength } from '../../../../app.service'; import { getChartLength } from '../../../../app.service';
import { NAME_MAX_LENGTH } from '../../../../app.constant'; import { NAME_MAX_LENGTH } from '../../../../app.constant';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@model() @model()
export class ListItemModel extends Model<{ export class ListItemModel extends Model<{
types : { types: {
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne'];
@ -21,7 +23,7 @@ export class ListItemModel extends Model<{
}> { }> {
static xtype = 'dec.dcm.model.connection.list_item'; 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() { state() {
return { return {
@ -52,10 +54,12 @@ export class ListItemModel extends Model<{
}, },
setIsEdit: (isEdit: boolean, name: string) => { setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) { if (isEdit) {
api.getConnectionStatus(name).then(re => { api.getConnectionStatus(name)
this.model.isEdit = true; .then(re => {
}) this.model.isEdit = true;
.catch(() => {}); })
.catch(() => {
});
} else { } else {
api.shutdownConnectionStatus(name); api.shutdownConnectionStatus(name);
this.model.isEdit = false; this.model.isEdit = false;
@ -69,7 +73,10 @@ export class ListItemModel extends Model<{
} }
if (getChartLength(newName) > NAME_MAX_LENGTH) { if (getChartLength(newName) > NAME_MAX_LENGTH) {
return new Promise(resolve => { 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); const hasNamed = this.model.connections.some(item => item.connectionName === newName);
@ -82,31 +89,50 @@ export class ListItemModel extends Model<{
connection.connectionId = oldName; connection.connectionId = oldName;
connection.connectionName = newName; connection.connectionName = newName;
return api.updateConnection(connection).then(re => { return api.updateConnection(connection)
if (!re.errorCode) { .then(re => {
this.model.connections = this.model.connections.map(item => { if (!re.errorCode) {
return { this.model.connections = this.model.connections.map(item => {
...item, return {
connectionName: item.connectionName === oldName ? newName : item.connectionName, ...item,
connectionId: item.connectionName === oldName ? newName : item.connectionName, connectionName: item.connectionName === oldName ? newName : item.connectionName,
}; connectionId: item.connectionName === oldName ? newName : item.connectionName,
}); };
if (this.model.connectionSelected === oldName) { });
this.model.connectionSelected = newName; 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) => { setIsCopy: (isCopy: boolean) => {
this.model.isCopy = isCopy; this.model.isCopy = isCopy;
}, },
isDriverError: (errorCode: string) => api.isDriverError(errorCode), isDriverError: (errorCode: string) => api.isDriverError(errorCode),
} };
removeConnection(name: string) { 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 => { .then(connections => {
this.model.connections = connections.data; this.model.connections = connections.data;
this.model.connections.forEach(item => { 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, height: 25,
baseCls: 'dec-dcm-connection-list-item bi-list-item-active2', baseCls: 'dec-dcm-connection-list-item bi-list-item-active2',
$testId: 'dec-dcm-connection-list-item', $testId: 'dec-dcm-connection-list-item',
} };
store: ListItemModel['store']; store: ListItemModel['store'];
model: ListItemModel['model']; model: ListItemModel['model'];
@ -36,7 +36,7 @@ export class ListItem extends BI.BasicButton {
this.nameEditor.focus(); this.nameEditor.focus();
} }
}, },
} };
render() { render() {
const { name, databaseType } = this.options; const { name, databaseType } = this.options;
@ -220,15 +220,14 @@ export class ListItem extends BI.BasicButton {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected(''); this.store.setDatebaseTypeSelected('');
}) })
.catch(() => { }); .catch(() => {
});
}, },
changeName: () => { changeName: () => {
this.store.setIsEdit(true, name); this.store.setIsEdit(true, name);
}, },
copy: () => { copy: () => {
this.store.setConnectionSelected(name); this.store.copyConnection(name);
this.store.setIsCopy(true);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
}, },
delete: () => { delete: () => {
this.store.deleteConnection(name); this.store.deleteConnection(name);

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

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

@ -0,0 +1,182 @@
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;
watch = {
driverClassItems: items => {
// this.customDrivers.populate(items);
// this.customDrivers.setValue(this.model.customDriver.value);
},
driverManageEntryVisible: b => {
this.driverManageEntry.setVisible(false);
},
};
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,
invisible: true,
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: 300,
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: true,
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: true,
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,
};
}
}

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

@ -7,7 +7,17 @@ import { CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE } from
import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service'; import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service';
import { TextChecker } from '../../../../components/text_checker/text_checker'; import { TextChecker } from '../../../../components/text_checker/text_checker';
import { ApiFactory } from 'src/modules/crud/apiFactory'; import { ApiFactory } from 'src/modules/crud/apiFactory';
import { Editor, EditorIconCheckCombo, Label, TextAreaEditor, TextEditor, TextValueCombo, VerticalLayout } from '@fui/core'; import {
Editor,
EditorIconCheckCombo,
Label,
TextAreaEditor,
TextEditor,
TextValueCombo,
VerticalLayout,
} from '@fui/core';
import { DriverSelector } from '../../components/driverselector/driverselector';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@shortcut() @shortcut()
@ -16,7 +26,7 @@ export class FormJdbc extends BI.Widget {
props = { props = {
formData: {} as Connection, formData: {} as Connection,
} };
oldPassword = ''; oldPassword = '';
allDatabaseTypes = getAllDatabaseTypes(); allDatabaseTypes = getAllDatabaseTypes();
@ -54,23 +64,51 @@ export class FormJdbc extends BI.Widget {
numTestsPerEvictionRun: null, numTestsPerEvictionRun: null,
minIdle: null, minIdle: null,
minEvictableIdleTimeMillis: null, minEvictableIdleTimeMillis: null,
fetchSize: null,
}; };
render() { render() {
const { connectionName, connectionData } = this.options.formData; const { connectionName, connectionData } = this.options.formData;
const { driver, user, password, originalCharsetName, schema, url, connectionPoolAttr, database, authType, principal, keyPath } = connectionData as ConnectionJDBC; const {
const { initialSize, maxActive, maxIdle, maxWait, validationQuery, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minIdle, minEvictableIdleTimeMillis } = connectionPoolAttr as ConnectionPoolJDBC; driver,
driverSource,
user,
password,
originalCharsetName,
schema,
url,
connectionPoolAttr,
database,
authType,
principal,
keyPath,
fetchSize,
} = connectionData as ConnectionJDBC;
const {
initialSize,
maxActive,
maxIdle,
maxWait,
validationQuery,
testOnBorrow,
testOnReturn,
testWhileIdle,
timeBetweenEvictionRunsMillis,
numTestsPerEvictionRun,
minIdle,
minEvictableIdleTimeMillis,
} = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
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,
@ -94,31 +132,34 @@ export class FormJdbc extends BI.Widget {
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
forms: [{ forms: [
type: BI.EditorIconCheckCombo.xtype, {
$testId: 'dec-editor-icon-check-combo', type: DriverSelector.xtype,
$value: 'driver', ref: (_ref: DriverSelector) => {
width: 300, this.form.driver = _ref;
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);
}, },
}], 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, type: FormItem.xtype,
@ -360,7 +401,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 +578,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) => {
@ -547,7 +588,7 @@ export class FormJdbc extends BI.Widget {
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'),
forms: [{ forms: [{
type: BI.TextValueCombo.xtype, type: BI.TextValueCombo.xtype,
$value: 'check', $value: 'check',
@ -555,7 +596,7 @@ export class FormJdbc extends BI.Widget {
allowBlank: true, allowBlank: true,
value: testOnBorrow, value: testOnBorrow,
items: this.getBooleanItem(), items: this.getBooleanItem(),
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'), watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'),
ref: (_ref: TextValueCombo) => { ref: (_ref: TextValueCombo) => {
this.form.testOnBorrow = _ref; this.form.testOnBorrow = _ref;
}, },
@ -668,6 +709,37 @@ export class FormJdbc extends BI.Widget {
text: BI.i18nText('BI-Basic_Seconds'), 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,
},
],
},
}, },
], ],
}, },
@ -715,7 +787,7 @@ export class FormJdbc extends BI.Widget {
...drivers, ...drivers,
]; ];
} }
return drivers; return drivers;
} }
@ -735,7 +807,7 @@ export class FormJdbc extends BI.Widget {
private onHostPortChange(databaseType) { private onHostPortChange(databaseType) {
const { urls, url } = databaseType; const { urls, url } = databaseType;
const driver = this.form.driver.getValue(); 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 host = this.form.host.getValue();
const port = this.form.port.getValue(); const port = this.form.port.getValue();
const database = this.form.database.getValue(); const database = this.form.database.getValue();
@ -756,20 +828,24 @@ export class FormJdbc extends BI.Widget {
} }
} }
public getSubmitValue():Connection { public validation(): boolean {
return this.form.driver.validation();
}
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(),
connectionName: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(),
connectionData: { connectionData: <ConnectionJDBC>BI.extend({}, connectionData, {
database: connectionData.database, database: connectionData.database,
connectionName: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(),
driver: this.form.driver.getValue(), ...this.form.driver.getValue(),
url: this.form.url.getValue(), url: this.form.url.getValue(),
user: this.form.user.getValue(), user: this.form.user.getValue(),
password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()), password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()),
@ -782,13 +858,14 @@ export class FormJdbc extends BI.Widget {
creator: Dec ? Dec.personal.username : '', creator: Dec ? Dec.personal.username : '',
principal: this.form.principal.getValue(), principal: this.form.principal.getValue(),
keyPath: this.form.keyPath.getValue(), keyPath: this.form.keyPath.getValue(),
fetchSize: BI.isEmptyString(this.form.fetchSize.getValue()) ? -2 : BI.parseInt(this.form.fetchSize.getValue()),
connectionPoolAttr: { connectionPoolAttr: {
initialSize: this.form.initialSize.getValue(), initialSize: this.form.initialSize.getValue(),
maxActive: this.form.maxActive.getValue(), maxActive: this.form.maxActive.getValue(),
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,
@ -796,7 +873,7 @@ export class FormJdbc extends BI.Widget {
numTestsPerEvictionRun: this.form.numTestsPerEvictionRun.getValue(), numTestsPerEvictionRun: this.form.numTestsPerEvictionRun.getValue(),
minEvictableIdleTimeMillis: this.form.minEvictableIdleTimeMillis.getValue(), minEvictableIdleTimeMillis: this.form.minEvictableIdleTimeMillis.getValue(),
}, },
}, }),
}; };
} }
} }

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

@ -1,11 +1,11 @@
import { shortcut } from '@core/core'; import {shortcut} from '@core/core';
import { FormItem } from '../../components/form_item/form_item'; import {FormItem} from '../../components/form_item/form_item';
import { ConnectionJNDI, Connection, ContextHashtable } from 'src/modules/crud/crud.typings'; import {ConnectionJNDI, Connection, ContextHashtable} from 'src/modules/crud/crud.typings';
import { CONNECT_CHARSET, CONNECTION_LAYOUT, JNDI_FACTORYS } from '@constants/constant'; import {CONNECT_CHARSET, CONNECTION_LAYOUT, JNDI_FACTORYS} from '@constants/constant';
import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse';
import { connectionType } from '@constants/env'; import {connectionType} from '@constants/env';
import { TextChecker } from '../../../../components/text_checker/text_checker'; import {TextChecker} from '../../../../components/text_checker/text_checker';
import { EditorIconCheckCombo, TextEditor, TextValueCombo, VerticalLayout } from '@fui/core'; import {EditorIconCheckCombo, TextEditor, TextValueCombo, VerticalLayout} from '@fui/core';
@shortcut() @shortcut()
export class FormJndi extends BI.Widget { export class FormJndi extends BI.Widget {
@ -37,9 +37,9 @@ export class FormJndi extends BI.Widget {
} }
render() { render() {
const { connectionName, connectionData } = this.options.formData; const {connectionName, connectionData} = this.options.formData;
const { jndiName, newCharsetName, contextHashtable } = connectionData as ConnectionJNDI; const {jndiName, newCharsetName, contextHashtable} = connectionData as ConnectionJNDI;
const { hgap, vgap } = CONNECTION_LAYOUT; const {hgap, vgap} = CONNECTION_LAYOUT;
return { return {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
@ -193,7 +193,7 @@ export class FormJndi extends BI.Widget {
nameWidth: 200, nameWidth: 200,
forms: [{ forms: [{
type: BI.TextValueCombo.xtype, type: BI.TextValueCombo.xtype,
$value: 'new-charset-name', $value: 'original-charset-name',
width: 300, width: 300,
value: newCharsetName ? newCharsetName : '', value: newCharsetName ? newCharsetName : '',
items: CONNECT_CHARSET, items: CONNECT_CHARSET,
@ -399,7 +399,9 @@ export class FormJndi extends BI.Widget {
this.form.connectionName.setError(value); this.form.connectionName.setError(value);
} }
public getSubmitValue():Connection { public getSubmitValue(): Connection {
const connectionData = this.options.formData.connectionData as ConnectionJNDI;
const contextHashtable = { const contextHashtable = {
'java.naming.factory.initial': this.form.initial.getValue(), 'java.naming.factory.initial': this.form.initial.getValue(),
'java.naming.provider.url': this.form.providerUrl.getValue(), 'java.naming.provider.url': this.form.providerUrl.getValue(),
@ -423,18 +425,18 @@ export class FormJndi extends BI.Widget {
delete contextHashtable[propName]; delete contextHashtable[propName];
} }
} }
return { return {
connectionId: this.form.connectionName.getValue(), connectionId: this.form.connectionName.getValue(),
connectionName: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(),
connectionType: connectionType.JNDI, connectionType: connectionType.JNDI,
connectionData: { connectionData: <ConnectionJNDI>BI.extend({}, connectionData, {
jndiName: this.form.jndiName.getValue(), jndiName: this.form.jndiName.getValue(),
newCharsetName: this.form.newCharsetName.getValue()[0] || '', newCharsetName: this.form.newCharsetName.getValue()[0] || '',
originalCharsetName: this.form.newCharsetName.getValue()[0] || '', originalCharsetName: this.form.newCharsetName.getValue()[0] || '',
creator: Dec ? Dec.personal.username : '', creator: Dec ? Dec.personal.username : '',
contextHashtable: contextHashtable as ContextHashtable, contextHashtable: contextHashtable as ContextHashtable,
}, }),
}; };
} }
} }

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

@ -1,13 +1,13 @@
import {shortcut} from '@core/core'; import { shortcut } from '@core/core';
import {Connection} from 'src/modules/crud/crud.typings'; import { Connection, ConnectionPlugin } 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';
props = { props = {
formData: {} as Connection, formData: {} as Connection,
} };
plugin: any; plugin: any;
@ -28,13 +28,13 @@ export class FormPlugin extends BI.Widget {
} }
public getSubmitValue(): Connection { public getSubmitValue(): Connection {
const { connectionType, connectionId, connectionName } = this.options.formData; const { connectionType, connectionId, connectionName, connectionData } = this.options.formData;
return { return {
connectionId, connectionId,
connectionType, connectionType,
connectionName: this.plugin.getConnectionName ? this.plugin.getConnectionName() : connectionName, connectionName: this.plugin.getConnectionName ? this.plugin.getConnectionName() : connectionName,
connectionData: this.plugin.getValue(), connectionData: <ConnectionPlugin>BI.extend({}, 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) => {

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

@ -16,10 +16,10 @@ export class MaintainForm extends BI.Widget {
props = { props = {
connectionType: '', connectionType: '',
} };
isEdit = false; isEdit = false;
connectionName = ''; connectionName = '';
model: MaintainFormModel['model']; model: MaintainFormModel['model'];
store: MaintainFormModel['store']; store: MaintainFormModel['store'];
@ -39,7 +39,7 @@ export class MaintainForm extends BI.Widget {
this.store.updateConnection(this.connectionName, value).then(result => { this.store.updateConnection(this.connectionName, value).then(result => {
if (result.errorCode) { if (result.errorCode) {
this.showError(result); this.showError(result);
return; return;
} }
this.store.goFirstPage(); this.store.goFirstPage();
@ -55,7 +55,7 @@ export class MaintainForm extends BI.Widget {
testEvent: () => { testEvent: () => {
this.testConnection(); this.testConnection();
}, },
} };
render() { render() {
const formData = BI.clone(this.getFormData()); const formData = BI.clone(this.getFormData());
@ -63,7 +63,7 @@ export class MaintainForm extends BI.Widget {
formData.connectionName = this.getConnectionName(formData.connectionName); formData.connectionName = this.getConnectionName(formData.connectionName);
this.isEdit = false; this.isEdit = false;
} }
return { return {
type: this.getFormType(), type: this.getFormType(),
formData, formData,
@ -98,7 +98,7 @@ export class MaintainForm extends BI.Widget {
} }
} }
private getFormData():Connection { private getFormData(): Connection {
switch (this.options.connectionType) { switch (this.options.connectionType) {
case connectionType.JDBC: case connectionType.JDBC:
return this.getJdbcConnection(); return this.getJdbcConnection();
@ -111,7 +111,7 @@ export class MaintainForm extends BI.Widget {
} }
} }
private getJdbcConnection():Connection { private getJdbcConnection(): Connection {
const connectionName = this.getConnectionName(); const connectionName = this.getConnectionName();
let editConnection: Connection; let editConnection: Connection;
let connectionData: ConnectionJDBC; let connectionData: ConnectionJDBC;
@ -122,8 +122,10 @@ export class MaintainForm extends BI.Widget {
database: this.model.datebaseTypeSelectedOne.databaseType, database: this.model.datebaseTypeSelectedOne.databaseType,
connectionName, connectionName,
connectionPoolAttr: DEFAULT_JDBC_POOL, connectionPoolAttr: DEFAULT_JDBC_POOL,
port:'', port: '',
host: 'localhost', host: 'localhost',
fetchSize: this.model.datebaseTypeSelectedOne.fetchSize ?? -1,
identity: BI.UUID(),
}; };
editConnection = { editConnection = {
connectionId: '', connectionId: '',
@ -131,7 +133,7 @@ export class MaintainForm extends BI.Widget {
connectionType: connectionType.JDBC, connectionType: connectionType.JDBC,
connectionName, connectionName,
}; };
return editConnection; return editConnection;
} }
this.isEdit = true; this.isEdit = true;
@ -139,11 +141,11 @@ export class MaintainForm extends BI.Widget {
const connection = BI.clone(this.model.connectionSelectedOne); const connection = BI.clone(this.model.connectionSelectedOne);
const { database, driver } = connection.connectionData as ConnectionJDBC; const { database, driver } = connection.connectionData as ConnectionJDBC;
(connection.connectionData as ConnectionJDBC).database = getJdbcDatabaseType(database, driver).databaseType; (connection.connectionData as ConnectionJDBC).database = getJdbcDatabaseType(database, driver).databaseType;
return connection; return connection;
} }
private getJndiConnection():Connection { private getJndiConnection(): Connection {
if (this.model.datebaseTypeSelected) { if (this.model.datebaseTypeSelected) {
return { return {
connectionId: '', connectionId: '',
@ -154,18 +156,18 @@ export class MaintainForm extends BI.Widget {
} }
this.connectionName = this.model.connectionSelectedOne.connectionName; this.connectionName = this.model.connectionSelectedOne.connectionName;
this.isEdit = true; this.isEdit = true;
return this.model.connectionSelectedOne; return this.model.connectionSelectedOne;
} }
private getPluginConnection():Connection { private getPluginConnection(): Connection {
if (!this.model.datebaseTypeSelected) { if (!this.model.datebaseTypeSelected) {
this.connectionName = this.model.connectionSelectedOne.connectionName; this.connectionName = this.model.connectionSelectedOne.connectionName;
this.isEdit = true; this.isEdit = true;
return this.model.connectionSelectedOne; return this.model.connectionSelectedOne;
} }
return { return {
connectionId: '', connectionId: '',
connectionType: this.model.datebaseTypeSelectedOne.databaseType, connectionType: this.model.datebaseTypeSelectedOne.databaseType,
@ -174,27 +176,31 @@ export class MaintainForm extends BI.Widget {
}; };
} }
private testValue():boolean { private testValue(): boolean {
const value = this.form.getSubmitValue(); const value = this.form.getSubmitValue();
if (!value.connectionName) { if (!value.connectionName) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'));
return false; return false;
} }
if (this.connectionName !== value.connectionName) { if (this.connectionName !== value.connectionName) {
const hasNamed = this.model.connections.some(item => item.connectionName === value.connectionName); const hasNamed = this.model.connections.some(item => item.connectionName === value.connectionName);
if (hasNamed) { if (hasNamed) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_Is_Existence')); this.setFromError(BI.i18nText('Dec-Dcm_Connection_Is_Existence'));
return false; return false;
} }
} }
if (getChartLength(value.connectionName) > NAME_MAX_LENGTH) { if (getChartLength(value.connectionName) > NAME_MAX_LENGTH) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH)); this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH));
return false; return false;
} }
if (this.form.validation && !this.form.validation()) {
return false;
}
return true; return true;
} }
@ -204,7 +210,7 @@ export class MaintainForm extends BI.Widget {
BI.Msg.toast(BI.i18nText(result.errorMsg), { BI.Msg.toast(BI.i18nText(result.errorMsg), {
level: 'error', level: 'error',
}); });
return; return;
} }
@ -220,14 +226,19 @@ export class MaintainForm extends BI.Widget {
const formValue = this.form.getSubmitValue(); const formValue = this.form.getSubmitValue();
if (!formValue.connectionName) { if (!formValue.connectionName) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'));
return; return false;
} }
if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) { if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', 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; return false;
} }
if (this.isEdit || this.model.isCopy) { if (this.isEdit || this.model.isCopy) {
formValue.connectionId = this.connectionName; formValue.connectionId = this.connectionName;
} }
@ -256,7 +267,7 @@ export class MaintainForm extends BI.Widget {
level: 'error', level: 'error',
}); });
} }
return; return;
} }
this.store.goFirstPage(); this.store.goFirstPage();

9021
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save