From a8bba76fe9b6cb05b6da36d3d4ce94a8ee9ae3d2 Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 22 Jul 2021 19:05:46 +0800 Subject: [PATCH] =?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; }, - }; + } }