Browse Source

REPORT-102763 fix:【开个接口】数据连接支持对接业务系统-补充

feature/x
parent
commit
3b71fdbdea
  1. 30
      README.md
  2. 6
      src/modules/pages/connection/connection.model.ts
  3. 3
      src/modules/pages/connection/connection.ts
  4. 1
      src/modules/pages/database/database.constant.ts
  5. 7
      src/modules/pages/database/database_type/database_type.model.ts
  6. 1
      src/modules/pages/database/database_type/database_type.ts
  7. 14
      src/modules/pages/maintain/forms/components/form.plugin.ts
  8. 1
      src/modules/pages/maintain/forms/form.model.ts
  9. 29
      src/modules/pages/maintain/forms/form.ts
  10. 3
      src/modules/title/title.model.ts
  11. 9
      src/modules/title/title_maintain/title_maintain.ts

30
README.md

@ -216,21 +216,6 @@ const RedisShow = BI.inherit(BI.Widget, {
},
],
},
mounted() {
this.fireEvent('EVENT_HIDE_TEST_CONNECTION', true);//可以触发隐藏测试按钮
},
//可以触发组件的数据save方法,不需要则可不写
async save() {
let result = 0;
await Promise.resolve().then(() => {result = 1});
//要求返回是否成功的boolean变量
return result;
},
//可以阻止触发平台保存数据的方法
preventParentSave() {
return true;
}
},
});
BI.shortcut(RedisShowName, RedisShow);
@ -325,6 +310,13 @@ const RedisEdit = BI.inherit(BI.Widget, {
password: this.password.getValue(),
};
},
//可以触发组件的数据save方法,不需要则可不写
async save() {
let result = false;
await Promise.resolve().then(() => {result = true});
//要求返回是否成功的boolean变量
return result;
},
});
BI.shortcut(RedisEditName, RedisEdit);
@ -349,7 +341,11 @@ BI.config('dec.constant.connection.list', function (value) {
#### 1. 添加分类DEMO
```js
BI.config('dec.constant.database.filter.type', (value) => {
value.push({text:"DEMO", value:"DEMO_VALUE"});return value;
value.push({
text:"DEMO",
value:"DEMO_VALUE"
});
return value;
});
```
#### 2. 添加数据连接类型进DEMO
@ -358,6 +354,8 @@ BI.config('dec.constant.database.filter.type', (value) => {
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'],

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

@ -13,13 +13,14 @@ export class ConnectionModel extends Model<{
connectionSelected: AppModel['TYPE']['connectionSelected'];
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
noTestConnection: AppModel['TYPE']['noTestConnection'];
},
childContext: ConnectionModel['childContext'];
context: ConnectionModel['context'];
}> {
static xtype = 'dec.dcm.model.connection';
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo'];
context = <const>['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo', 'noTestConnection'];
actions = {
initConnectionLicInfo: (cb: Function) => {
@ -58,6 +59,9 @@ export class ConnectionModel extends Model<{
}
return api.getConnectionStatus(this.model.connectionSelected);
},
setNoTestConnection(value: boolean) {
this.model.noTestConnection = value;
},
checkConnectionLic() {
return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum;
},

3
src/modules/pages/connection/connection.ts

@ -138,7 +138,10 @@ export class Connection extends BI.Widget {
handler: () => {
this.store.getConnectionStatus()
.then(() => {
const databaseType = this.model.connectionSelectedOne.connectionType;
const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType);
this.setMaintainPage();
this.store.setNoTestConnection(database.isHideConnection);
})
.catch(() => {
});

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

@ -1,6 +1,5 @@
import { DATEBASE_FILTER_TYPE } from "@constants/constant";
console.log('contant');
BI.constant('dec.constant.database.filter.type', [
{
text: BI.i18nText('Dec-Dcm_Connection_Commonly'),

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

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

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

@ -70,6 +70,7 @@ export class DatebaseType extends BI.BasicButton {
const { value } = this.options;
this.store.setDatebaseTypeSelected(value);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setNoTestConnection(this.model.datebaseTypeSelectedOne.isHideConnection);
}
mounted() {

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

@ -5,8 +5,6 @@ import { getPluginWidgetEdit } from '../../../../app.service';
@shortcut()
export class FormPlugin extends BI.Widget {
static xtype = 'dec.dcm.maintain_plugin';
static EVENTNOTEST = 'EVENT_HIDE_TEST_CONNECTION';
static PREVENTPARENTSAVE = 'EVENT_PREVENT_PARENT_SAVE';
props = {
formData: {} as Connection,
};
@ -26,12 +24,6 @@ export class FormPlugin extends BI.Widget {
connectionId,
connectionType,
connectionName,
listeners: [{
eventName: FormPlugin.EVENTNOTEST,
action: (value: boolean) => {
this.fireEvent(FormPlugin.EVENTNOTEST, value);
}
}]
};
}
@ -46,11 +38,7 @@ export class FormPlugin extends BI.Widget {
};
}
public save() {
public getSaveFn() {
return this.plugin.save;
}
public preventParentSave() {
return this.plugin.preventParentSave ? this.plugin.preventParentSave() : false;
}
}

1
src/modules/pages/maintain/forms/form.model.ts

@ -31,7 +31,6 @@ export class MaintainFormModel extends Model<{
'testEvent',
'connections',
'isCopy',
'noTestConnection',
];
actions = {

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

@ -6,7 +6,7 @@ import { FormPlugin } from './components/form.plugin';
import { connectionType, errorCode } from '@constants/env';
import { ConnectionJDBC, Connection, ResultType } from 'src/modules/crud/crud.typings';
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 { checkIllegalStrings } from "@core/index";
@ -14,8 +14,7 @@ import { checkIllegalStrings } from "@core/index";
@store(MaintainFormModel)
export class MaintainForm extends BI.Widget {
static xtype = 'dec.dcm.maintain.form';
static TESTCONNECTION = 'EVENT_TEST_CONNECTION';
static EVENTNOTEST = 'EVENT_HIDE_TEST_CONNECTION';
static EVENT_TESTCONNECTION = 'EVENT_TEST_CONNECTION';
props = {
connectionType: '',
@ -31,9 +30,9 @@ export class MaintainForm extends BI.Widget {
watch = {
saveEvent: () => {
const sonSave = this.form.save?.();
const sonSave = this.form.getSaveFn?.();
if (sonSave) {
sonSave().then((success: Boolean) => {
sonSave().then((success: boolean) => {
if (success) {
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Success"), {
level: "success",
@ -45,9 +44,20 @@ export class MaintainForm extends BI.Widget {
}
});
if (this.form.preventParentSave()) {
//只有外来插件才可以使用是否不执行平台的保存逻辑
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;
}
} else {
const databaseType = this.model.connectionSelectedOne.connectionType;
const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType);
if (this.model.connectionSelectedOne.pluginConnection && database?.isNoSave) {
return;
}
}
}
this.save();
},
@ -70,15 +80,10 @@ export class MaintainForm extends BI.Widget {
this.form = _ref;
},
listeners: [{
eventName: MaintainForm.TESTCONNECTION,
eventName: MaintainForm.EVENT_TESTCONNECTION,
action: () => {
this.testConnection();
},
}, {
eventName: MaintainForm.EVENTNOTEST,
action: (value: boolean) => {
this.model.noTestConnection = value;
}
}],
};
}

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

@ -6,13 +6,12 @@ export class TitleModel extends Model<{
types: {
pageIndex: AppModel['TYPE']['pageIndex'];
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected'];
noTestConnection: AppModel['TYPE']['noTestConnection'];
},
context: TitleModel['context'];
}> {
static xtype = 'dec.dcm.model.title';
context = <const>['pageIndex', 'datebaseTypeSelected', 'noTestConnection']
context = <const>['pageIndex', 'datebaseTypeSelected']
actions = {
setPageIndex: (index: string) => {

9
src/modules/title/title_maintain/title_maintain.ts

@ -10,13 +10,6 @@ export class TitleMaintain extends BI.Widget {
store: TitleMaintainModel['store'];
model: TitleMaintainModel['model'];
testConnectionBtn: Button;
watch = {
noTestConnection: function (value) {
this.testConnectionBtn.setVisible(!value);
}
}
render() {
return {
@ -42,6 +35,7 @@ export class TitleMaintain extends BI.Widget {
ref: (_ref) => {
this.testConnectionBtn = _ref;
},
invisible: () => this.model.noTestConnection,
_rgap: 16,
$value: 'title-maintain-connection-test',
text: BI.i18nText('Dec-Dcm_Connection_Test'),
@ -69,6 +63,5 @@ export class TitleMaintain extends BI.Widget {
window.onunload = () => {
this.store.shutdownConnectionStatus();
};
this.testConnectionBtn.setVisible(!this.model.noTestConnection);
}
}

Loading…
Cancel
Save