Browse Source

Pull request #8033: REPORT-102763 fix:【开个接口】数据连接支持对接业务系统

Merge in DEC/decision-webui-dcm from ~KEVIN.KING/decision-webui-dcm:feature/x to feature/x

* commit '3b71fdbdea7a78c67d64ab6e48e88582b175d59a':
  REPORT-102763 fix:【开个接口】数据连接支持对接业务系统-补充
  REPORT-102763 fix:【开个接口】数据连接支持对接业务系统
feature/x
parent
commit
10fda08400
  1. 65
      README.md
  2. 3
      src/modules/app.model.ts
  3. 1
      src/modules/app.typings.d.ts
  4. 9
      src/modules/pages/connection/connection.model.ts
  5. 13
      src/modules/pages/connection/connection.ts
  6. 1
      src/modules/pages/connection/list/list.constant.ts
  7. 4
      src/modules/pages/connection/list/list.model.ts
  8. 2
      src/modules/pages/connection/list/list.ts
  9. 5
      src/modules/pages/connection/list/list_item/list_item.ts
  10. 17
      src/modules/pages/database/database.constant.ts
  11. 28
      src/modules/pages/database/database.ts
  12. 7
      src/modules/pages/database/database_type/database_type.model.ts
  13. 4
      src/modules/pages/database/database_type/database_type.ts
  14. 4
      src/modules/pages/maintain/forms/components/form.plugin.ts
  15. 86
      src/modules/pages/maintain/forms/form.ts
  16. 3
      src/modules/title/title_maintain/title_maintain.model.ts
  17. 6
      src/modules/title/title_maintain/title_maintain.ts

65
README.md

@ -114,7 +114,8 @@ BI.config("dec.connection.provider.datebase", function (provider) {
版本和平台保持一致 版本和平台保持一致
## 接口文档: ## 接口文档:
### 增加数据连接类型 ### A 增加数据连接类型
#### 1. 增加数据连接类型
使用`BI.config`,ConstantName名称为`dec.constant.database.conf.connect.types`,值为连接的名称 使用`BI.config`,ConstantName名称为`dec.constant.database.conf.connect.types`,值为连接的名称
例如增加`Redis`的连接: 例如增加`Redis`的连接:
@ -128,25 +129,25 @@ BI.config(ConstantPluginTyps, (datas: string[]) => [...datas, {
}]); }]);
``` ```
### 数据连接填写页面 #### 2. 数据连接填写页面
edit属性值为填写组件shortcut的名称 edit属性值为填写组件shortcut的名称
### 数据连接展示页面 #### 3. 数据连接展示页面
show属性值为组件shortcut的名称 show属性值为组件shortcut的名称
### 示例 #### 4. 示例
``` ```js
const DataBaseConfigProvider = 'dec.connection.provider.datebase'; const DataBaseConfigProvider = 'dec.connection.provider.datebase';
const RedisShowName = 'dec.dcm.connection.plugin.redis.show'; const RedisShowName = 'dec.dcm.connection.plugin.redis.show';
const RedisEditName = 'dec.dcm.connection.plugin.redis.edit'; const RedisEditName = 'dec.dcm.connection.plugin.redis.edit';
BI.config(DataBaseConfigProvider, function (provider) { BI.config(DataBaseConfigProvider, function (provider) {
provider.registerDatabaseType({ provider.registerDatabaseType([{
text: "Redis", text: "Redis",
databaseType: "Redis", databaseType: "Redis",
edit: "dec.dcm.connection.plugin.demo.edit", edit: "dec.dcm.connection.plugin.demo.edit",
show: "dec.dcm.connection.plugin.demo.show", show: "dec.dcm.connection.plugin.demo.show",
}); }]);
}); });
const RedisShow = BI.inherit(BI.Widget, { const RedisShow = BI.inherit(BI.Widget, {
@ -214,7 +215,7 @@ const RedisShow = BI.inherit(BI.Widget, {
], ],
}, },
], ],
}; },
}, },
}); });
BI.shortcut(RedisShowName, RedisShow); BI.shortcut(RedisShowName, RedisShow);
@ -309,7 +310,55 @@ const RedisEdit = BI.inherit(BI.Widget, {
password: this.password.getValue(), password: this.password.getValue(),
}; };
}, },
//可以触发组件的数据save方法,不需要则可不写
async save() {
let result = false;
await Promise.resolve().then(() => {result = true});
//要求返回是否成功的boolean变量
return result;
},
}); });
BI.shortcut(RedisEditName, RedisEdit); BI.shortcut(RedisEditName, RedisEdit);
``` ```
### B 添加数据连接实例
#### 1. 增加数据连接
```js
BI.config('dec.constant.connection.list', function (value) {
const result = [{
"connectionType": "Redis",//和databaseType一致
"connectionName": "CHART",//类似于id,唯一性
"pluginConnection": true,//表示是外来添加的插件
"connectionData": {
//表单保存数据
},
"connectionId": null,
}];
return value.concat(result);
})
```
### C 添加数据连接类型分类
#### 1. 添加分类DEMO
```js
BI.config('dec.constant.database.filter.type', (value) => {
value.push({
text:"DEMO",
value:"DEMO_VALUE"
});
return value;
});
```
#### 2. 添加数据连接类型进DEMO
```js
BI.config('dec.connection.provider.datebase', function (provider) {
text: "Redis",//必填
databaseType: "Redis",//唯一值
marker: 'DEMO_VALUE',//marker对标dec.constant.database.filter.type常量item的value,用于过滤
isHideConnection: true, //是否隐藏测试连接按钮
isNoSave: true,//是否不执行平台的保存逻辑
iconUrl:'https://work.fineres.com/secure/projectavatar?pid=10301&avatarId=10011',
driver: 'com.amazon.redshift.jdbc41.Driver',
drivers: ['com.amazon.redshift.jdbc4.Driver', 'com.amazon.redshift.jdbc41.Driver'],
url: 'jdbc:redshift://endpoint:port/database',
}
```

