Browse Source

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

feature/10.0
dailer 3 years ago
parent
commit
d95efbd68b
  1. 2
      private/i18n.ts
  2. 2
      src/modules/app.model.ts
  3. 16
      src/modules/crud/api.ts
  4. 5
      src/modules/crud/crud.typings.d.ts
  5. 57
      src/modules/crud/decision.api.ts
  6. 9
      src/modules/crud/design.api.ts
  7. 47
      src/modules/pages/connection/connection.model.ts
  8. 24
      src/modules/pages/connection/connection.ts
  9. 4
      src/modules/pages/connection/list/list.model.ts
  10. 6
      src/modules/pages/connection/list/list.ts
  11. 76
      src/modules/pages/connection/list/list_item/list_item.model.ts
  12. 11
      src/modules/pages/connection/list/list_item/list_item.ts
  13. 37
      src/modules/pages/connection_pool/connection_pool.ts
  14. 18
      src/modules/pages/maintain/forms/form.model.ts

2
private/i18n.ts

@ -303,4 +303,6 @@ export default {
'Dec-Dcm_Connection_Analytic_DB': '阿里云AnalyticDB', 'Dec-Dcm_Connection_Analytic_DB': '阿里云AnalyticDB',
'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围', 'Dec-Dcm_Connection_Value_Out_Range': '数值超出范围',
'Dec-Dcm_Socket_Unable_Connect_Tip': '可能出现编辑冲突', 'Dec-Dcm_Socket_Unable_Connect_Tip': '可能出现编辑冲突',
'Dec-Connection_Lic_Limit_Approach_Tip': '当前数据连接数量超过注册lic限制({}个),所有数据连接都不可用,请删除多余的数据连接',
'Dec-Connection_Lic_Limit_Approach_Prevent_Tip': '当前数据连接数量已经达到注册lic限制({}个),无法新增',
}; };

2
src/modules/app.model.ts

