Browse Source

Merge pull request #2789 in DEC/decision-webui-dcm from release/11.0 to feature/x

* commit 'f414107f3e50a0ed3ffdcb5778f250bf4238fb4c':
  DEC-19760 feat: 【BI配合】驱动管理
  DEC-20237 fix: 【迭代】【驱动管理】使用某个自定义驱动新建数据连接,下拉框选中后再次下拉,使用相同驱动文件的的所有自定义驱动都会标蓝选中
  DEC-20235 fix: 【迭代】【驱动管理】新建数据连接选择自定义驱动,点击添加驱动再退出,所有没有选择驱动类的自定义驱动标蓝显示
  DEC-20201 fix: 【迭代】【驱动管理】切换为自定义驱动,已经填好的数据库信息不会保存
  DEC-19760 feat: 【BI配合】驱动管理,war包部署不支持提醒
  DEC-20204 fix: 【迭代】【驱动管理】次管权限没有限制,可以进入驱动管理页面
  DEC-20200 fix: 【迭代】【驱动管理】新建数据连接,选择自定义驱动,保存后显示默认驱动
  DEC-20201 fix: 【迭代】【驱动管理】切换为自定义驱动,已经填好的数据库信息不会保存
  DEC-20047 fix: 【迭代】【部分数据连接支持fetchSize】平台设置fetchSize为空回填数值为0
  DEC-20026 fix: 【自动化】数据连接-新增JNDI类型数据连接无法保存和测试连接
  DEC-20036 fix: 【自动化】数据连接管理-其他JDBC类型,切换驱动类型后URL没有联动变化
  DEC-20078 fix: 【迭代】【部分数据连接支持fetchSize】JNDI数据连接新建、编辑页面的「测试连接」、「保存」按钮点击无反应
  DEC-19879 feat: 驱动管理-前端
research/11.0
superman 3 years ago
parent
commit
ac83e11f48
  1. 5
      src/modules/crud/api.ts
  2. 8
      src/modules/crud/decision.api.ts
  3. 9
      src/modules/pages/connection/connection.ts
  4. 7
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  5. 126
      src/modules/pages/maintain/components/driverselector/driverselector.model.ts
  6. 185
      src/modules/pages/maintain/components/driverselector/driverselector.ts
  7. 67
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  8. 11
      src/modules/pages/maintain/forms/form.ts

5
src/modules/crud/api.ts