3
src/modules/app.model.ts

@ -7,7 +7,7 @@ import { getAllDatabaseTypes } from './app.service';
export class AppModel extends Model { export class AppModel extends Model {
static xtype = 'dec.dcm.model.main'; static xtype = 'dec.dcm.model.main';
childContext = <const>['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy', 'connectionLicInfo']; childContext = <const>['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy', 'connectionLicInfo', 'noTestConnection'];
state() { state() {
return { return {
@ -23,6 +23,7 @@ export class AppModel extends Model {
currentConnectionNum: 0, currentConnectionNum: 0,
maxConnectionNum: 0, maxConnectionNum: 0,
}, },
noTestConnection: false,
}; };
} }

1
src/modules/app.typings.d.ts vendored

@ -17,4 +17,5 @@ export interface DatabaseType {
urls?: { urls?: {
[key: string]: string; [key: string]: string;
}; };
marker?: string;
} }

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

@ -13,13 +13,14 @@ export class ConnectionModel extends Model<{
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
noTestConnection: AppModel['TYPE']['noTestConnection'];
}, },
childContext: ConnectionModel['childContext']; 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', 'connectionLicInfo']; context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo', 'noTestConnection'];
actions = { actions = {
initConnectionLicInfo: (cb: Function) => { initConnectionLicInfo: (cb: Function) => {
@ -53,8 +54,14 @@ export class ConnectionModel extends Model<{
this.model.connectionSelected = name; this.model.connectionSelected = name;
}, },
getConnectionStatus() { getConnectionStatus() {
if (this.model.connectionSelectedOne.pluginConnection) {
return Promise.resolve();
}
return api.getConnectionStatus(this.model.connectionSelected); return api.getConnectionStatus(this.model.connectionSelected);
}, },
setNoTestConnection(value: boolean) {
this.model.noTestConnection = value;
},
checkConnectionLic() { checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum; return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
}, },

13
src/modules/pages/connection/connection.ts

@ -137,9 +137,11 @@ export class Connection extends BI.Widget {
}, },
handler: () => { handler: () => {
this.store.getConnectionStatus() this.store.getConnectionStatus()
.then(re => { .then(() => {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); const databaseType = this.model.connectionSelectedOne.connectionType;
this.store.setDatebaseTypeSelected(''); const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType);
this.setMaintainPage();
this.store.setNoTestConnection(database.isHideConnection);
}) })
.catch(() => { .catch(() => {
}); });
@ -239,4 +241,9 @@ export class Connection extends BI.Widget {
return databaseType; return databaseType;
} }
private setMaintainPage() {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
}
} }

