Browse Source

REPORT-87662 feat:数据连接添加版本选择

feature/x
Aries.lsy 2 years ago
parent
commit
9f5eb9077d
  1. 6
      src/modules/app.typings.d.ts
  2. 4
      src/modules/components/collapse/collapse.ts
  3. 10
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  4. 14
      src/modules/pages/maintain/components/driverselector/driverselector.model.ts
  5. 11
      src/modules/pages/maintain/components/driverselector/driverselector.ts
  6. 52
      src/modules/pages/maintain/forms/components/form.jdbc.ts

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

@ -8,9 +8,13 @@ export interface DatabaseType {
internal: boolean;
type: string;
hasSchema?: boolean;
hasSchemas?: {
[key: string]: boolean;
};
kerberos?: boolean;
iconUrl?: string;
versions?: string[];
urls?: {
[key: string]: string;
}
};
}

4
src/modules/components/collapse/collapse.ts

@ -64,4 +64,8 @@ export class Collapse extends BI.BasicButton {
doClick() {
this.store.setCollapse(!this.model.isCollapse);
}
setCollapse(v: boolean) {
this.store.setCollapse(v);
}
}

10
src/modules/pages/connection/connection_jdbc/connection_jdbc.ts

@ -52,7 +52,8 @@ export class ConnectionJdbc extends BI.Widget {
sslClientCertificate,
} = connectionData;
const databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName } = resolveUrlInfo(url, database);
const { host, port, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT;
return {
@ -62,6 +63,13 @@ export class ConnectionJdbc extends BI.Widget {
items: [
{
type: FormItem.xtype,
name: BI.i18nText('Dec-Basic_Version'),
invisible: BI.isUndefined(this.version),
value: BI.i18nText('Dec-Migration_Database_Version', this.version),
},
{
type: FormItem.xtype,
_tgap: BI.isUndefined(this.version) ? vgap : 0,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
},

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

@ -87,6 +87,12 @@ export class DriverSelectorModel extends Model {
changeDriverSource: driverTypeComboValue => {
this.model.driverSource = driverTypeComboValue === 'default' ? '' : this.model.driverSource;
},
setDefaultDrivers: version => {
const defaultDrivers = this.getDrivers(version);
this.model.defaultDrivers = defaultDrivers;
this.changeDefaultDriver(defaultDrivers[0]?.value);
}
};
private resolveSelectedDriverType = () => {
@ -97,11 +103,12 @@ export class DriverSelectorModel extends Model {
return [this.options.driverSource, this.options.driver];
};
private getDrivers = () => {
private getDrivers = (version?: string) => {
const connectionData = this.options.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);
const selectedVersion = version ?? this.options.version;
const drivers = connectionType.drivers ?
connectionType.drivers.map(item => {
(BI.isUndefined(connectionType.versions) ? connectionType.drivers : connectionType.drivers[selectedVersion]).map(item => {
return {
text: item,
value: item,
@ -111,8 +118,7 @@ export class DriverSelectorModel extends Model {
text: connectionType.driver,
value: connectionType.driver,
}];
if (!drivers.some(item => item.text === connectionData.driver)) {
if (BI.isUndefined(connectionType.versions) && !drivers.some(item => item.text === connectionData.driver)) {
return [
{
text: connectionData.driver,

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

@ -24,6 +24,7 @@ export class DriverSelector extends BI.Widget {
driver: '',
driverSource: '',
connectionData: {} as ConnectionJDBC,
version: '',
};
defaultDrivers: EditorIconCheckCombo = null;
@ -43,6 +44,12 @@ export class DriverSelector extends BI.Widget {
driverManageEntryVisible: b => {
this.driverManageEntry.setVisible(b);
},
defaultDrivers: items => {
this.defaultDrivers.populate(items);
this.defaultDrivers.setValue(this.model.defaultDriver.driver);
this.fireEvent('EVENT_CHANGE');
}
};
private driverManageEntry = null;
@ -182,4 +189,8 @@ export class DriverSelector extends BI.Widget {
driver: this.model.driverSource === '' ? this.model.defaultDriver.driver : this.model.customDriver.driver,
};
}
setDefaultDrivers(version: string) {
this.store.setDefaultDrivers(version);
}
}

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

@ -40,9 +40,11 @@ export class FormJdbc extends BI.Widget {
formKeyPath: FormItem;
formKrb5File: FormItem;
labelTips: Label;
schemaForm: FormItem;
form = {
connectionName: null,
version: null,
driver: null,
database: null,
host: null,
@ -138,8 +140,8 @@ export class FormJdbc extends BI.Widget {
} = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver);
this.databaseType = databaseType;
const { host, port, databaseName } = resolveUrlInfo(url, database);
const { host, port, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT;
const valueRangeConfig = {
@ -171,6 +173,41 @@ export class FormJdbc extends BI.Widget {
},
],
},
// 版本
{
type: FormItem.xtype,
name: BI.i18nText('Dec-Basic_Version'),
invisible: BI.isUndefined(databaseType.versions),
forms: [
{
type: BI.TextValueCombo.xtype,
width: 300,
value: this.version,
items: () => databaseType.versions.map(item => {
return {
text: BI.i18nText('Dec-Migration_Database_Version', item),
value: item,
}
}),
ref: (_ref: TextValueCombo) => {
this.form.version = _ref;
},
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: () => {
const version = this.form.version.getValue()[0];
this.version = version;
this.sslCollapse.setCollapse(true);
this.sslCollapse.setVisible(this.getSslSetEnabled());
!BI.isUndefined(databaseType.hasSchemas) && this.schemaForm.setVisible(databaseType.hasSchemas[version]);
this.form.driver.setDefaultDrivers(version);
},
},
],
},
],
},
// 驱动
{
type: FormItem.xtype,
@ -184,6 +221,7 @@ export class FormJdbc extends BI.Widget {
driver,
driverSource,
connectionData,
version: this.version,
listeners: [
{
eventName: 'EVENT_CHANGE',
@ -510,7 +548,7 @@ export class FormJdbc extends BI.Widget {
// 模式
{
type: FormItem.xtype,
invisible: !databaseType.hasSchema,
invisible: BI.isUndefined(databaseType.hasSchemas) ? !databaseType.hasSchema : !databaseType.hasSchemas[this.version],
height: 64,
name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
forms: [
@ -551,6 +589,9 @@ export class FormJdbc extends BI.Widget {
],
},
],
ref: (_ref: FormItem) => {
this.schemaForm = _ref;
},
},
// 分隔线
{
@ -866,6 +907,9 @@ export class FormJdbc extends BI.Widget {
width: 100,
name: BI.i18nText('Dec-Dcm_Connection_Setting', 'SSL'),
invisible: !this.getSslSetEnabled(),
ref: (_ref: Collapse) => {
this.sslCollapse = _ref;
},
listeners: [
{
eventName: EVENT_CHANGE,
@ -1309,7 +1353,7 @@ export class FormJdbc extends BI.Widget {
private getSslSetEnabled(): boolean {
const { databaseType } = this.databaseType;
return databaseType === 'mysql';
return databaseType === 'mysql' || this.version === 'mysql';
}
public setSchemas(schemas: string[]) {

Loading…
Cancel
Save