Browse Source

DEC-19867 feat: 数据lic受限连接出错提示-前端

feature/10.0
dailer 3 years ago
parent
commit
ea728d46f8
  1. 1
      private/i18n.ts
  2. 12
      src/modules/constants/constant.ts
  3. 4
      src/modules/crud/crud.typings.d.ts
  4. 2
      src/modules/pages/connection/connection.model.ts
  5. 19
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  6. 42
      src/modules/pages/connection/list/list_item/list_item.model.ts
  7. 69
      src/modules/pages/maintain/forms/components/form.jdbc.ts

1
private/i18n.ts

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

12
src/modules/constants/constant.ts

@ -19,7 +19,7 @@ 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: '',
@ -29,7 +29,7 @@ export const DATA_BASE_TYPES_OTHER =
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',
@ -444,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',
@ -521,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',
@ -547,6 +549,7 @@ export const DATA_BASE_TYPES = [
type: 'jdbc', type: 'jdbc',
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
fetchSize: 10000,
}, { }, {
text: 'Presto', text: 'Presto',
databaseType: 'presto', databaseType: 'presto',
@ -648,7 +651,6 @@ export const DATA_BASE_TYPES = [
]; ];
export const CONNECT_CHARSET = [ export const CONNECT_CHARSET = [
{ {
text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'), text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'),
@ -740,10 +742,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',

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

@ -108,6 +108,10 @@ export interface ConnectionJDBC {
* *
*/ */
keyPath?: string; keyPath?: string;
/**
* fetchSize
*/
fetchSize?: string;
connectionPoolAttr: ConnectionPoolJDBC; connectionPoolAttr: ConnectionPoolJDBC;
} }

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

@ -30,7 +30,7 @@ export class ConnectionModel extends Model<{
childContext: ['connectionLicInfo']; childContext: ['connectionLicInfo'];
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo']; context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected'];
actions = { actions = {
initConnectionLicInfo: (cb: Function) => { initConnectionLicInfo: (cb: Function) => {

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

@ -19,9 +19,20 @@ 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,
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;
@ -169,6 +180,10 @@ 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,
name: 'Fetchsize',
value: fetchSize,
}, },
], ],
}, },

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

@ -4,13 +4,11 @@ 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'];
@ -23,7 +21,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', 'connectionLicInfo']; context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy'];
state() { state() {
return { return {
@ -54,12 +52,10 @@ export class ListItemModel extends Model<{
}, },
setIsEdit: (isEdit: boolean, name: string) => { setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) { if (isEdit) {
api.getConnectionStatus(name) api.getConnectionStatus(name).then(re => {
.then(re => {
this.model.isEdit = true; this.model.isEdit = true;
}) })
.catch(() => { .catch(() => {});
});
} else { } else {
api.shutdownConnectionStatus(name); api.shutdownConnectionStatus(name);
this.model.isEdit = false; this.model.isEdit = false;
@ -73,10 +69,7 @@ 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({ resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) });
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);
@ -90,8 +83,7 @@ export class ListItemModel extends Model<{
connection.connectionName = newName; connection.connectionName = newName;
return api.updateConnection(connection) return api.updateConnection(connection).then(re => {
.then(re => {
if (!re.errorCode) { if (!re.errorCode) {
this.model.connections = this.model.connections.map(item => { this.model.connections = this.model.connections.map(item => {
return { return {
@ -108,31 +100,13 @@ export class ListItemModel extends Model<{
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) api.deleteConnection(name).then(re => api.getConnectionList())
.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 => {

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

@ -1,12 +1,12 @@
import {shortcut} from '@core/core'; import { shortcut } from '@core/core';
import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse'; import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import {FormItem} from '../../components/form_item/form_item'; import { FormItem } from '../../components/form_item/form_item';
import {Connection, ConnectionJDBC, ConnectionPoolJDBC} from 'src/modules/crud/crud.typings'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings';
import {connectionType} from '@constants/env'; import { connectionType } from '@constants/env';
import {CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE} from '@constants/constant'; import { CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE } from '@constants/constant';
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 { import {
Editor, Editor,
EditorIconCheckCombo, EditorIconCheckCombo,
@ -14,7 +14,7 @@ import {
TextAreaEditor, TextAreaEditor,
TextEditor, TextEditor,
TextValueCombo, TextValueCombo,
VerticalLayout VerticalLayout,
} from '@fui/core'; } from '@fui/core';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@ -25,7 +25,7 @@ export class FormJdbc extends BI.Widget {
props = { props = {
formData: {} as Connection, formData: {} as Connection,
} };
oldPassword = ''; oldPassword = '';
allDatabaseTypes = getAllDatabaseTypes(); allDatabaseTypes = getAllDatabaseTypes();
@ -63,10 +63,11 @@ 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 { const {
driver, driver,
user, user,
@ -78,7 +79,8 @@ export class FormJdbc extends BI.Widget {
database, database,
authType, authType,
principal, principal,
keyPath keyPath,
fetchSize,
} = connectionData as ConnectionJDBC; } = connectionData as ConnectionJDBC;
const { const {
initialSize, initialSize,
@ -92,12 +94,12 @@ export class FormJdbc extends BI.Widget {
timeBetweenEvictionRunsMillis, timeBetweenEvictionRunsMillis,
numTestsPerEvictionRun, numTestsPerEvictionRun,
minIdle, minIdle,
minEvictableIdleTimeMillis minEvictableIdleTimeMillis,
} = connectionPoolAttr as ConnectionPoolJDBC; } = 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'),
@ -394,7 +396,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;
}, },
@ -702,6 +704,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: 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,
},
],
},
}, },
], ],
}, },
@ -767,7 +800,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) || url;
const host = this.form.host.getValue(); const host = this.form.host.getValue();

Loading…
Cancel
Save