1
src/modules/pages/connection/list/list.constant.ts

@ -0,0 +1 @@
BI.constant('dec.constant.connection.list', []);

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

@ -21,10 +21,10 @@ 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.concat(BI.Constants.getConstant('dec.constant.connection.list'));
this.model.connections.forEach(item => { this.model.connections.forEach(item => {
// 后端传过来的是字符串,转为对象 // 后端传过来的是字符串,转为对象
item.connectionData = JSON.parse(item.connectionData as string); BI.isString(item.connectionData) && (item.connectionData = JSON.parse(item.connectionData as string));
}); });
this.model.connectionSelected = data.data[0].connectionName; this.model.connectionSelected = data.data[0].connectionName;
} else { } else {

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

@ -3,6 +3,7 @@ import { ListItem } from './list_item/list_item';
import { ConnectionListModel } from './list.model'; import { ConnectionListModel } from './list.model';
import { getDatabaseType } from './list.service'; import { getDatabaseType } from './list.service';
import { Tab } from '@fui/core'; import { Tab } from '@fui/core';
import './list.constant'
@shortcut() @shortcut()
@store(ConnectionListModel) @store(ConnectionListModel)
@ -91,6 +92,7 @@ export class ConnectionList extends BI.Pane {
creator: item.creator, creator: item.creator,
databaseType: getDatabaseType(item), databaseType: getDatabaseType(item),
selected: this.model.connectionSelected ? this.model.connectionSelected === item.connectionName : index === 0, selected: this.model.connectionSelected ? this.model.connectionSelected === item.connectionName : index === 0,
pluginConnection: item.pluginConnection,
}; };
}); });
} }

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