@ -52,6 +52,11 @@ export interface Api {
*/ */
getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>; getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>;
/**
*
*/
getSimpleDriverList(): Promise<{ data?: any[] }>;
/** /**
* *
* @param name * @param name

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

@ -52,6 +52,14 @@ export class DecisionApi implements Api {
return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {}); 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<SocketResult> { getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN) return this.sendEditStatusEvent(name, editStatusEvent.OPEN)
.then(re => { .then(re => {

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

@ -79,7 +79,16 @@ export class Connection extends BI.Widget {
right: [ right: [
{ {
type: 'dec.connection.driver.entry', type: 'dec.connection.driver.entry',
invisible: !BI.Services.getService('dec.service.global').isAdmin(),
from: '.dec-dcm', from: '.dec-dcm',
listeners: [
{
eventName: 'EVENT_CLOSE',
action: () => {
this.reset();
},
},
],
}, },
], ],
}, },

7
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 connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { const {
driver, driver,
driverSource,
database, database,
user, user,
originalCharsetName, originalCharsetName,
@ -45,7 +46,7 @@ export class ConnectionJdbc extends BI.Widget {
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: driver, value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -182,9 +183,9 @@ export class ConnectionJdbc extends BI.Widget {
unit: BI.i18nText('BI-Basic_Seconds'), unit: BI.i18nText('BI-Basic_Seconds'),
}, { }, {
type: FormItem.xtype, type: FormItem.xtype,
invisible: BI.parseInt(fetchSize) < 0, invisible: fetchSize < 0 && fetchSize !== -2,
name: 'Fetchsize', name: 'Fetchsize',
value: fetchSize, value: fetchSize === -2 ? '' : fetchSize,
}, },
], ],
}, },

126
src/modules/pages/maintain/components/driverselector/driverselector.model.ts

@ -0,0 +1,126 @@
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 : '',
value: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '',
},
};
};
computed = {
driverClassItems: () => this.model.customDrivers.map(driver => {
return {
text: `${driver.driverClass} (${driver.name})`,
value: `${driver.driverClass} (${driver.name})`,
driverClass: 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.filter(driver => {
return BI.isKey(driver.driverClass);
});
cb();
});
},
changeDefaultDriver: driver => {
this.model.defaultDriver.driver = driver;
this.model.driverSource = '';
},
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.value = `${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;
};
}

185
src/modules/pages/maintain/components/driverselector/driverselector.ts

@ -0,0 +1,185 @@
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.value);
},
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);
this.fireEvent('EVENT_CHANGE');
return;
}
this.defaultDrivers.setVisible(false);
this.customDrivers.setVisible(true);
if (BI.isKey(this.customDrivers.getValue()[0])) {
this.fireEvent('EVENT_CHANGE');
}
},
},
],
},
}, {
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());
this.fireEvent('EVENT_CHANGE');
},
},
],
},
}, {
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.value,
text: () => this.model.customDriver.value || '',
defaultText: 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]);
this.fireEvent('EVENT_CHANGE');
},
},
],
},
}, {
el: {
type: 'dec.connection.driver.entry',
ref: (_ref: Button) => {
this.driverManageEntry = _ref;
},
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);
},
},
],
},
},
],
};
}
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,
};
}
}

67
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -16,6 +16,7 @@ import {
TextValueCombo, TextValueCombo,
VerticalLayout, VerticalLayout,
} from '@fui/core'; } from '@fui/core';
import { DriverSelector } from '../../components/driverselector/driverselector';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
@ -70,6 +71,7 @@ export class FormJdbc extends BI.Widget {
const { connectionName, connectionData } = this.options.formData; const { connectionName, connectionData } = this.options.formData;
const { const {
driver, driver,
driverSource,
user, user,
password, password,
originalCharsetName, originalCharsetName,
@ -130,31 +132,34 @@ export class FormJdbc extends BI.Widget {
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
forms: [{ forms: [
type: BI.EditorIconCheckCombo.xtype, {
$testId: 'dec-editor-icon-check-combo', type: DriverSelector.xtype,
$value: 'driver', ref: (_ref: DriverSelector) => {
width: 300, this.form.driver = _ref;
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);
}, },
}], driver,
}], driverSource,
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);
// DEC-2020
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);
this.form.database.setValue(urlInfo.databaseName);
this.form.port.setValue(urlInfo.port);
},
},
],
},
],
}, },
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -708,7 +713,7 @@ export class FormJdbc extends BI.Widget {
el: { el: {
type: BI.VerticalLayout.xtype, type: BI.VerticalLayout.xtype,
cls: 'bi-border-top', cls: 'bi-border-top',
invisible: BI.parseInt(fetchSize) < 0, invisible: fetchSize < 0 && fetchSize !== -2,
items: [ items: [
{ {
el: { el: {
@ -719,7 +724,7 @@ export class FormJdbc extends BI.Widget {
$value: 'fetch-size', $value: 'fetch-size',
width: 300, width: 300,
allowBlank: true, allowBlank: true,
value: fetchSize, value: fetchSize === -2 ? '' : fetchSize,
watermark: 'Fetchsize', watermark: 'Fetchsize',
validationChecker: [{ validationChecker: [{
errorText: BI.i18nText('Dec-Dcm_Connection_Check_Fetch_Size_Range'), errorText: BI.i18nText('Dec-Dcm_Connection_Check_Fetch_Size_Range'),
@ -802,7 +807,7 @@ export class FormJdbc extends BI.Widget {
private onHostPortChange(databaseType) { private onHostPortChange(databaseType) {
const { urls, url } = databaseType; const { urls, url } = databaseType;
const driver = this.form.driver.getValue(); 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 host = this.form.host.getValue();
const port = this.form.port.getValue(); const port = this.form.port.getValue();
const database = this.form.database.getValue(); const database = this.form.database.getValue();
@ -823,6 +828,10 @@ export class FormJdbc extends BI.Widget {
} }
} }
public validation(): boolean {
return this.form.driver.validation();
}
public getSubmitValue(): Connection { public getSubmitValue(): Connection {
const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionPoolAttr = connectionData.connectionPoolAttr; const connectionPoolAttr = connectionData.connectionPoolAttr;
@ -836,7 +845,7 @@ export class FormJdbc extends BI.Widget {
connectionData: <ConnectionJDBC>BI.extend({}, connectionData, { connectionData: <ConnectionJDBC>BI.extend({}, connectionData, {
database: connectionData.database, database: connectionData.database,
connectionName: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(),
driver: this.form.driver.getValue(), ...this.form.driver.getValue(),
url: this.form.url.getValue(), url: this.form.url.getValue(),
user: this.form.user.getValue(), user: this.form.user.getValue(),
password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()), password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : api.getCipher(this.form.password.getValue()),
@ -849,7 +858,7 @@ export class FormJdbc extends BI.Widget {
creator: Dec ? Dec.personal.username : '', creator: Dec ? Dec.personal.username : '',
principal: this.form.principal.getValue(), principal: this.form.principal.getValue(),
keyPath: this.form.keyPath.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: { connectionPoolAttr: {
initialSize: this.form.initialSize.getValue(), initialSize: this.form.initialSize.getValue(),
maxActive: this.form.maxActive.getValue(), maxActive: this.form.maxActive.getValue(),

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

@ -197,6 +197,10 @@ export class MaintainForm extends BI.Widget {
return false; return false;
} }
if (this.form.validation && !this.form.validation()) {
return false;
}
return true; return true;
} }
@ -223,13 +227,18 @@ export class MaintainForm extends BI.Widget {
if (!formValue.connectionName) { if (!formValue.connectionName) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null')); this.setFromError(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'));
return; return false;
} }
if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) { if (getChartLength(formValue.connectionName) > NAME_MAX_LENGTH) {
this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH)); this.setFromError(BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH));
return false; return false;
} }
if (this.form.validation && !this.form.validation()) {
return false;
}
if (this.isEdit || this.model.isCopy) { if (this.isEdit || this.model.isCopy) {
formValue.connectionId = this.connectionName; formValue.connectionId = this.connectionName;
} }

Loading…
Cancel
Save