From d95efbd68be6320f5dfbffca3427d81c47ebac14 Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 22 Jul 2021 14:46:08 +0800 Subject: [PATCH 01/18] =?UTF-8?q?DEC-19867=20feat:=20=E6=95=B0=E6=8D=AElic?= =?UTF-8?q?=E5=8F=97=E9=99=90=E8=BF=9E=E6=8E=A5=E5=87=BA=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA-=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- private/i18n.ts | 2 + src/modules/app.model.ts | 2 +- src/modules/crud/api.ts | 16 +++- src/modules/crud/crud.typings.d.ts | 5 ++ src/modules/crud/decision.api.ts | 57 ++++++++------ src/modules/crud/design.api.ts | 9 ++- .../pages/connection/connection.model.ts | 47 +++++++++++- src/modules/pages/connection/connection.ts | 24 +++--- .../pages/connection/list/list.model.ts | 4 +- src/modules/pages/connection/list/list.ts | 6 +- .../list/list_item/list_item.model.ts | 76 +++++++++++++------ .../connection/list/list_item/list_item.ts | 11 ++- .../pages/connection_pool/connection_pool.ts | 37 +++++---- .../pages/maintain/forms/form.model.ts | 18 +++-- 14 files changed, 214 insertions(+), 100 deletions(-) diff --git a/private/i18n.ts b/private/i18n.ts index d105961..6d9294b 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -303,4 +303,6 @@ 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限制({}个),无法新增', }; diff --git a/src/modules/app.model.ts b/src/modules/app.model.ts index 8dd78a8..79b06f6 100644 --- a/src/modules/app.model.ts +++ b/src/modules/app.model.ts @@ -31,7 +31,7 @@ export class AppModel extends Model { setPageIndex: (index: string) => { this.model.pageIndex = index; }, - setFilter:(filter: string) => { + setFilter: (filter: string) => { this.model.filter = filter; }, setDatebaseTypeSelected: (datebaseTypeSelected: string) => { diff --git a/src/modules/crud/api.ts b/src/modules/crud/api.ts index 0122e48..1d917b8 100644 --- a/src/modules/crud/api.ts +++ b/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 }>; /** * 删除数据连接 diff --git a/src/modules/crud/crud.typings.d.ts b/src/modules/crud/crud.typings.d.ts index 84181fe..2d56028 100644 --- a/src/modules/crud/crud.typings.d.ts +++ b/src/modules/crud/crud.typings.d.ts @@ -25,6 +25,11 @@ export interface Connection { }[] } +export interface ConnectionLicInfo { + currentConnectionNum: number; + maxConnectionNum: number +} + export interface ConnectionJDBC { /** * 数据库名称 diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index 6c2f2a5..a15cd14 100644 --- a/src/modules/crud/decision.api.ts +++ b/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,28 +53,29 @@ export class DecisionApi implements Api { } getConnectionStatus(name: string): Promise { - return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => { - if (re.errorCode) { - let errorMessage = ''; - switch (re.errorCode) { - case errorCode.CONNECTION_DELETED: - errorMessage = 'Dec-Dcm_Connection_Deleted'; - break; - case errorCode.CONNECTION_UNDER_EDIT: - errorMessage = 'Dec-Dcm_Connection_Is_Using'; - break; - default: - errorMessage = re.errorMsg; - break; + return this.sendEditStatusEvent(name, editStatusEvent.OPEN) + .then(re => { + if (re.errorCode) { + let errorMessage = ''; + switch (re.errorCode) { + case errorCode.CONNECTION_DELETED: + errorMessage = 'Dec-Dcm_Connection_Deleted'; + break; + case errorCode.CONNECTION_UNDER_EDIT: + errorMessage = 'Dec-Dcm_Connection_Is_Using'; + break; + default: + errorMessage = re.errorMsg; + break; + } + BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), { + level: 'error', + }); + throw re; + } else { + return re; } - BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), { - level: 'error', - }); - throw re; - } else { - return re; - } - }); + }); } shutdownConnectionStatus(name: string): Promise { @@ -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) { diff --git a/src/modules/crud/design.api.ts b/src/modules/crud/design.api.ts index 2402db7..f010918 100644 --- a/src/modules/crud/design.api.ts +++ b/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' }); diff --git a/src/modules/pages/connection/connection.model.ts b/src/modules/pages/connection/connection.model.ts index 6fe86dc..5874bdf 100644 --- a/src/modules/pages/connection/connection.model.ts +++ b/src/modules/pages/connection/connection.model.ts @@ -1,24 +1,60 @@ import { model, Model } from '@core/core'; import { AppModel } from '../../app.model'; import { ApiFactory } from 'src/modules/crud/apiFactory'; +import { PAGE_INDEX } from '@constants/constant'; + const api = new ApiFactory().create(); + @model() export class ConnectionModel extends Model<{ - types : { + types: { pageIndex: AppModel['TYPE']['pageIndex']; connections: AppModel['TYPE']['connections']; connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; }, + childContext: ConnectionModel['childContext']; context: ConnectionModel['context']; }> { static xtype = 'dec.dcm.model.connection'; - context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected']; + state() { + return { + connectionLicInfo: { + currentConnectionNum: 0, + maxConnectionNum: 0, + }, + }; + } + + childContext: ['connectionLicInfo']; + + context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo']; actions = { - setPageIndex:(index: string) => { + initConnectionLicInfo: (cb: Function) => { + return api.getConnectionLicInfo() + .then(res => { + this.model.connectionLicInfo = res.data; + if (res.data.currentConnectionNum > res.data.maxConnectionNum) { + BI.Services.getService('dec.service.component.icon_text.msg').alert({ + text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Tip', res.data.maxConnectionNum), + }); + } + cb(); + }); + }, + createNewConnection: () => { + if (this.model.connectionLicInfo.currentConnectionNum < this.model.connectionLicInfo.maxConnectionNum) { + this.setPageIndex(PAGE_INDEX.DATEBASE); + } else { + BI.Services.getService('dec.service.component.icon_text.msg').alert({ + text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum), + }); + } + }, + setPageIndex: (index: string) => { this.model.pageIndex = index; }, setDatebaseTypeSelected(name: string) { @@ -30,5 +66,8 @@ export class ConnectionModel extends Model<{ getConnectionStatus() { return api.getConnectionStatus(this.model.connectionSelected); }, - } + checkConnectionLic() { + return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum; + }, + }; } diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 43387d5..60327af 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -24,7 +24,7 @@ export class Connection extends BI.Widget { title: HTapeLayout; watch = { - connectionSelected:(name: string) => { + connectionSelected: (name: string) => { if (name) { const canEdit = connectionCanEdit(this.model.connectionSelectedOne); const type = this.getSelectConnectionType(); @@ -43,11 +43,15 @@ export class Connection extends BI.Widget { this.connectionEditWidget.setVisible(false); } }, + }; + + beforeRender(cb: Function) { + this.store.initConnectionLicInfo(cb); } render() { this.store.setConnectionSelected(''); - + return { type: BI.HTapeLayout.xtype, hgap: 10, @@ -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.setPageIndex(PAGE_INDEX.MAINTAIN); - this.store.setDatebaseTypeSelected(''); - }) - .catch(() => {}); + this.store.getConnectionStatus() + .then(re => { + this.store.setPageIndex(PAGE_INDEX.MAINTAIN); + this.store.setDatebaseTypeSelected(''); + }) + .catch(() => { + }); }, }], }, @@ -209,7 +215,7 @@ export class Connection extends BI.Widget { const connectionJDBC = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; databaseType = getJdbcDatabaseType(connectionJDBC.database, connectionJDBC.driver).databaseType; } - + return databaseType; } } diff --git a/src/modules/pages/connection/list/list.model.ts b/src/modules/pages/connection/list/list.model.ts index 036f320..5d650e9 100644 --- a/src/modules/pages/connection/list/list.model.ts +++ b/src/modules/pages/connection/list/list.model.ts @@ -19,7 +19,7 @@ export class ConnectionListModel extends Model<{ } actions = { - setConnections: ():Promise => api.getConnectionlist().then(data => { + setConnections: ():Promise => api.getConnectionList().then(data => { if (BI.size(data.data) > 0) { this.model.connections = data.data; this.model.connections.forEach(item => { @@ -30,7 +30,7 @@ export class ConnectionListModel extends Model<{ } else { this.model.connectionSelected = ''; } - + return new Promise(resolve => { resolve(); }); diff --git a/src/modules/pages/connection/list/list.ts b/src/modules/pages/connection/list/list.ts index 0e4be9b..f674dab 100644 --- a/src/modules/pages/connection/list/list.ts +++ b/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(); }); @@ -67,7 +67,7 @@ export class ConnectionList extends BI.LoadingPane { ], }; } - + return { type: BI.Loader.xtype, itemsCreator: (options: {times: number}, populate) => { diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index a02695d..f23de66 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/src/modules/pages/connection/list/list_item/list_item.model.ts @@ -4,11 +4,13 @@ import { ApiFactory } from '../../../../crud/apiFactory'; import { ResultType } from '../../../../crud/crud.typings'; import { getChartLength } from '../../../../app.service'; import { NAME_MAX_LENGTH } from '../../../../app.constant'; +import { PAGE_INDEX } from '@constants/constant'; + const api = new ApiFactory().create(); @model() export class ListItemModel extends Model<{ - types : { + types: { connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; @@ -21,7 +23,7 @@ export class ListItemModel extends Model<{ }> { static xtype = 'dec.dcm.model.connection.list_item'; - context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; + context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo']; state() { return { @@ -52,10 +54,12 @@ export class ListItemModel extends Model<{ }, setIsEdit: (isEdit: boolean, name: string) => { if (isEdit) { - api.getConnectionStatus(name).then(re => { - this.model.isEdit = true; - }) - .catch(() => {}); + api.getConnectionStatus(name) + .then(re => { + this.model.isEdit = true; + }) + .catch(() => { + }); } else { api.shutdownConnectionStatus(name); this.model.isEdit = false; @@ -69,7 +73,10 @@ export class ListItemModel extends Model<{ } if (getChartLength(newName) > NAME_MAX_LENGTH) { return new Promise(resolve => { - resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) }); + resolve({ + errorCode: '1', + errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH), + }); }); } const hasNamed = this.model.connections.some(item => item.connectionName === newName); @@ -82,31 +89,50 @@ export class ListItemModel extends Model<{ connection.connectionId = oldName; connection.connectionName = newName; - - return api.updateConnection(connection).then(re => { - if (!re.errorCode) { - this.model.connections = this.model.connections.map(item => { - return { - ...item, - connectionName: item.connectionName === oldName ? newName : item.connectionName, - connectionId: item.connectionName === oldName ? newName : item.connectionName, - }; - }); - if (this.model.connectionSelected === oldName) { - this.model.connectionSelected = newName; + + return api.updateConnection(connection) + .then(re => { + if (!re.errorCode) { + this.model.connections = this.model.connections.map(item => { + return { + ...item, + connectionName: item.connectionName === oldName ? newName : item.connectionName, + connectionId: item.connectionName === oldName ? newName : item.connectionName, + }; + }); + if (this.model.connectionSelected === oldName) { + this.model.connectionSelected = newName; + } } - } - - return re; - }); + + return re; + }); + }, + copyConnection(connectionName) { + if (this.model.connectionLicInfo.currentConnectionNum >= this.model.connectionLicInfo.maxConnectionNum) { + BI.Services.getService('dec.service.component.icon_text.msg').alert({ + text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum), + }); + + return; + } + this.setConnectionSelected(connectionName); + this.setIsCopy(true); + this.setPageIndex(PAGE_INDEX.MAINTAIN); }, setIsCopy: (isCopy: boolean) => { this.model.isCopy = isCopy; }, isDriverError: (errorCode: string) => api.isDriverError(errorCode), - } + }; + removeConnection(name: string) { - api.deleteConnection(name).then(re => api.getConnectionlist()) + api.deleteConnection(name) + .then(re => { + this.model.connectionLicInfo.currentConnectionNum -= 1; + + return api.getConnectionList(); + }) .then(connections => { this.model.connections = connections.data; this.model.connections.forEach(item => { diff --git a/src/modules/pages/connection/list/list_item/list_item.ts b/src/modules/pages/connection/list/list_item/list_item.ts index 4f098bc..58537d7 100644 --- a/src/modules/pages/connection/list/list_item/list_item.ts +++ b/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); diff --git a/src/modules/pages/connection_pool/connection_pool.ts b/src/modules/pages/connection_pool/connection_pool.ts index e3547f7..2cec421 100644 --- a/src/modules/pages/connection_pool/connection_pool.ts +++ b/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 : ''; @@ -29,7 +30,7 @@ export class ConnectionPool extends BI.Widget { if (BI.size(this.model.connectionJDBC) === 0) { return this.renderNoConnection(); } - + return { type: BI.HTapeLayout.xtype, items: [ @@ -37,6 +38,7 @@ export class ConnectionPool extends BI.Widget { el: { type: BI.VTapeLayout.xtype, cls: 'bi-border-right', + hgap: 10, items: [ { el: { @@ -44,16 +46,18 @@ export class ConnectionPool extends BI.Widget { cls: 'bi-border-bottom', textAlign: 'left', text: BI.i18nText('Dec-Dcm_Data_Connections'), - lgap: 10, }, height: 40, }, { - type: BI.Loader.xtype, - itemsCreator: (options: {times: number}, populate) => { - populate(this.renderList((options.times - 1) * PAGE_SIZE, options.times * PAGE_SIZE)); + el: { + type: BI.Loader.xtype, + itemsCreator: (options: { times: number }, populate) => { + populate(this.renderList((options.times - 1) * PAGE_SIZE, options.times * PAGE_SIZE)); + }, + hasNext: options => options.times * PAGE_SIZE < BI.size(this.model.connectionJDBC), }, - hasNext: options => options.times * PAGE_SIZE < BI.size(this.model.connectionJDBC), + vgap: 10, }, ], }, @@ -116,14 +120,15 @@ export class ConnectionPool extends BI.Widget { private renderList(start = 0, end = 0) { const defaultSelected = this.model.connectionJDBC.length > 0 ? this.model.connectionJDBC[0].connectionName : ''; - - return this.model.connectionJDBC.slice(start, end).map(item => { - return { - type: ListItem.xtype, - name: item.connectionName, - value: item.connectionName, - selected: item.connectionName === defaultSelected, - }; - }); + + return this.model.connectionJDBC.slice(start, end) + .map(item => { + return { + type: ListItem.xtype, + name: item.connectionName, + value: item.connectionName, + selected: item.connectionName === defaultSelected, + }; + }); } } diff --git a/src/modules/pages/maintain/forms/form.model.ts b/src/modules/pages/maintain/forms/form.model.ts index 3bbc66e..f72b8ed 100644 --- a/src/modules/pages/maintain/forms/form.model.ts +++ b/src/modules/pages/maintain/forms/form.model.ts @@ -4,11 +4,12 @@ import { Connection } from 'src/modules/crud/crud.typings'; import { ApiFactory } from 'src/modules/crud/apiFactory'; import { PAGE_INDEX } from '@constants/constant'; import { testConnection } from './form.server'; + const api = new ApiFactory().create(); @model() export class MaintainFormModel extends Model<{ - types : { + types: { datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; @@ -21,7 +22,7 @@ export class MaintainFormModel extends Model<{ context: MaintainFormModel['context']; }> { static xtype = 'dec.dcm.model.maintain_form'; - + context = [ 'datebaseTypeSelected', 'datebaseTypeSelectedOne', @@ -31,13 +32,20 @@ export class MaintainFormModel extends Model<{ 'testEvent', 'connections', 'isCopy', + 'connectionLicInfo', ]; actions = { - addConnection: (data: Connection) => api.addConnection(data), + addConnection: (data: Connection) => api.addConnection(data).then(result => { + if (!result.errorCode) { + this.model.connectionLicInfo.currentConnectionNum += 1; + } + + return result; + }), updateConnection: (name: string, data: Connection) => { data.connectionId = name; - + return api.updateConnection(data); }, shutdownConnectionStatus: (name: string) => api.shutdownConnectionStatus(name), @@ -51,5 +59,5 @@ export class MaintainFormModel extends Model<{ goFirstPage() { this.model.pageIndex = PAGE_INDEX.CONNECTION; }, - } + }; } From ea728d46f89a3f9696df6ea6a0eab13cee00c16c Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 22 Jul 2021 18:36:26 +0800 Subject: [PATCH 02/18] =?UTF-8?q?DEC-19867=20feat:=20=E6=95=B0=E6=8D=AElic?= =?UTF-8?q?=E5=8F=97=E9=99=90=E8=BF=9E=E6=8E=A5=E5=87=BA=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA-=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- private/i18n.ts | 1 + src/modules/constants/constant.ts | 30 ++++---- src/modules/crud/crud.typings.d.ts | 4 ++ .../pages/connection/connection.model.ts | 2 +- .../connection_jdbc/connection_jdbc.ts | 19 ++++- .../connection_jndi/connection_jndi.ts | 2 +- .../list/list_item/list_item.model.ts | 72 ++++++------------- .../maintain/forms/components/form.jdbc.ts | 69 +++++++++++++----- 8 files changed, 114 insertions(+), 85 deletions(-) diff --git a/private/i18n.ts b/private/i18n.ts index 6d9294b..a36b80e 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -305,4 +305,5 @@ export default { '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之间的值', }; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index ba6a849..c519031 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -19,17 +19,17 @@ export const DATEBASE_FILTER_TYPE = { }; export const DATA_BASE_TYPES_OTHER = -{ - text: OTHER_JDBC, - databaseType: OTHER_JDBC, - driver: '', - url: '', - commonly: false, - internal: false, - type: 'jdbc', - hasSchema: true, - kerberos: false, -}; + { + text: OTHER_JDBC, + databaseType: OTHER_JDBC, + driver: '', + url: '', + commonly: false, + internal: false, + type: 'jdbc', + hasSchema: true, + kerberos: false, + }; export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [ { databaseType: 'ads', @@ -444,6 +444,7 @@ export const DATA_BASE_TYPES = [ type: 'jdbc', hasSchema: true, kerberos: false, + fetchSize: 50, }, { text: 'INFORMIX', databaseType: 'informix', @@ -521,6 +522,7 @@ export const DATA_BASE_TYPES = [ type: 'jdbc', hasSchema: true, kerberos: false, + fetchSize: 128, }, { text: 'Pivotal Greenplum Database', @@ -547,6 +549,7 @@ export const DATA_BASE_TYPES = [ type: 'jdbc', hasSchema: true, kerberos: false, + fetchSize: 10000, }, { text: 'Presto', databaseType: 'presto', @@ -648,7 +651,6 @@ export const DATA_BASE_TYPES = [ ]; - export const CONNECT_CHARSET = [ { text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'), @@ -740,10 +742,10 @@ export const CONNECTION_LAYOUT = { export const JNDI_FACTORYS = [ { - factory:'', + factory: '', url: '', }, { - factory:'weblogic.jndi.WLInitialContextFactory', + factory: 'weblogic.jndi.WLInitialContextFactory', url: 't3://localhost:7001', }, { factory: 'com.ibm.websphere.naming.WsnInitialContextFactory', diff --git a/src/modules/crud/crud.typings.d.ts b/src/modules/crud/crud.typings.d.ts index 2d56028..bdbf770 100644 --- a/src/modules/crud/crud.typings.d.ts +++ b/src/modules/crud/crud.typings.d.ts @@ -108,6 +108,10 @@ export interface ConnectionJDBC { * 秘钥路径 */ keyPath?: string; + /** + * fetchSize + */ + fetchSize?: string; connectionPoolAttr: ConnectionPoolJDBC; } diff --git a/src/modules/pages/connection/connection.model.ts b/src/modules/pages/connection/connection.model.ts index 5874bdf..bdea196 100644 --- a/src/modules/pages/connection/connection.model.ts +++ b/src/modules/pages/connection/connection.model.ts @@ -30,7 +30,7 @@ export class ConnectionModel extends Model<{ childContext: ['connectionLicInfo']; - context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo']; + context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected']; actions = { initConnectionLicInfo: (cb: Function) => { diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 9e205aa..3c35f03 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -19,9 +19,20 @@ export class ConnectionJdbc extends BI.Widget { model: ConnectionJdecModel['model']; allDatabaseTypes = getAllDatabaseTypes(); - render () { + render() { const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; - const { driver, database, user, originalCharsetName, schema, connectionPoolAttr, authType, principal, url } = connectionData; + const { + driver, + 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, }, ], }, diff --git a/src/modules/pages/connection/connection_jndi/connection_jndi.ts b/src/modules/pages/connection/connection_jndi/connection_jndi.ts index 1db4a3b..874120a 100644 --- a/src/modules/pages/connection/connection_jndi/connection_jndi.ts +++ b/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 { jndiName, contextHashtable, originalCharsetName } = connectionData; const { hgap, vgap } = CONNECTION_LAYOUT; - + return { type: BI.VerticalLayout.xtype, $testId: 'dec-dcm-connection-jndi', diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index f23de66..f43abb5 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/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 { getChartLength } from '../../../../app.service'; import { NAME_MAX_LENGTH } from '../../../../app.constant'; -import { PAGE_INDEX } from '@constants/constant'; - const api = new ApiFactory().create(); @model() export class ListItemModel extends Model<{ - types: { + types : { connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; @@ -23,7 +21,7 @@ export class ListItemModel extends Model<{ }> { static xtype = 'dec.dcm.model.connection.list_item'; - context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo']; + context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; state() { return { @@ -54,12 +52,10 @@ export class ListItemModel extends Model<{ }, setIsEdit: (isEdit: boolean, name: string) => { if (isEdit) { - api.getConnectionStatus(name) - .then(re => { - this.model.isEdit = true; - }) - .catch(() => { - }); + api.getConnectionStatus(name).then(re => { + this.model.isEdit = true; + }) + .catch(() => {}); } else { api.shutdownConnectionStatus(name); this.model.isEdit = false; @@ -73,10 +69,7 @@ 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); @@ -90,49 +83,30 @@ export class ListItemModel extends Model<{ connection.connectionName = newName; - return api.updateConnection(connection) - .then(re => { - if (!re.errorCode) { - this.model.connections = this.model.connections.map(item => { - return { - ...item, - connectionName: item.connectionName === oldName ? newName : item.connectionName, - connectionId: item.connectionName === oldName ? newName : item.connectionName, - }; - }); - if (this.model.connectionSelected === oldName) { - this.model.connectionSelected = newName; - } + return api.updateConnection(connection).then(re => { + if (!re.errorCode) { + this.model.connections = this.model.connections.map(item => { + return { + ...item, + connectionName: item.connectionName === oldName ? newName : item.connectionName, + connectionId: item.connectionName === oldName ? newName : item.connectionName, + }; + }); + if (this.model.connectionSelected === oldName) { + this.model.connectionSelected = newName; } + } - return re; - }); - }, - 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); + return re; + }); }, setIsCopy: (isCopy: boolean) => { this.model.isCopy = isCopy; }, isDriverError: (errorCode: string) => api.isDriverError(errorCode), - }; - + } removeConnection(name: string) { - api.deleteConnection(name) - .then(re => { - this.model.connectionLicInfo.currentConnectionNum -= 1; - - return api.getConnectionList(); - }) + api.deleteConnection(name).then(re => api.getConnectionList()) .then(connections => { this.model.connections = connections.data; this.model.connections.forEach(item => { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index b00d993..3c69a47 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -1,12 +1,12 @@ -import {shortcut} from '@core/core'; -import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse'; -import {FormItem} from '../../components/form_item/form_item'; -import {Connection, ConnectionJDBC, ConnectionPoolJDBC} from 'src/modules/crud/crud.typings'; -import {connectionType} from '@constants/env'; -import {CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE} from '@constants/constant'; -import {getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl} from '../../../../app.service'; -import {TextChecker} from '../../../../components/text_checker/text_checker'; -import {ApiFactory} from 'src/modules/crud/apiFactory'; +import { shortcut } from '@core/core'; +import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; +import { FormItem } from '../../components/form_item/form_item'; +import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; +import { connectionType } from '@constants/env'; +import { CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE } from '@constants/constant'; +import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service'; +import { TextChecker } from '../../../../components/text_checker/text_checker'; +import { ApiFactory } from 'src/modules/crud/apiFactory'; import { Editor, EditorIconCheckCombo, @@ -14,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,10 +63,11 @@ export class FormJdbc extends BI.Widget { numTestsPerEvictionRun: null, minIdle: null, minEvictableIdleTimeMillis: null, + fetchSize: null, }; render() { - const {connectionName, connectionData} = this.options.formData; + const { connectionName, connectionData } = this.options.formData; const { driver, user, @@ -78,7 +79,8 @@ export class FormJdbc extends BI.Widget { database, authType, principal, - keyPath + keyPath, + fetchSize, } = connectionData as ConnectionJDBC; const { initialSize, @@ -92,12 +94,12 @@ export class FormJdbc extends BI.Widget { timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minIdle, - minEvictableIdleTimeMillis + minEvictableIdleTimeMillis, } = connectionPoolAttr as ConnectionPoolJDBC; const databaseType = getJdbcDatabaseType(database, driver); this.oldPassword = password; - const {host, port, databaseName} = resolveUrlInfo(url, database); - const {hgap, vgap} = CONNECTION_LAYOUT; + const { host, port, databaseName } = resolveUrlInfo(url, database); + const { hgap, vgap } = CONNECTION_LAYOUT; const valueRangeConfig = { errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'), @@ -394,7 +396,7 @@ export class FormJdbc extends BI.Widget { vgap: 15, disabled: true, value: schema, - items: schema ? [{text: schema, value: schema}] : [], + items: schema ? [{ text: schema, value: schema }] : [], ref: (_ref: TextValueCombo) => { this.form.schema = _ref; }, @@ -702,6 +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, + }, + ], + }, }, ], }, @@ -767,7 +800,7 @@ export class FormJdbc extends BI.Widget { } private onHostPortChange(databaseType) { - const {urls, url} = databaseType; + const { urls, url } = databaseType; const driver = this.form.driver.getValue(); const selectUrl = BI.get(urls, driver) || url; const host = this.form.host.getValue(); From a8bba76fe9b6cb05b6da36d3d4ce94a8ee9ae3d2 Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 22 Jul 2021 19:05:46 +0800 Subject: [PATCH 03/18] =?UTF-8?q?DEC-19762=20feat:=20=E3=80=90FR=E9=85=8D?= =?UTF-8?q?=E5=90=88=E3=80=91=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=94=AF=E6=8C=81fetchsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../list/list_item/list_item.model.ts | 72 +++++++++++++------ .../maintain/forms/components/form.jdbc.ts | 1 + .../pages/maintain/forms/form.model.ts | 18 ++--- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index f43abb5..f23de66 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/src/modules/pages/connection/list/list_item/list_item.model.ts @@ -4,11 +4,13 @@ import { ApiFactory } from '../../../../crud/apiFactory'; import { ResultType } from '../../../../crud/crud.typings'; import { getChartLength } from '../../../../app.service'; import { NAME_MAX_LENGTH } from '../../../../app.constant'; +import { PAGE_INDEX } from '@constants/constant'; + const api = new ApiFactory().create(); @model() export class ListItemModel extends Model<{ - types : { + types: { connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; @@ -21,7 +23,7 @@ export class ListItemModel extends Model<{ }> { static xtype = 'dec.dcm.model.connection.list_item'; - context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; + context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo']; state() { return { @@ -52,10 +54,12 @@ export class ListItemModel extends Model<{ }, setIsEdit: (isEdit: boolean, name: string) => { if (isEdit) { - api.getConnectionStatus(name).then(re => { - this.model.isEdit = true; - }) - .catch(() => {}); + api.getConnectionStatus(name) + .then(re => { + this.model.isEdit = true; + }) + .catch(() => { + }); } else { api.shutdownConnectionStatus(name); this.model.isEdit = false; @@ -69,7 +73,10 @@ export class ListItemModel extends Model<{ } if (getChartLength(newName) > NAME_MAX_LENGTH) { return new Promise(resolve => { - resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) }); + resolve({ + errorCode: '1', + errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH), + }); }); } const hasNamed = this.model.connections.some(item => item.connectionName === newName); @@ -83,30 +90,49 @@ export class ListItemModel extends Model<{ connection.connectionName = newName; - return api.updateConnection(connection).then(re => { - if (!re.errorCode) { - this.model.connections = this.model.connections.map(item => { - return { - ...item, - connectionName: item.connectionName === oldName ? newName : item.connectionName, - connectionId: item.connectionName === oldName ? newName : item.connectionName, - }; - }); - if (this.model.connectionSelected === oldName) { - this.model.connectionSelected = newName; + return api.updateConnection(connection) + .then(re => { + if (!re.errorCode) { + this.model.connections = this.model.connections.map(item => { + return { + ...item, + connectionName: item.connectionName === oldName ? newName : item.connectionName, + connectionId: item.connectionName === oldName ? newName : item.connectionName, + }; + }); + if (this.model.connectionSelected === oldName) { + this.model.connectionSelected = newName; + } } - } - return re; - }); + return re; + }); + }, + copyConnection(connectionName) { + if (this.model.connectionLicInfo.currentConnectionNum >= this.model.connectionLicInfo.maxConnectionNum) { + BI.Services.getService('dec.service.component.icon_text.msg').alert({ + text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum), + }); + + return; + } + this.setConnectionSelected(connectionName); + this.setIsCopy(true); + this.setPageIndex(PAGE_INDEX.MAINTAIN); }, setIsCopy: (isCopy: boolean) => { this.model.isCopy = isCopy; }, isDriverError: (errorCode: string) => api.isDriverError(errorCode), - } + }; + removeConnection(name: string) { - api.deleteConnection(name).then(re => api.getConnectionList()) + api.deleteConnection(name) + .then(re => { + this.model.connectionLicInfo.currentConnectionNum -= 1; + + return api.getConnectionList(); + }) .then(connections => { this.model.connections = connections.data; this.model.connections.forEach(item => { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 3c69a47..1c2f519 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -849,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(), diff --git a/src/modules/pages/maintain/forms/form.model.ts b/src/modules/pages/maintain/forms/form.model.ts index f72b8ed..3bbc66e 100644 --- a/src/modules/pages/maintain/forms/form.model.ts +++ b/src/modules/pages/maintain/forms/form.model.ts @@ -4,12 +4,11 @@ import { Connection } from 'src/modules/crud/crud.typings'; import { ApiFactory } from 'src/modules/crud/apiFactory'; import { PAGE_INDEX } from '@constants/constant'; import { testConnection } from './form.server'; - const api = new ApiFactory().create(); @model() export class MaintainFormModel extends Model<{ - types: { + types : { datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; @@ -22,7 +21,7 @@ export class MaintainFormModel extends Model<{ context: MaintainFormModel['context']; }> { static xtype = 'dec.dcm.model.maintain_form'; - + context = [ 'datebaseTypeSelected', 'datebaseTypeSelectedOne', @@ -32,20 +31,13 @@ export class MaintainFormModel extends Model<{ 'testEvent', 'connections', 'isCopy', - 'connectionLicInfo', ]; actions = { - addConnection: (data: Connection) => api.addConnection(data).then(result => { - if (!result.errorCode) { - this.model.connectionLicInfo.currentConnectionNum += 1; - } - - return result; - }), + addConnection: (data: Connection) => api.addConnection(data), updateConnection: (name: string, data: Connection) => { data.connectionId = name; - + return api.updateConnection(data); }, shutdownConnectionStatus: (name: string) => api.shutdownConnectionStatus(name), @@ -59,5 +51,5 @@ export class MaintainFormModel extends Model<{ goFirstPage() { this.model.pageIndex = PAGE_INDEX.CONNECTION; }, - }; + } } From 2d1a088cfb60ef2fadc8da295c946b6f5d5e8159 Mon Sep 17 00:00:00 2001 From: dailer Date: Tue, 27 Jul 2021 14:11:20 +0800 Subject: [PATCH 04/18] =?UTF-8?q?DEC-19934=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E5=87=BA?= =?UTF-8?q?=E9=94=99=E6=8F=90=E7=A4=BA-=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=82=B9=E5=87=BB=E5=A4=8D=E5=88=B6=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.model.ts | 10 +++++++--- src/modules/pages/connection/connection.model.ts | 13 +------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/modules/app.model.ts b/src/modules/app.model.ts index 79b06f6..200800c 100644 --- a/src/modules/app.model.ts +++ b/src/modules/app.model.ts @@ -7,7 +7,7 @@ import { getAllDatabaseTypes } from './app.service'; export class AppModel extends Model { static xtype = 'dec.dcm.model.main'; - childContext = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy']; + childContext = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy', 'connectionLicInfo']; state() { return { @@ -19,13 +19,17 @@ export class AppModel extends Model { saveEvent: '', testEvent: '', isCopy: false, + connectionLicInfo: { + currentConnectionNum: 0, + maxConnectionNum: 0, + }, }; } computed = { connectionSelectedOne: () => this.model.connections.find(item => item.connectionName === this.model.connectionSelected), datebaseTypeSelectedOne: () => getAllDatabaseTypes().find(item => item.databaseType === this.model.datebaseTypeSelected), - } + }; actions = { setPageIndex: (index: string) => { @@ -37,5 +41,5 @@ export class AppModel extends Model { setDatebaseTypeSelected: (datebaseTypeSelected: string) => { this.model.datebaseTypeSelected = datebaseTypeSelected; }, - } + }; } diff --git a/src/modules/pages/connection/connection.model.ts b/src/modules/pages/connection/connection.model.ts index bdea196..f037865 100644 --- a/src/modules/pages/connection/connection.model.ts +++ b/src/modules/pages/connection/connection.model.ts @@ -19,18 +19,7 @@ export class ConnectionModel extends Model<{ }> { static xtype = 'dec.dcm.model.connection'; - state() { - return { - connectionLicInfo: { - currentConnectionNum: 0, - maxConnectionNum: 0, - }, - }; - } - - childContext: ['connectionLicInfo']; - - context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected']; + context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo']; actions = { initConnectionLicInfo: (cb: Function) => { From 151a770315c12ecd9b2a4afe10cdfd8c1ad76884 Mon Sep 17 00:00:00 2001 From: dailer Date: Wed, 28 Jul 2021 11:08:11 +0800 Subject: [PATCH 05/18] =?UTF-8?q?DEC-19762=20feat:=E3=80=90FR=E9=85=8D?= =?UTF-8?q?=E5=90=88=E3=80=91=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=94=AF=E6=8C=81fetchsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 10 +--- src/modules/app.ts | 6 ++- src/modules/crud/crud.typings.d.ts | 10 ++-- src/modules/pages/connection/connection.ts | 26 +++++++--- .../connection_jdbc/connection_jdbc.ts | 1 + .../maintain/forms/components/form.jdbc.ts | 2 +- src/modules/pages/maintain/forms/form.ts | 50 ++++++++++--------- 7 files changed, 60 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 8f7d836..d7f4eac 100644 --- a/package.json +++ b/package.json @@ -48,15 +48,14 @@ "source-map-loader": "0.2.4", "style-loader": "0.23.1", "ts-jest": "24.0.2", - "typescript": "3.5.1", + "typescript": "^4.3.5", "webpack": "4.35.2", "webpack-cli": "3.3.5", "webpack-dev-server": "3.7.2", "webpack-merge": "4.2.1" }, "optionalDependencies": { - "@fui/core": "^2.0.0", - "@fui/materials": "10.0.0-release - 10.0.0-release.99999999999999" + "@fui/core": "^2.0.20210721103227" }, "scripts": { "dev": "cross-env NODE_ENV=mock webpack-dev-server -p --progress --config=webpack/webpack.dev.js --mode development --open", @@ -67,10 +66,5 @@ "i18n": "node ./lib/transform-i18n/transform-i18n.js", "test": "jest --passWithNoTests", "upgrade": "node lib/upgrade" - }, - "husky": { - "hooks": { - "pre-push": "npm run eslint && npm run test" - } } } diff --git a/src/modules/app.ts b/src/modules/app.ts index 73561fc..c347927 100644 --- a/src/modules/app.ts +++ b/src/modules/app.ts @@ -15,6 +15,10 @@ import '../less/index.less'; export class App extends BI.Widget { static xtype = 'dec.dcm.main'; + props = { + baseCls: 'dec-dcm', + }; + tab: Tab; store: AppModel['store']; @@ -24,7 +28,7 @@ export class App extends BI.Widget { pageIndex: (index: string) => { this.tab.setSelect(index); }, - } + }; render() { return { diff --git a/src/modules/crud/crud.typings.d.ts b/src/modules/crud/crud.typings.d.ts index bdbf770..9f0f69f 100644 --- a/src/modules/crud/crud.typings.d.ts +++ b/src/modules/crud/crud.typings.d.ts @@ -22,12 +22,12 @@ export interface Connection { privilegeDetailBeanList?: { privilegeType: number; privilegeValue: number; - }[] + }[]; } export interface ConnectionLicInfo { currentConnectionNum: number; - maxConnectionNum: number + maxConnectionNum: number; } export interface ConnectionJDBC { @@ -111,7 +111,11 @@ export interface ConnectionJDBC { /** * fetchSize */ - fetchSize?: string; + fetchSize?: number; + /** + * 连接池id + */ + identity?: string; connectionPoolAttr: ConnectionPoolJDBC; } diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 60327af..4682418 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -64,15 +64,25 @@ export class Connection extends BI.Widget { items: [ { el: { - type: BI.VerticalAdaptLayout.xtype, + type: BI.LeftRightVerticalAdaptLayout.xtype, cls: 'bi-border-bottom', - items: [{ - type: BI.Button.xtype, - text: BI.i18nText('Dec-Dcm_Connection_New'), - handler: () => { - this.store.createNewConnection(); - }, - }], + items: { + left: [ + { + type: BI.Button.xtype, + text: BI.i18nText('Dec-Dcm_Connection_New'), + handler: () => { + this.store.createNewConnection(); + }, + }, + ], + right: [ + { + type: 'dec.connection.driver.entry', + from: '.dec-dcm', + }, + ], + }, }, height: 40, }, diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 3c35f03..4dc6d0e 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -182,6 +182,7 @@ export class ConnectionJdbc extends BI.Widget { unit: BI.i18nText('BI-Basic_Seconds'), }, { type: FormItem.xtype, + invisible: BI.parseInt(fetchSize) < 0, name: 'Fetchsize', value: fetchSize, }, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 1c2f519..a0c49d4 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -849,7 +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(), + fetchSize: BI.parseInt(this.form.fetchSize.getValue()), connectionPoolAttr: { initialSize: this.form.initialSize.getValue(), maxActive: this.form.maxActive.getValue(), diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index fe33db2..ceb59cc 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -16,10 +16,10 @@ export class MaintainForm extends BI.Widget { props = { connectionType: '', - } + }; isEdit = false; connectionName = ''; - + model: MaintainFormModel['model']; store: MaintainFormModel['store']; @@ -39,7 +39,7 @@ export class MaintainForm extends BI.Widget { this.store.updateConnection(this.connectionName, value).then(result => { if (result.errorCode) { this.showError(result); - + return; } this.store.goFirstPage(); @@ -55,7 +55,7 @@ export class MaintainForm extends BI.Widget { testEvent: () => { this.testConnection(); }, - } + }; render() { const formData = BI.clone(this.getFormData()); @@ -63,7 +63,7 @@ export class MaintainForm extends BI.Widget { formData.connectionName = this.getConnectionName(formData.connectionName); this.isEdit = false; } - + return { type: this.getFormType(), formData, @@ -98,7 +98,7 @@ export class MaintainForm extends BI.Widget { } } - private getFormData():Connection { + private getFormData(): Connection { switch (this.options.connectionType) { case connectionType.JDBC: return this.getJdbcConnection(); @@ -111,7 +111,7 @@ export class MaintainForm extends BI.Widget { } } - private getJdbcConnection():Connection { + private getJdbcConnection(): Connection { const connectionName = this.getConnectionName(); let editConnection: Connection; let connectionData: ConnectionJDBC; @@ -122,8 +122,10 @@ export class MaintainForm extends BI.Widget { database: this.model.datebaseTypeSelectedOne.databaseType, connectionName, connectionPoolAttr: DEFAULT_JDBC_POOL, - port:'', + port: '', host: 'localhost', + fetchSize: this.model.datebaseTypeSelectedOne.fetchSize ?? -1, + identity: BI.UUID(), }; editConnection = { connectionId: '', @@ -131,7 +133,7 @@ export class MaintainForm extends BI.Widget { connectionType: connectionType.JDBC, connectionName, }; - + return editConnection; } this.isEdit = true; @@ -139,11 +141,11 @@ export class MaintainForm extends BI.Widget { const connection = BI.clone(this.model.connectionSelectedOne); const { database, driver } = connection.connectionData as ConnectionJDBC; (connection.connectionData as ConnectionJDBC).database = getJdbcDatabaseType(database, driver).databaseType; - + return connection; } - private getJndiConnection():Connection { + private getJndiConnection(): Connection { if (this.model.datebaseTypeSelected) { return { connectionId: '', @@ -154,18 +156,18 @@ export class MaintainForm extends BI.Widget { } this.connectionName = this.model.connectionSelectedOne.connectionName; this.isEdit = true; - + return this.model.connectionSelectedOne; } - private getPluginConnection():Connection { + private getPluginConnection(): Connection { if (!this.model.datebaseTypeSelected) { this.connectionName = this.model.connectionSelectedOne.connectionName; this.isEdit = true; - + return this.model.connectionSelectedOne; } - + return { connectionId: '', connectionType: this.model.datebaseTypeSelectedOne.databaseType, @@ -174,27 +176,27 @@ export class MaintainForm extends BI.Widget { }; } - private testValue():boolean { + private testValue(): boolean { const value = this.form.getSubmitValue(); if (!value.connectionName) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); - + return false; } if (this.connectionName !== value.connectionName) { const hasNamed = this.model.connections.some(item => item.connectionName === value.connectionName); if (hasNamed) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_Is_Existence')); - + return false; } } if (getChartLength(value.connectionName) > NAME_MAX_LENGTH) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH)); - + return false; } - + return true; } @@ -204,7 +206,7 @@ export class MaintainForm extends BI.Widget { BI.Msg.toast(BI.i18nText(result.errorMsg), { level: 'error', }); - + return; } @@ -220,12 +222,12 @@ export class MaintainForm extends BI.Widget { const formValue = this.form.getSubmitValue(); if (!formValue.connectionName) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); - + return; } if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH)); - + return false; } if (this.isEdit || this.model.isCopy) { @@ -256,7 +258,7 @@ export class MaintainForm extends BI.Widget { level: 'error', }); } - + return; } this.store.goFirstPage(); From 3568b32989c193cb060edb1a8775046c3e796ac3 Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 2 Aug 2021 18:17:00 +0800 Subject: [PATCH 06/18] =?UTF-8?q?DEC-19879=20feat:=20=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/crud/api.ts | 5 + src/modules/crud/decision.api.ts | 8 + .../driverselector/driverselector.model.ts | 119 ++++++++++ .../driverselector/driverselector.ts | 217 ++++++++++++++++++ .../maintain/forms/components/form.jdbc.ts | 56 +++-- src/modules/pages/maintain/forms/form.ts | 11 +- 6 files changed, 390 insertions(+), 26 deletions(-) create mode 100644 src/modules/pages/maintain/components/driverselector/driverselector.model.ts create mode 100644 src/modules/pages/maintain/components/driverselector/driverselector.ts diff --git a/src/modules/crud/api.ts b/src/modules/crud/api.ts index 1d917b8..12d4f0c 100644 --- a/src/modules/crud/api.ts +++ b/src/modules/crud/api.ts @@ -52,6 +52,11 @@ export interface Api { */ getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>; + /** + * 获取自定义驱动列表 + */ + getSimpleDriverList(): Promise<{ data?: any[] }>; + /** * 获取连接状态 * @param name diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index a15cd14..7301526 100644 --- a/src/modules/crud/decision.api.ts +++ b/src/modules/crud/decision.api.ts @@ -52,6 +52,14 @@ export class DecisionApi implements Api { return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {}); } + getSimpleDriverList(): Promise<{ data: any[] }> { + return new Promise(resolve => { + Dec.reqGet('/v10/drivers/simple/list', '', re => { + resolve(re); + }); + }); + } + getConnectionStatus(name: string): Promise { return this.sendEditStatusEvent(name, editStatusEvent.OPEN) .then(re => { diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts new file mode 100644 index 0000000..77077ab --- /dev/null +++ b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts @@ -0,0 +1,119 @@ +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 : '', + text: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '', + }, + }; + }; + + computed = { + driverClassItems: () => this.model.customDrivers.map(driver => { + return { + text: `${driver.driverClass} (${driver.name})`, + value: 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; + cb(); + }); + }, + + changeDefaultDriver: driver => { + this.model.defaultDriver.driver = driver; + this.model.driverSource = ''; + }, + + changeCustomDriver: driver => { + this.model.customDriver.driver = driver; + + + this.model.customDrivers.some(customDriver => { + if (customDriver.driverClass === driver) { + this.model.driverSource = customDriver.name; + this.model.customDriver.text = `${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; + }; +} diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts new file mode 100644 index 0000000..564dc9a --- /dev/null +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -0,0 +1,217 @@ +import { shortcut, store } from '@core/core'; + +import { + Button, + EditorIconCheckCombo, + SearchTextValueCombo, + TextValueCombo, +} from '@fui/core'; +import { ConnectionJDBC } from '../../../../crud/crud.typings'; +import { getJdbcDatabaseType } from '../../../../app.service'; +import { DriverSelectorModel } from './driverselector.model'; + + +@shortcut() +@store(DriverSelectorModel, { + props(this: DriverSelector) { + return this.options; + }, +}) +export class DriverSelector extends BI.Widget { + static xtype = 'dec.dcm.maintain.form.jdbc.driver_selector'; + + props = { + driver: '', + driverSource: '', + connectionData: {} as ConnectionJDBC, + }; + + defaultDrivers: EditorIconCheckCombo = null; + + customDrivers: SearchTextValueCombo = null; + + beforeRender(cb: Function) { + this.store.initDriverClassList(cb); + } + + watch = { + driverClassItems: items => { + this.customDrivers.populate(items); + this.customDrivers.setValue(this.model.customDriver.driver); + }, + + driverManageEntryVisible: b => { + this.driverManageEntry.setVisible(b); + }, + }; + + private driverManageEntry = null; + + render() { + const { driver } = this.options.connectionData; + + return { + type: BI.VerticalAdaptLayout.xtype, + rgap: 10, + items: [ + { + el: { + type: BI.TextValueCombo.xtype, + width: 86, + value: this.model.selectedDriverType, + items: [ + { + text: BI.i18nText('Dec-Basic_Default'), + value: 'default', + }, { + text: BI.i18nText('Dec-Basic_Custom'), + value: 'custom', + }, + ], + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: value => { + this.store.changeSelectedDriverType(value); + if (value === 'default') { + this.defaultDrivers.setVisible(true); + this.customDrivers.setVisible(false); + + return; + } + + this.defaultDrivers.setVisible(false); + this.customDrivers.setVisible(true); + }, + }, + ], + }, + }, { + el: { + type: BI.EditorIconCheckCombo.xtype, + $testId: 'dec-editor-icon-check-combo', + $value: 'driver', + ref: _ref => { + this.defaultDrivers = _ref; + }, + invisible: this.model.driverSource !== '', + width: 204, + items: this.model.defaultDrivers, + value: this.model.defaultDriver.driver, + listeners: [ + { + eventName: BI.EditorIconCheckCombo.EVENT_CHANGE, + action: () => this.store.changeDefaultDriver(this.defaultDrivers.getValue()), + }, + ], + }, + }, { + el: { + type: BI.SearchTextValueCombo.xtype, + $testId: 'dec-editor-icon-check-combo', + $value: 'driver', + ref: _ref => { + this.customDrivers = _ref; + }, + invisible: this.model.driverSource === '', + width: 204, + watermark: BI.i18nText('Dec-Please_Input'), + items: this.model.driverClassItems, + value: this.model.customDriver.driver, + text: () => this.model.customDriver.text || 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]), + }, + ], + }, + }, { + el: { + type: BI.Button.xtype, + ref: (_ref: Button) => { + this.driverManageEntry = _ref; + }, + level: 'ignore', + text: BI.i18nText('Dec-Dcm_Create_New_Driver'), + invisible: !this.model.driverManageEntryVisible, + handler: () => { + this.createDriverManagerLayer(); + }, + }, + }, + ], + }; + } + + private createDriverManagerLayer() { + const name = BI.UUID(); + + BI.Layers.create(name, '.dec-dcm', { + render: { + type: 'bi.vtape', + cls: 'bi-background', + items: [ + { + type: 'bi.vertical_adapt', + cls: 'bi-card', + items: [ + { + el: { + type: 'bi.icon_text_item', + text: BI.i18nText('Dec-Connection_Driver_Management_Exit'), + cls: 'back-font bi-high-light', + height: 24, + logic: { + dynamic: true, + }, + handler: () => { + this.store.initDriverClassList(() => BI.Layers.remove(name)); + }, + }, + hgap: 10, + }, + ], + height: 40, + }, { + el: { + type: 'dec.connection.driver', + listeners: [ + { + eventName: 'EVENT_CLOSE', + action() { + BI.Layers.remove(name); + }, + }, + ], + }, + hgap: 10, + vgap: 10, + }, + ], + }, + }); + + BI.Layers.show(name); + } + + 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, + }; + } +} diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index a0c49d4..fa18f6a 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -16,6 +16,7 @@ import { TextValueCombo, VerticalLayout, } from '@fui/core'; +import { DriverSelector } from '../../components/driverselector/driverselector'; const api = new ApiFactory().create(); @@ -130,31 +131,32 @@ export class FormJdbc extends BI.Widget { { type: FormItem.xtype, name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), - forms: [{ - type: BI.EditorIconCheckCombo.xtype, - $testId: 'dec-editor-icon-check-combo', - $value: 'driver', - width: 300, - value: driver, - ref: (_ref: EditorIconCheckCombo) => { - this.form.driver = _ref; - }, - items: this.getDrivers(), - listeners: [{ - eventName: BI.EditorIconCheckCombo.EVENT_CHANGE, - action: () => { - const value = this.form.driver.getValue(); - const connectionData = this.options.formData.connectionData as ConnectionJDBC; - const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); - const url = connectionType.urls ? connectionType.urls[value] : connectionType.url; - this.form.url.setValue(url); - const urlInfo = resolveUrlInfo(url, connectionData.database); - this.form.host.setValue(urlInfo.host); - this.form.database.setValue(urlInfo.databaseName); - this.form.port.setValue(urlInfo.port); + forms: [ + { + type: DriverSelector.xtype, + ref: (_ref: DriverSelector) => { + this.form.driver = _ref; }, - }], - }], + driver, + 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); + 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); + }, + }, + ], + }, + ], }, { type: FormItem.xtype, @@ -823,6 +825,10 @@ export class FormJdbc extends BI.Widget { } } + public validation(): boolean { + return this.form.driver.validation(); + } + public getSubmitValue(): Connection { const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionPoolAttr = connectionData.connectionPoolAttr; @@ -836,7 +842,7 @@ export class FormJdbc extends BI.Widget { connectionData: BI.extend({}, connectionData, { database: connectionData.database, connectionName: this.form.connectionName.getValue(), - driver: this.form.driver.getValue(), + ...this.form.driver.getValue(), url: this.form.url.getValue(), user: this.form.user.getValue(), password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()), diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index ceb59cc..84201e6 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -197,6 +197,10 @@ export class MaintainForm extends BI.Widget { return false; } + if (!this.form.validation || !this.form.validation()) { + return false; + } + return true; } @@ -223,13 +227,18 @@ export class MaintainForm extends BI.Widget { if (!formValue.connectionName) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); - return; + return false; } if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) { this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH)); return false; } + + if (!this.form.validation || !this.form.validation()) { + return false; + } + if (this.isEdit || this.model.isCopy) { formValue.connectionId = this.connectionName; } From a0f2479cc0b88c4b47219aea7ef4829484811d6c Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 9 Aug 2021 16:59:23 +0800 Subject: [PATCH 07/18] =?UTF-8?q?DEC-20078=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=94=AF=E6=8C=81fetchSize=E3=80=91JNDI?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E6=96=B0=E5=BB=BA=E3=80=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=E7=9A=84=E3=80=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=BF=9E=E6=8E=A5=E3=80=8D=E3=80=81=E3=80=8C=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=80=8D=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=E6=97=A0?= =?UTF-8?q?=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/maintain/components/driverselector/driverselector.ts | 3 ++- src/modules/pages/maintain/forms/components/form.jdbc.ts | 2 ++ src/modules/pages/maintain/forms/form.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index 564dc9a..d59f956 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -118,7 +118,8 @@ export class DriverSelector extends BI.Widget { watermark: BI.i18nText('Dec-Please_Input'), items: this.model.driverClassItems, value: this.model.customDriver.driver, - text: () => this.model.customDriver.text || BI.i18nText('Dec-Please_Select'), + text: () => this.model.customDriver.text || '', + defaultText: BI.i18nText('Dec-Please_Select'), warningTitle: BI.i18nText('Dec-Dcm-Driver_Driver_File_Lost'), listeners: [ { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index fa18f6a..baf83ff 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -71,6 +71,7 @@ export class FormJdbc extends BI.Widget { const { connectionName, connectionData } = this.options.formData; const { driver, + driverSource, user, password, originalCharsetName, @@ -138,6 +139,7 @@ export class FormJdbc extends BI.Widget { this.form.driver = _ref; }, driver, + driverSource, connectionData, listeners: [ { diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 84201e6..4900051 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -235,7 +235,7 @@ export class MaintainForm extends BI.Widget { return false; } - if (!this.form.validation || !this.form.validation()) { + if (this.form.validation && !this.form.validation()) { return false; } From f15c965f5abb822e183cf0439daa82d1095c0c8b Mon Sep 17 00:00:00 2001 From: dailer Date: Tue, 10 Aug 2021 14:46:49 +0800 Subject: [PATCH 08/18] =?UTF-8?q?DEC-20036=20fix:=20=E3=80=90=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E3=80=91=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E5=85=B6=E4=BB=96JDBC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E5=88=87=E6=8D=A2=E9=A9=B1=E5=8A=A8=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=90=8EURL=E6=B2=A1=E6=9C=89=E8=81=94=E5=8A=A8=E5=8F=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/driverselector/driverselector.ts | 10 ++++++++-- .../pages/maintain/forms/components/form.jdbc.ts | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index d59f956..c155878 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -101,7 +101,10 @@ export class DriverSelector extends BI.Widget { listeners: [ { eventName: BI.EditorIconCheckCombo.EVENT_CHANGE, - action: () => this.store.changeDefaultDriver(this.defaultDrivers.getValue()), + action: () => { + this.store.changeDefaultDriver(this.defaultDrivers.getValue()); + this.fireEvent('EVENT_CHANGE'); + }, }, ], }, @@ -124,7 +127,10 @@ export class DriverSelector extends BI.Widget { listeners: [ { eventName: BI.SearchTextValueCombo.EVENT_CHANGE, - action: () => this.store.changeCustomDriver(this.customDrivers.getValue()[0]), + action: () => { + this.store.changeCustomDriver(this.customDrivers.getValue()[0]); + this.fireEvent('EVENT_CHANGE'); + }, }, ], }, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index baf83ff..c73ff73 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -148,7 +148,7 @@ export class FormJdbc extends BI.Widget { 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; + 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); @@ -806,7 +806,7 @@ export class FormJdbc extends BI.Widget { private onHostPortChange(databaseType) { const { urls, url } = databaseType; const driver = this.form.driver.getValue(); - const selectUrl = BI.get(urls, driver) || url; + const selectUrl = BI.get(urls, driver.driver) || url; const host = this.form.host.getValue(); const port = this.form.port.getValue(); const database = this.form.database.getValue(); From 19dc654a7db0633b49f109be459214da0843b6f7 Mon Sep 17 00:00:00 2001 From: dailer Date: Wed, 11 Aug 2021 17:48:43 +0800 Subject: [PATCH 09/18] =?UTF-8?q?DEC-20026=20fix:=20=E3=80=90=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E3=80=91=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?-=E6=96=B0=E5=A2=9EJNDI=E7=B1=BB=E5=9E=8B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98=E5=92=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/form.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 4900051..cb3b573 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -197,7 +197,7 @@ export class MaintainForm extends BI.Widget { return false; } - if (!this.form.validation || !this.form.validation()) { + if (this.form.validation && !this.form.validation()) { return false; } From 0843c9acae4e4d04a3ecbf5aa81686e03e9a069c Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 12 Aug 2021 20:11:23 +0800 Subject: [PATCH 10/18] =?UTF-8?q?DEC-20047=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=94=AF=E6=8C=81fetchSize=E3=80=91=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=AE=BE=E7=BD=AEfetchSize=E4=B8=BA=E7=A9=BA=E5=9B=9E?= =?UTF-8?q?=E5=A1=AB=E6=95=B0=E5=80=BC=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/connection/connection_jdbc/connection_jdbc.ts | 4 ++-- src/modules/pages/maintain/forms/components/form.jdbc.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 4dc6d0e..f28f9ec 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -182,9 +182,9 @@ export class ConnectionJdbc extends BI.Widget { unit: BI.i18nText('BI-Basic_Seconds'), }, { type: FormItem.xtype, - invisible: BI.parseInt(fetchSize) < 0, + invisible: fetchSize < 0 && fetchSize !== -2, name: 'Fetchsize', - value: fetchSize, + value: fetchSize === -2 ? '' : fetchSize, }, ], }, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index c73ff73..9f4262b 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -712,7 +712,7 @@ export class FormJdbc extends BI.Widget { el: { type: BI.VerticalLayout.xtype, cls: 'bi-border-top', - invisible: BI.parseInt(fetchSize) < 0, + invisible: fetchSize < 0 && fetchSize !== -2, items: [ { el: { @@ -723,7 +723,7 @@ export class FormJdbc extends BI.Widget { $value: 'fetch-size', width: 300, allowBlank: true, - value: fetchSize, + value: fetchSize === -2 ? '' : fetchSize, watermark: 'Fetchsize', validationChecker: [{ errorText: BI.i18nText('Dec-Dcm_Connection_Check_Fetch_Size_Range'), @@ -857,7 +857,7 @@ export class FormJdbc extends BI.Widget { creator: Dec ? Dec.personal.username : '', principal: this.form.principal.getValue(), keyPath: this.form.keyPath.getValue(), - fetchSize: BI.parseInt(this.form.fetchSize.getValue()), + fetchSize: BI.isEmptyString(this.form.fetchSize.getValue()) ? -2 : BI.parseInt(this.form.fetchSize.getValue()), connectionPoolAttr: { initialSize: this.form.initialSize.getValue(), maxActive: this.form.maxActive.getValue(), From cfe65b0254978fc4cc63f865caeaabed0ba002f9 Mon Sep 17 00:00:00 2001 From: dailer Date: Fri, 13 Aug 2021 15:21:44 +0800 Subject: [PATCH 11/18] =?UTF-8?q?DEC-20201=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E5=88=87=E6=8D=A2=E4=B8=BA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=EF=BC=8C=E5=B7=B2=E7=BB=8F=E5=A1=AB=E5=A5=BD?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/components/form.jdbc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 9f4262b..5d26ad1 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -148,7 +148,7 @@ export class FormJdbc extends BI.Widget { 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.driver] : connectionType.url; + 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); From fa2a113f0943a4a725fff8d9503c1ff3216e3a60 Mon Sep 17 00:00:00 2001 From: dailer Date: Fri, 13 Aug 2021 15:35:58 +0800 Subject: [PATCH 12/18] =?UTF-8?q?DEC-20200=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E6=96=B0=E5=BB=BA=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=EF=BC=8C=E4=BF=9D=E5=AD=98=E5=90=8E=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/connection/connection_jdbc/connection_jdbc.ts | 3 ++- src/modules/pages/maintain/forms/components/form.jdbc.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index f28f9ec..eff5383 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -23,6 +23,7 @@ export class ConnectionJdbc extends BI.Widget { const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; const { driver, + driverSource, database, user, originalCharsetName, @@ -45,7 +46,7 @@ export class ConnectionJdbc extends BI.Widget { { type: FormItem.xtype, name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), - value: driver, + value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver, }, { type: FormItem.xtype, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 5d26ad1..d9fe88c 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -148,6 +148,7 @@ export class FormJdbc extends BI.Widget { 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); From 4cea5f431e11a93019a06bee17e332b4f8c01eb6 Mon Sep 17 00:00:00 2001 From: dailer Date: Fri, 13 Aug 2021 17:21:26 +0800 Subject: [PATCH 13/18] =?UTF-8?q?DEC-20204=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E6=AC=A1=E7=AE=A1=E6=9D=83=E9=99=90=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E9=99=90=E5=88=B6=EF=BC=8C=E5=8F=AF=E4=BB=A5=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/connection/connection.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 4682418..8094b8d 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -79,6 +79,7 @@ export class Connection extends BI.Widget { right: [ { type: 'dec.connection.driver.entry', + invisible: !BI.Services.getService('dec.service.global').isAdmin(), from: '.dec-dcm', }, ], From d8b3b81e3997b3c9c54a534a985a3d3b5bbfd933 Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 16 Aug 2021 15:08:25 +0800 Subject: [PATCH 14/18] =?UTF-8?q?DEC-19760=20feat:=20=E3=80=90BI=E9=85=8D?= =?UTF-8?q?=E5=90=88=E3=80=91=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86,war?= =?UTF-8?q?=E5=8C=85=E9=83=A8=E7=BD=B2=E4=B8=8D=E6=94=AF=E6=8C=81=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../driverselector/driverselector.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index c155878..4382810 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -136,16 +136,25 @@ export class DriverSelector extends BI.Widget { }, }, { el: { - type: BI.Button.xtype, + type: 'dec.connection.driver.entry', ref: (_ref: Button) => { this.driverManageEntry = _ref; }, - level: 'ignore', - text: BI.i18nText('Dec-Dcm_Create_New_Driver'), - invisible: !this.model.driverManageEntryVisible, - handler: () => { - this.createDriverManagerLayer(); + el: { + type: BI.Button.xtype, + level: 'ignore', + text: BI.i18nText('Dec-Dcm_Create_New_Driver'), }, + from: '.dec-dcm', + invisible: !this.model.driverManageEntryVisible, + listeners: [ + { + eventName: 'EVENT_CLOSE', + action: () => { + this.store.initDriverClassList(BI.emptyFn); + }, + }, + ], }, }, ], From 11d8cea36be3af882c468ffea7728c26b9ce63cd Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 16 Aug 2021 17:02:11 +0800 Subject: [PATCH 15/18] =?UTF-8?q?DEC-20201=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E5=88=87=E6=8D=A2=E4=B8=BA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=EF=BC=8C=E5=B7=B2=E7=BB=8F=E5=A1=AB=E5=A5=BD?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../driverselector/driverselector.ts | 56 ++----------------- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index 4382810..0bb502c 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -76,12 +76,15 @@ export class DriverSelector extends BI.Widget { 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'); + } }, }, ], @@ -161,57 +164,6 @@ export class DriverSelector extends BI.Widget { }; } - private createDriverManagerLayer() { - const name = BI.UUID(); - - BI.Layers.create(name, '.dec-dcm', { - render: { - type: 'bi.vtape', - cls: 'bi-background', - items: [ - { - type: 'bi.vertical_adapt', - cls: 'bi-card', - items: [ - { - el: { - type: 'bi.icon_text_item', - text: BI.i18nText('Dec-Connection_Driver_Management_Exit'), - cls: 'back-font bi-high-light', - height: 24, - logic: { - dynamic: true, - }, - handler: () => { - this.store.initDriverClassList(() => BI.Layers.remove(name)); - }, - }, - hgap: 10, - }, - ], - height: 40, - }, { - el: { - type: 'dec.connection.driver', - listeners: [ - { - eventName: 'EVENT_CLOSE', - action() { - BI.Layers.remove(name); - }, - }, - ], - }, - hgap: 10, - vgap: 10, - }, - ], - }, - }); - - BI.Layers.show(name); - } - validation(): boolean { if (this.model.selectedDriverType === 'default' && BI.isKey(this.model.defaultDriver.driver)) { return true; From 8226d5ac15b4b96b8fd663674a1811226a421689 Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 16 Aug 2021 19:56:09 +0800 Subject: [PATCH 16/18] =?UTF-8?q?DEC-20235=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E6=96=B0=E5=BB=BA=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E6=B7=BB=E5=8A=A0=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=86=8D=E9=80=80=E5=87=BA=EF=BC=8C=E6=89=80=E6=9C=89=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=80=89=E6=8B=A9=E9=A9=B1=E5=8A=A8=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A9=B1=E5=8A=A8=E6=A0=87=E8=93=9D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/driverselector/driverselector.model.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts index 77077ab..9b2fc3e 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts @@ -45,7 +45,9 @@ export class DriverSelectorModel extends Model { initDriverClassList: cb => { api.getSimpleDriverList().then(res => { - this.model.customDrivers = res.data; + this.model.customDrivers = res.data.filter(driver => { + return BI.isKey(driver.driverClass); + }); cb(); }); }, From c61dac179428975334bfa93bf05c988acfcb1ee1 Mon Sep 17 00:00:00 2001 From: dailer Date: Mon, 16 Aug 2021 20:21:14 +0800 Subject: [PATCH 17/18] =?UTF-8?q?DEC-20237=20fix:=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E4=BD=BF=E7=94=A8=E6=9F=90=E4=B8=AA=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=A9=B1=E5=8A=A8=E6=96=B0=E5=BB=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=EF=BC=8C=E4=B8=8B=E6=8B=89=E6=A1=86=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E5=90=8E=E5=86=8D=E6=AC=A1=E4=B8=8B=E6=8B=89=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=90=8C=E9=A9=B1=E5=8A=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E7=9A=84=E6=89=80=E6=9C=89=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=A9=B1=E5=8A=A8=E9=83=BD=E4=BC=9A=E6=A0=87=E8=93=9D?= =?UTF-8?q?=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../driverselector/driverselector.model.ts | 15 ++++++++++----- .../components/driverselector/driverselector.ts | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts index 9b2fc3e..384e4f4 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts @@ -23,7 +23,7 @@ export class DriverSelectorModel extends Model { }, customDriver: { driver: driverSource !== '' ? selectedDriver : '', - text: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '', + value: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '', }, }; }; @@ -32,7 +32,8 @@ export class DriverSelectorModel extends Model { driverClassItems: () => this.model.customDrivers.map(driver => { return { text: `${driver.driverClass} (${driver.name})`, - value: driver.driverClass, + value: `${driver.driverClass} (${driver.name})`, + driverClass: driver.driverClass, }; }), @@ -57,14 +58,18 @@ export class DriverSelectorModel extends Model { this.model.driverSource = ''; }, - changeCustomDriver: driver => { - this.model.customDriver.driver = driver; + 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.text = `${driver} (${customDriver.name})`; + this.model.customDriver.value = `${driver} (${customDriver.name})`; return true; } diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index 0bb502c..896c157 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -37,7 +37,7 @@ export class DriverSelector extends BI.Widget { watch = { driverClassItems: items => { this.customDrivers.populate(items); - this.customDrivers.setValue(this.model.customDriver.driver); + this.customDrivers.setValue(this.model.customDriver.value); }, driverManageEntryVisible: b => { @@ -123,8 +123,8 @@ export class DriverSelector extends BI.Widget { width: 204, watermark: BI.i18nText('Dec-Please_Input'), items: this.model.driverClassItems, - value: this.model.customDriver.driver, - text: () => this.model.customDriver.text || '', + 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: [ From 02622eef5bb9b1461a2299f8de8a09f34b49cecd Mon Sep 17 00:00:00 2001 From: dailer Date: Wed, 18 Aug 2021 11:02:55 +0800 Subject: [PATCH 18/18] =?UTF-8?q?DEC-19760=20feat:=20=E3=80=90BI=E9=85=8D?= =?UTF-8?q?=E5=90=88=E3=80=91=E9=A9=B1=E5=8A=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/connection/connection.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 8094b8d..90f5ba1 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -81,6 +81,14 @@ export class Connection extends BI.Widget { type: 'dec.connection.driver.entry', invisible: !BI.Services.getService('dec.service.global').isAdmin(), from: '.dec-dcm', + listeners: [ + { + eventName: 'EVENT_CLOSE', + action: () => { + this.reset(); + }, + }, + ], }, ], },