@ -20,6 +20,7 @@ export class ListItem extends BI.BasicButton {
name: '', name: '',
creator: '', creator: '',
databaseType: '', databaseType: '',
pluginConnection: false,
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',
@ -43,7 +44,7 @@ export class ListItem extends BI.BasicButton {
}; };
render() { render() {
const { name, databaseType } = this.options; const { name, databaseType, pluginConnection } = this.options;
return { return {
type: BI.HTapeLayout.xtype, type: BI.HTapeLayout.xtype,
@ -118,7 +119,7 @@ export class ListItem extends BI.BasicButton {
}, },
], ],
}, { }, {
el: databaseType ? { el: databaseType && !pluginConnection ? {
type: BI.DownListCombo.xtype, type: BI.DownListCombo.xtype,
cls: 'link-item-icon', cls: 'link-item-icon',
stopPropagation: true, stopPropagation: true,

17
src/modules/pages/database/database.constant.ts

@ -0,0 +1,17 @@
import { DATEBASE_FILTER_TYPE } from "@constants/constant";
BI.constant('dec.constant.database.filter.type', [
{
text: BI.i18nText('Dec-Dcm_Connection_Commonly'),
value: DATEBASE_FILTER_TYPE.COMMONLY,
selected: true,
},
{
text: BI.i18nText('Dec-Dcm_Connection_All'),
value: DATEBASE_FILTER_TYPE.ALL,
},
{
text: BI.i18nText('Dec-Dcm_Connection_Other'),
value: DATEBASE_FILTER_TYPE.OTHER,
},
]);

28
src/modules/pages/database/database.ts

@ -7,6 +7,7 @@ import { DatebaseType } from './database_type/database_type';
import { getAllDatabaseTypes } from '../../app.service'; import { getAllDatabaseTypes } from '../../app.service';
import { ButtonGroup, MultiSelectItem, SearchEditor } from '@fui/core'; import { ButtonGroup, MultiSelectItem, SearchEditor } from '@fui/core';
import { ApiFactory } from 'src/modules/crud/apiFactory'; import { ApiFactory } from 'src/modules/crud/apiFactory';
import './database.constant'
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@ -121,24 +122,12 @@ export class Datebase extends BI.Widget {
ref: (_ref: ButtonGroup) => { ref: (_ref: ButtonGroup) => {
this.filter = _ref; this.filter = _ref;
}, },
items: [ items: () => BI.map(BI.Constants.getConstant('dec.constant.database.filter.type'), (_, value) => {
{ return {
type: Filter.xtype, type: Filter.xtype,
text: BI.i18nText('Dec-Dcm_Connection_Commonly'), ...value,
value: DATEBASE_FILTER_TYPE.COMMONLY, }
selected: true, }),
},
{
type: Filter.xtype,
text: BI.i18nText('Dec-Dcm_Connection_All'),
value: DATEBASE_FILTER_TYPE.ALL,
},
{
type: Filter.xtype,
text: BI.i18nText('Dec-Dcm_Connection_Other'),
value: DATEBASE_FILTER_TYPE.OTHER,
},
],
}, },
width: 200, width: 200,
}, },
@ -254,9 +243,12 @@ export class Datebase extends BI.Widget {
case DATEBASE_FILTER_TYPE.OTHER: case DATEBASE_FILTER_TYPE.OTHER:
this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => this.model.otherDatabases.includes(item.type))); this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => this.model.otherDatabases.includes(item.type)));
break; break;
default: case DATEBASE_FILTER_TYPE.ALL:
this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== OTHER_JDBC)); this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== OTHER_JDBC));
break; break;
default:
this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.marker && (item.marker === filter)));
break;
} }
} }

7
src/modules/pages/database/database_type/database_type.model.ts

@ -6,11 +6,13 @@ export class DatebaseTypeModel extends Model<
types: { types: {
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
pageIndex: AppModel['TYPE']['pageIndex']; pageIndex: AppModel['TYPE']['pageIndex'];
noTestConnection: AppModel['TYPE']['noTestConnection'];
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne'];
}, },
context: DatebaseTypeModel['context']; context: DatebaseTypeModel['context'];
}> { }> {
static xtype = 'dec.dcm.model.datebase.type'; static xtype = 'dec.dcm.model.datebase.type';
context = <const>['datebaseTypeSelected', 'pageIndex']; context = <const>['datebaseTypeSelected', 'pageIndex', 'noTestConnection', 'datebaseTypeSelectedOne'];
actions = { actions = {
setDatebaseTypeSelected: (datebaseTypeSelected: string) => { setDatebaseTypeSelected: (datebaseTypeSelected: string) => {
@ -19,5 +21,8 @@ export class DatebaseTypeModel extends Model<
setPageIndex: (index: string) => { setPageIndex: (index: string) => {
this.model.pageIndex = index; this.model.pageIndex = index;
}, },
setNoTestConnection: (value: boolean) => {
this.model.noTestConnection = value;
}
} }
} }

4
src/modules/pages/database/database_type/database_type.ts

@ -70,6 +70,7 @@ export class DatebaseType extends BI.BasicButton {
const { value } = this.options; const { value } = this.options;
this.store.setDatebaseTypeSelected(value); this.store.setDatebaseTypeSelected(value);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setNoTestConnection(this.model.datebaseTypeSelectedOne.isHideConnection);
} }
mounted() { mounted() {
@ -88,6 +89,9 @@ export class DatebaseType extends BI.BasicButton {
if (url.startsWith('/')) { if (url.startsWith('/')) {
return `${PluginImgPrefix}${url}`; return `${PluginImgPrefix}${url}`;
} }
if (url.startsWith('http')) {
return url;
}
return `${PluginImgPrefix}/${url}`; return `${PluginImgPrefix}/${url}`;
} }

4
src/modules/pages/maintain/forms/components/form.plugin.ts

@ -37,4 +37,8 @@ export class FormPlugin extends BI.Widget {
connectionData: <ConnectionPlugin>BI.extend({}, connectionData, this.plugin.getValue()), connectionData: <ConnectionPlugin>BI.extend({}, connectionData, this.plugin.getValue()),
}; };
} }
public getSaveFn() {
return this.plugin.save;
}
} }