@ -31,7 +31,7 @@ export class AppModel extends Model {
setPageIndex: (index: string) => { setPageIndex: (index: string) => {
this.model.pageIndex = index; this.model.pageIndex = index;
}, },
setFilter:(filter: string) => { setFilter: (filter: string) => {
this.model.filter = filter; this.model.filter = filter;
}, },
setDatebaseTypeSelected: (datebaseTypeSelected: string) => { setDatebaseTypeSelected: (datebaseTypeSelected: string) => {

16
src/modules/crud/api.ts

@ -1,4 +1,11 @@
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ResultType } from './crud.typings'; import {
Connection,
ConnectionLicInfo,
TestRequest,
ConnectionPoolType,
SocketResult,
ResultType,
} from './crud.typings';
export interface Api { export interface Api {
/** /**
@ -9,7 +16,12 @@ export interface Api {
/** /**
* *
*/ */
getConnectionlist(): Promise<{ data?: Connection[] }>; getConnectionList(): Promise<{ data?: Connection[] }>;
/**
* lic限制信息
*/
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }>;
/** /**
* *

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

@ -25,6 +25,11 @@ export interface Connection {
}[] }[]
} }
export interface ConnectionLicInfo {
currentConnectionNum: number;
maxConnectionNum: number
}
export interface ConnectionJDBC { export interface ConnectionJDBC {
/** /**
* *

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

@ -1,15 +1,19 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings';
import { requestGet, requestDelete, requestPost, requestPut } from './crud.service'; import { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent, errorCode } from '@constants/env'; import { editStatusEvent, errorCode } from '@constants/env';
export class DecisionApi implements Api { export class DecisionApi implements Api {
isDec = true; isDec = true;
getConnectionlist(): Promise<{ data?: Connection[] }> { getConnectionList(): Promise<{ data?: Connection[] }> {
return requestGet('list', {}); return requestGet('list', {});
} }
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
deleteConnection(connectionName: string) { deleteConnection(connectionName: string) {
return requestDelete('', { return requestDelete('', {
connectionName, connectionName,
@ -49,28 +53,29 @@ export class DecisionApi implements Api {
} }
getConnectionStatus(name: string): Promise<SocketResult> { getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => { return this.sendEditStatusEvent(name, editStatusEvent.OPEN)
if (re.errorCode) { .then(re => {
let errorMessage = ''; if (re.errorCode) {
switch (re.errorCode) { let errorMessage = '';
case errorCode.CONNECTION_DELETED: switch (re.errorCode) {
errorMessage = 'Dec-Dcm_Connection_Deleted'; case errorCode.CONNECTION_DELETED:
break; errorMessage = 'Dec-Dcm_Connection_Deleted';
case errorCode.CONNECTION_UNDER_EDIT: break;
errorMessage = 'Dec-Dcm_Connection_Is_Using'; case errorCode.CONNECTION_UNDER_EDIT:
break; errorMessage = 'Dec-Dcm_Connection_Is_Using';
default: break;
errorMessage = re.errorMsg; default:
break; errorMessage = re.errorMsg;
break;
}
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), {
level: 'error',
});
throw re;
} else {
return re;
} }
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), { });
level: 'error',
});
throw re;
} else {
return re;
}
});
} }
shutdownConnectionStatus(name: string): Promise<SocketResult> { shutdownConnectionStatus(name: string): Promise<SocketResult> {
@ -94,11 +99,13 @@ export class DecisionApi implements Api {
} }
getCipher(password: string) { getCipher(password: string) {
return BI.Providers.getProvider('dec.provider.cipher').getCipher(password); return BI.Providers.getProvider('dec.provider.cipher')
.getCipher(password);
} }
getPlain(cipher: string) { getPlain(cipher: string) {
return BI.Providers.getProvider('dec.provider.cipher').getPlain(cipher); return BI.Providers.getProvider('dec.provider.cipher')
.getPlain(cipher);
} }
getHyperlink(name: string) { getHyperlink(name: string) {

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

@ -1,16 +1,21 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings';
import { requestGet } from './crud.service';
// TODO: 此页面的接口等待设计器提供相应的方法 // TODO: 此页面的接口等待设计器提供相应的方法
export class DesignApi implements Api { export class DesignApi implements Api {
isDec = false; isDec = false;
getConnectionlist(): Promise<{ data: Connection[] }> { getConnectionList(): Promise<{ data: Connection[] }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: [] }); resolve({ data: [] });
}); });
} }
getConnectionLicInfo(): Promise<{ data?: ConnectionLicInfo }> {
return requestGet('lic/info', {});
}
deleteConnection(connectionName: string): Promise<{ data: string }> { deleteConnection(connectionName: string): Promise<{ data: string }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ data: 'success' }); resolve({ data: 'success' });

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

@ -1,24 +1,60 @@
import { model, Model } from '@core/core'; import { model, Model } from '@core/core';
import { AppModel } from '../../app.model'; import { AppModel } from '../../app.model';
import { ApiFactory } from 'src/modules/crud/apiFactory'; import { ApiFactory } from 'src/modules/crud/apiFactory';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@model() @model()
export class ConnectionModel extends Model<{ export class ConnectionModel extends Model<{
types : { types: {
pageIndex: AppModel['TYPE']['pageIndex']; pageIndex: AppModel['TYPE']['pageIndex'];
connections: AppModel['TYPE']['connections']; connections: AppModel['TYPE']['connections'];
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
}, },
childContext: ConnectionModel['childContext'];
context: ConnectionModel['context']; context: ConnectionModel['context'];
}> { }> {
static xtype = 'dec.dcm.model.connection'; static xtype = 'dec.dcm.model.connection';
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected']; state() {
return {
connectionLicInfo: {
currentConnectionNum: 0,
maxConnectionNum: 0,
},
};
}
childContext: ['connectionLicInfo'];
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo'];
actions = { actions = {
setPageIndex:(index: string) => { initConnectionLicInfo: (cb: Function) => {
return api.getConnectionLicInfo()
.then(res => {
this.model.connectionLicInfo = res.data;
if (res.data.currentConnectionNum > res.data.maxConnectionNum) {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Tip', res.data.maxConnectionNum),
});
}
cb();
});
},
createNewConnection: () => {
if (this.model.connectionLicInfo.currentConnectionNum < this.model.connectionLicInfo.maxConnectionNum) {
this.setPageIndex(PAGE_INDEX.DATEBASE);
} else {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum),
});
}
},
setPageIndex: (index: string) => {
this.model.pageIndex = index; this.model.pageIndex = index;
}, },
setDatebaseTypeSelected(name: string) { setDatebaseTypeSelected(name: string) {
@ -30,5 +66,8 @@ export class ConnectionModel extends Model<{
getConnectionStatus() { getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected); return api.getConnectionStatus(this.model.connectionSelected);
}, },
} checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
},
};
} }

24
src/modules/pages/connection/connection.ts

@ -24,7 +24,7 @@ export class Connection extends BI.Widget {
title: HTapeLayout; title: HTapeLayout;
watch = { watch = {
connectionSelected:(name: string) => { connectionSelected: (name: string) => {
if (name) { if (name) {
const canEdit = connectionCanEdit(this.model.connectionSelectedOne); const canEdit = connectionCanEdit(this.model.connectionSelectedOne);
const type = this.getSelectConnectionType(); const type = this.getSelectConnectionType();
@ -43,11 +43,15 @@ export class Connection extends BI.Widget {
this.connectionEditWidget.setVisible(false); this.connectionEditWidget.setVisible(false);
} }
}, },
};
beforeRender(cb: Function) {
this.store.initConnectionLicInfo(cb);
} }
render() { render() {
this.store.setConnectionSelected(''); this.store.setConnectionSelected('');
return { return {
type: BI.HTapeLayout.xtype, type: BI.HTapeLayout.xtype,
hgap: 10, hgap: 10,
@ -66,7 +70,7 @@ export class Connection extends BI.Widget {
type: BI.Button.xtype, type: BI.Button.xtype,
text: BI.i18nText('Dec-Dcm_Connection_New'), text: BI.i18nText('Dec-Dcm_Connection_New'),
handler: () => { handler: () => {
this.store.setPageIndex(PAGE_INDEX.DATEBASE); this.store.createNewConnection();
}, },
}], }],
}, },
@ -110,11 +114,13 @@ export class Connection extends BI.Widget {
this.connectionEditWidget = _ref; this.connectionEditWidget = _ref;
}, },
handler: () => { handler: () => {
this.store.getConnectionStatus().then(re => { this.store.getConnectionStatus()
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); .then(re => {
this.store.setDatebaseTypeSelected(''); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
}) this.store.setDatebaseTypeSelected('');
.catch(() => {}); })
.catch(() => {
});
}, },
}], }],
}, },
@ -209,7 +215,7 @@ export class Connection extends BI.Widget {
const connectionJDBC = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; const connectionJDBC = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
databaseType = getJdbcDatabaseType(connectionJDBC.database, connectionJDBC.driver).databaseType; databaseType = getJdbcDatabaseType(connectionJDBC.database, connectionJDBC.driver).databaseType;
} }
return databaseType; return databaseType;
} }
} }

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

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

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

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

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

@ -4,11 +4,13 @@ import { ApiFactory } from '../../../../crud/apiFactory';
import { ResultType } from '../../../../crud/crud.typings'; import { ResultType } from '../../../../crud/crud.typings';
import { getChartLength } from '../../../../app.service'; import { getChartLength } from '../../../../app.service';
import { NAME_MAX_LENGTH } from '../../../../app.constant'; import { NAME_MAX_LENGTH } from '../../../../app.constant';
import { PAGE_INDEX } from '@constants/constant';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@model() @model()
export class ListItemModel extends Model<{ export class ListItemModel extends Model<{
types : { types: {
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne'];
@ -21,7 +23,7 @@ export class ListItemModel extends Model<{
}> { }> {
static xtype = 'dec.dcm.model.connection.list_item'; static xtype = 'dec.dcm.model.connection.list_item';
context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo'];
state() { state() {
return { return {
@ -52,10 +54,12 @@ export class ListItemModel extends Model<{
}, },
setIsEdit: (isEdit: boolean, name: string) => { setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) { if (isEdit) {
api.getConnectionStatus(name).then(re => { api.getConnectionStatus(name)
this.model.isEdit = true; .then(re => {
}) this.model.isEdit = true;
.catch(() => {}); })
.catch(() => {
});
} else { } else {
api.shutdownConnectionStatus(name); api.shutdownConnectionStatus(name);
this.model.isEdit = false; this.model.isEdit = false;
@ -69,7 +73,10 @@ export class ListItemModel extends Model<{
} }
if (getChartLength(newName) > NAME_MAX_LENGTH) { if (getChartLength(newName) > NAME_MAX_LENGTH) {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) }); resolve({
errorCode: '1',
errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH),
});
}); });
} }
const hasNamed = this.model.connections.some(item => item.connectionName === newName); const hasNamed = this.model.connections.some(item => item.connectionName === newName);
@ -82,31 +89,50 @@ export class ListItemModel extends Model<{
connection.connectionId = oldName; connection.connectionId = oldName;
connection.connectionName = newName; connection.connectionName = newName;
return api.updateConnection(connection).then(re => { return api.updateConnection(connection)
if (!re.errorCode) { .then(re => {
this.model.connections = this.model.connections.map(item => { if (!re.errorCode) {
return { this.model.connections = this.model.connections.map(item => {
...item, return {
connectionName: item.connectionName === oldName ? newName : item.connectionName, ...item,
connectionId: item.connectionName === oldName ? newName : item.connectionName, connectionName: item.connectionName === oldName ? newName : item.connectionName,
}; connectionId: item.connectionName === oldName ? newName : item.connectionName,
}); };
if (this.model.connectionSelected === oldName) { });
this.model.connectionSelected = newName; if (this.model.connectionSelected === oldName) {
this.model.connectionSelected = newName;
}
} }
}
return re;
return re; });
}); },
copyConnection(connectionName) {
if (this.model.connectionLicInfo.currentConnectionNum >= this.model.connectionLicInfo.maxConnectionNum) {
BI.Services.getService('dec.service.component.icon_text.msg').alert({
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum),
});
return;
}
this.setConnectionSelected(connectionName);
this.setIsCopy(true);
this.setPageIndex(PAGE_INDEX.MAINTAIN);
}, },
setIsCopy: (isCopy: boolean) => { setIsCopy: (isCopy: boolean) => {
this.model.isCopy = isCopy; this.model.isCopy = isCopy;
}, },
isDriverError: (errorCode: string) => api.isDriverError(errorCode), isDriverError: (errorCode: string) => api.isDriverError(errorCode),
} };
removeConnection(name: string) { removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist()) api.deleteConnection(name)
.then(re => {
this.model.connectionLicInfo.currentConnectionNum -= 1;
return api.getConnectionList();
})
.then(connections => { .then(connections => {
this.model.connections = connections.data; this.model.connections = connections.data;
this.model.connections.forEach(item => { this.model.connections.forEach(item => {

11
src/modules/pages/connection/list/list_item/list_item.ts

@ -19,7 +19,7 @@ export class ListItem extends BI.BasicButton {
height: 25, height: 25,
baseCls: 'dec-dcm-connection-list-item bi-list-item-active2', baseCls: 'dec-dcm-connection-list-item bi-list-item-active2',
$testId: 'dec-dcm-connection-list-item', $testId: 'dec-dcm-connection-list-item',
} };
store: ListItemModel['store']; store: ListItemModel['store'];
model: ListItemModel['model']; model: ListItemModel['model'];
@ -36,7 +36,7 @@ export class ListItem extends BI.BasicButton {
this.nameEditor.focus(); this.nameEditor.focus();
} }
}, },
} };
render() { render() {
const { name, databaseType } = this.options; const { name, databaseType } = this.options;
@ -220,15 +220,14 @@ export class ListItem extends BI.BasicButton {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected(''); this.store.setDatebaseTypeSelected('');
}) })
.catch(() => { }); .catch(() => {
});
}, },
changeName: () => { changeName: () => {
this.store.setIsEdit(true, name); this.store.setIsEdit(true, name);
}, },
copy: () => { copy: () => {
this.store.setConnectionSelected(name); this.store.copyConnection(name);
this.store.setIsCopy(true);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
}, },
delete: () => { delete: () => {
this.store.deleteConnection(name); this.store.deleteConnection(name);

37
src/modules/pages/connection_pool/connection_pool.ts

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

18
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 { ApiFactory } from 'src/modules/crud/apiFactory';
import { PAGE_INDEX } from '@constants/constant'; import { PAGE_INDEX } from '@constants/constant';
import { testConnection } from './form.server'; import { testConnection } from './form.server';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@model() @model()
export class MaintainFormModel extends Model<{ export class MaintainFormModel extends Model<{
types : { types: {
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
@ -21,7 +22,7 @@ export class MaintainFormModel extends Model<{
context: MaintainFormModel['context']; context: MaintainFormModel['context'];
}> { }> {
static xtype = 'dec.dcm.model.maintain_form'; static xtype = 'dec.dcm.model.maintain_form';
context = <const>[ context = <const>[
'datebaseTypeSelected', 'datebaseTypeSelected',
'datebaseTypeSelectedOne', 'datebaseTypeSelectedOne',
@ -31,13 +32,20 @@ export class MaintainFormModel extends Model<{
'testEvent', 'testEvent',
'connections', 'connections',
'isCopy', 'isCopy',
'connectionLicInfo',
]; ];
actions = { 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) => { updateConnection: (name: string, data: Connection) => {
data.connectionId = name; data.connectionId = name;
return api.updateConnection(data); return api.updateConnection(data);
}, },
shutdownConnectionStatus: (name: string) => api.shutdownConnectionStatus(name), shutdownConnectionStatus: (name: string) => api.shutdownConnectionStatus(name),
@ -51,5 +59,5 @@ export class MaintainFormModel extends Model<{
goFirstPage() { goFirstPage() {
this.model.pageIndex = PAGE_INDEX.CONNECTION; this.model.pageIndex = PAGE_INDEX.CONNECTION;
}, },
} };
} }

Loading…
Cancel
Save