Browse Source

Pull request #2535: DEC-19867 && DEC-19762

Merge in DEC/decision-webui-dcm from ~DAILER/decision-webui-dcm:feature/10.0 to feature/10.0

* commit 'a8bba76fe9b6cb05b6da36d3d4ce94a8ee9ae3d2':
  DEC-19762 feat: 【FR配合】部分数据连接支持fetchsize
  DEC-19867 feat: 数据lic受限连接出错提示-前端
  DEC-19867 feat: 数据lic受限连接出错提示-前端
feature/10.0
Dailer 3 years ago
parent
commit
67d53531c5
  1. 3
      private/i18n.ts
  2. 4
      src/modules/constants/constant.ts
  3. 16
      src/modules/crud/api.ts
  4. 9
      src/modules/crud/crud.typings.d.ts
  5. 17
      src/modules/crud/decision.api.ts
  6. 9
      src/modules/crud/design.api.ts
  7. 41
      src/modules/pages/connection/connection.model.ts
  8. 12
      src/modules/pages/connection/connection.ts
  9. 17
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  10. 2
      src/modules/pages/connection/list/list.model.ts
  11. 4
      src/modules/pages/connection/list/list.ts
  12. 40
      src/modules/pages/connection/list/list_item/list_item.model.ts
  13. 11
      src/modules/pages/connection/list/list_item/list_item.ts
  14. 11
      src/modules/pages/connection_pool/connection_pool.ts
  15. 42
      src/modules/pages/maintain/forms/components/form.jdbc.ts

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之间的值',
};

4
src/modules/constants/constant.ts

@ -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'),

16
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 }>;
/**
*

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

@ -25,6 +25,11 @@ export interface Connection {
}[]
}
export interface ConnectionLicInfo {
currentConnectionNum: number;
maxConnectionNum: number
}
export interface ConnectionJDBC {
/**
*
@ -103,6 +108,10 @@ export interface ConnectionJDBC {
*
*/
keyPath?: string;
/**
* fetchSize
*/
fetchSize?: string;
connectionPoolAttr: ConnectionPoolJDBC;
}

17
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,
@ -49,7 +53,8 @@ export class DecisionApi implements Api {
}
getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN)
.then(re => {
if (re.errorCode) {
let errorMessage = '';
switch (re.errorCode) {
@ -94,11 +99,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' });

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

@ -1,7 +1,10 @@
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: {
@ -11,13 +14,46 @@ export class ConnectionModel extends Model<{
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
},
childContext: ConnectionModel['childContext'];
context: ConnectionModel['context'];
}> {
static xtype = 'dec.dcm.model.connection';
state() {
return {
connectionLicInfo: {
currentConnectionNum: 0,
maxConnectionNum: 0,
},
};
}
childContext: ['connectionLicInfo'];
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected'];
actions = {
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;
},
@ -30,5 +66,8 @@ export class ConnectionModel extends Model<{
getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected);
},
}
checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
},
};
}

12
src/modules/pages/connection/connection.ts

@ -43,6 +43,10 @@ export class Connection extends BI.Widget {
this.connectionEditWidget.setVisible(false);
}
},
};
beforeRender(cb: Function) {
this.store.initConnectionLicInfo(cb);
}
render() {
@ -66,7 +70,7 @@ export class Connection extends BI.Widget {
type: BI.Button.xtype,
text: BI.i18nText('Dec-Dcm_Connection_New'),
handler: () => {
this.store.setPageIndex(PAGE_INDEX.DATEBASE);
this.store.createNewConnection();
},
}],
},
@ -110,11 +114,13 @@ export class Connection extends BI.Widget {
this.connectionEditWidget = _ref;
},
handler: () => {
this.store.getConnectionStatus().then(re => {
this.store.getConnectionStatus()
.then(re => {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
})
.catch(() => {});
.catch(() => {
});
},
}],
},

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

@ -21,7 +21,18 @@ export class ConnectionJdbc extends BI.Widget {
render() {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { driver, database, user, originalCharsetName, schema, connectionPoolAttr, authType, principal, url } = connectionData;
const {
driver,
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;
@ -169,6 +180,10 @@ 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,
name: 'Fetchsize',
value: 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();
});

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

@ -4,6 +4,8 @@ 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()
@ -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 => {
api.getConnectionStatus(name)
.then(re => {
this.model.isEdit = true;
})
.catch(() => {});
.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,7 +90,8 @@ export class ListItemModel extends Model<{
connection.connectionName = newName;
return api.updateConnection(connection).then(re => {
return api.updateConnection(connection)
.then(re => {
if (!re.errorCode) {
this.model.connections = this.model.connections.map(item => {
return {
@ -100,13 +108,31 @@ export class ListItemModel extends Model<{
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);

11
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,17 +46,19 @@ export class ConnectionPool extends BI.Widget {
cls: 'bi-border-bottom',
textAlign: 'left',
text: BI.i18nText('Dec-Dcm_Data_Connections'),
lgap: 10,
},
height: 40,
},
{
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),
},
vgap: 10,
},
],
},
width: 275,
@ -117,7 +121,8 @@ 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 this.model.connectionJDBC.slice(start, end)
.map(item => {
return {
type: ListItem.xtype,
name: item.connectionName,

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

@ -14,7 +14,7 @@ import {
TextAreaEditor,
TextEditor,
TextValueCombo,
VerticalLayout
VerticalLayout,
} from '@fui/core';
const api = new ApiFactory().create();
@ -25,7 +25,7 @@ export class FormJdbc extends BI.Widget {
props = {
formData: {} as Connection,
}
};
oldPassword = '';
allDatabaseTypes = getAllDatabaseTypes();
@ -63,6 +63,7 @@ export class FormJdbc extends BI.Widget {
numTestsPerEvictionRun: null,
minIdle: null,
minEvictableIdleTimeMillis: null,
fetchSize: null,
};
render() {
@ -78,7 +79,8 @@ export class FormJdbc extends BI.Widget {
database,
authType,
principal,
keyPath
keyPath,
fetchSize,
} = connectionData as ConnectionJDBC;
const {
initialSize,
@ -92,7 +94,7 @@ export class FormJdbc extends BI.Widget {
timeBetweenEvictionRunsMillis,
numTestsPerEvictionRun,
minIdle,
minEvictableIdleTimeMillis
minEvictableIdleTimeMillis,
} = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver);
this.oldPassword = password;
@ -702,6 +704,37 @@ export class FormJdbc extends BI.Widget {
text: BI.i18nText('BI-Basic_Seconds'),
},
],
}, {
el: {
type: BI.VerticalLayout.xtype,
cls: 'bi-border-top',
invisible: BI.parseInt(fetchSize) < 0,
items: [
{
el: {
type: FormItem.xtype,
name: 'Fetchsize',
forms: [{
type: TextChecker.xtype,
$value: 'fetch-size',
width: 300,
allowBlank: true,
value: 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,
},
],
},
},
],
},
@ -816,6 +849,7 @@ export class FormJdbc extends BI.Widget {
creator: Dec ? Dec.personal.username : '',
principal: this.form.principal.getValue(),
keyPath: this.form.keyPath.getValue(),
fetchSize: this.form.fetchSize.getValue(),
connectionPoolAttr: {
initialSize: this.form.initialSize.getValue(),
maxActive: this.form.maxActive.getValue(),

Loading…
Cancel
Save