86
src/modules/pages/maintain/forms/form.ts

@ -6,7 +6,7 @@ import { FormPlugin } from './components/form.plugin';
import { connectionType, errorCode } from '@constants/env'; import { connectionType, errorCode } from '@constants/env';
import { ConnectionJDBC, Connection, ResultType } from 'src/modules/crud/crud.typings'; import { ConnectionJDBC, Connection, ResultType } from 'src/modules/crud/crud.typings';
import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATEBASE_FILTER_TYPE } from '@constants/constant'; import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATEBASE_FILTER_TYPE } from '@constants/constant';
import { getJdbcDatabaseType, getChartLength } from '../../../app.service'; import { getJdbcDatabaseType, getChartLength, getAllDatabaseTypes } from '../../../app.service';
import { NAME_MAX_LENGTH } from '../../../app.constant'; import { NAME_MAX_LENGTH } from '../../../app.constant';
import { checkIllegalStrings } from "@core/index"; import { checkIllegalStrings } from "@core/index";
@ -14,6 +14,7 @@ import { checkIllegalStrings } from "@core/index";
@store(MaintainFormModel) @store(MaintainFormModel)
export class MaintainForm extends BI.Widget { export class MaintainForm extends BI.Widget {
static xtype = 'dec.dcm.maintain.form'; static xtype = 'dec.dcm.maintain.form';
static EVENT_TESTCONNECTION = 'EVENT_TEST_CONNECTION';
props = { props = {
connectionType: '', connectionType: '',
@ -29,34 +30,36 @@ export class MaintainForm extends BI.Widget {
watch = { watch = {
saveEvent: () => { saveEvent: () => {
if (!this.testValue()) { const sonSave = this.form.getSaveFn?.();
return; if (sonSave) {
} sonSave().then((success: boolean) => {
if (this.connectionName && !this.model.isCopy) { if (success) {
const value = this.form.getSubmitValue(); BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Success"), {
(value.connectionData as ConnectionJDBC).creator = BI.get(this.getFormData(), 'creator'); level: "success",
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段 });
value.creator = BI.get(this.getFormData(), 'creator'); } else {
this.store.updateConnection(this.connectionName, value).then(result => { BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), {
if (result.errorCode) { level: "error",
if (result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) { });
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), { }
level: "error", });
});
}
this.showError(result);
//只有外来插件才可以使用是否不执行平台的保存逻辑
if (this.model.datebaseTypeSelected) {
const isPluginDatabase = BI.some(BI.Providers.getProvider('dec.connection.provider.datebase').customDatabaseType, (_index, value) => value.databaseType === this.model.datebaseTypeSelected);
if (isPluginDatabase && this.model.datebaseTypeSelectedOne.isNoSave) {
return; return;
} }
this.store.goFirstPage(); } else {
}); const databaseType = this.model.connectionSelectedOne.connectionType;
} else { const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType);
const form = this.form.getSubmitValue(); if (this.model.connectionSelectedOne.pluginConnection && database?.isNoSave) {
form.connectionId = this.connectionName; return;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段 }
form.creator = Dec ? Dec.personal.username : ''; }
this.addConnection(form);
} }
this.save();
}, },
testEvent: () => { testEvent: () => {
this.testConnection(); this.testConnection();
@ -77,7 +80,7 @@ export class MaintainForm extends BI.Widget {
this.form = _ref; this.form = _ref;
}, },
listeners: [{ listeners: [{
eventName: 'EVENT_TEST_CONNECTION', eventName: MaintainForm.EVENT_TESTCONNECTION,
action: () => { action: () => {
this.testConnection(); this.testConnection();
}, },
@ -295,4 +298,35 @@ export class MaintainForm extends BI.Widget {
this.store.setIsCopy(false); this.store.setIsCopy(false);
}); });
} }
private save() {
if (!this.testValue()) {
return;
}
if (this.connectionName && !this.model.isCopy) {
const value = this.form.getSubmitValue();
(value.connectionData as ConnectionJDBC).creator = BI.get(this.getFormData(), 'creator');
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
value.creator = BI.get(this.getFormData(), 'creator');
this.store.updateConnection(this.connectionName, value).then(result => {
if (result.errorCode) {
if (result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) {
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), {
level: "error",
});
}
this.showError(result);
return;
}
this.store.goFirstPage();
});
} else {
const form = this.form.getSubmitValue();
form.connectionId = this.connectionName;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
form.creator = Dec ? Dec.personal.username : '';
this.addConnection(form);
}
}
} }

3
src/modules/title/title_maintain/title_maintain.model.ts

@ -11,12 +11,13 @@ export class TitleMaintainModel extends Model<{
connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelected: AppModel['TYPE']['connectionSelected'];
testEvent: AppModel['TYPE']['testEvent']; testEvent: AppModel['TYPE']['testEvent'];
isCopy: AppModel['TYPE']['isCopy']; isCopy: AppModel['TYPE']['isCopy'];
noTestConnection: AppModel['TYPE']['noTestConnection'];
}, },
context: TitleMaintainModel['context']; context: TitleMaintainModel['context'];
}> { }> {
static xtype = 'dec.dcm.model.title_maintain'; static xtype = 'dec.dcm.model.title_maintain';
context = <const>['pageIndex', 'saveEvent', 'testEvent', 'connectionSelected', 'isCopy']; context = <const>['pageIndex', 'saveEvent', 'testEvent', 'connectionSelected', 'isCopy', 'noTestConnection'];
actions = { actions = {
setPageIndex: (index: string) => { setPageIndex: (index: string) => {

6
src/modules/title/title_maintain/title_maintain.ts

@ -1,6 +1,7 @@
import { shortcut, store } from '@core/core'; import { shortcut, store } from '@core/core';
import { TitleMaintainModel } from './title_maintain.model'; import { TitleMaintainModel } from './title_maintain.model';
import { PAGE_INDEX } from '@constants/constant'; import { PAGE_INDEX } from '@constants/constant';
import { Button } from '@fui/core';
@shortcut() @shortcut()
@store(TitleMaintainModel) @store(TitleMaintainModel)
@ -9,6 +10,7 @@ export class TitleMaintain extends BI.Widget {
store: TitleMaintainModel['store']; store: TitleMaintainModel['store'];
model: TitleMaintainModel['model']; model: TitleMaintainModel['model'];
render() { render() {
return { return {
type: BI.FloatRightLayout.xtype, type: BI.FloatRightLayout.xtype,
@ -30,6 +32,10 @@ export class TitleMaintain extends BI.Widget {
}, },
{ {
type: BI.Button.xtype, type: BI.Button.xtype,
ref: (_ref) => {
this.testConnectionBtn = _ref;
},
invisible: () => this.model.noTestConnection,
_rgap: 16, _rgap: 16,
$value: 'title-maintain-connection-test', $value: 'title-maintain-connection-test',
text: BI.i18nText('Dec-Dcm_Connection_Test'), text: BI.i18nText('Dec-Dcm_Connection_Test'),

Loading…
Cancel
Save