You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
388 lines
17 KiB
388 lines
17 KiB
import { shortcut, store } from '@core/core'; |
|
import { FormItem } from '../components/form_item/form_item'; |
|
import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; |
|
import { ConnectionJdecModel } from './connection_jdbc.model'; |
|
import { ConnectionJDBC } from 'src/modules/crud/crud.typings'; |
|
import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../app.service'; |
|
import { CONNECTION_LAYOUT, CONNECT_SSH_TYPE } from '@constants/constant'; |
|
import { VerticalLayout } from '@fui/core'; |
|
import { ApiFactory } from '../../../crud/apiFactory'; |
|
|
|
const api = new ApiFactory().create(); |
|
|
|
@shortcut() |
|
@store(ConnectionJdecModel) |
|
export class ConnectionJdbc extends BI.Widget { |
|
static xtype = 'dec.dcm.connection_jdbc'; |
|
|
|
model: ConnectionJdecModel['model']; |
|
allDatabaseTypes = getAllDatabaseTypes(); |
|
|
|
sshSet: VerticalLayout; |
|
sslSet: VerticalLayout; |
|
advancedSet: VerticalLayout; |
|
parallelLoadSet: VerticalLayout; |
|
|
|
render() { |
|
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC; |
|
const { |
|
driver, |
|
driverSource, |
|
database, |
|
user, |
|
originalCharsetName, |
|
schema, |
|
connectionPoolAttr, |
|
authType, |
|
principal, |
|
url, |
|
fetchSize, |
|
// ssh |
|
usingSsh, |
|
sshIp, |
|
sshPort, |
|
sshUser, |
|
sshType, |
|
sshSecret, |
|
sshPrivateKeyPath, |
|
// ssl |
|
usingSsl, |
|
caCertificate, |
|
verifyCa, |
|
sslClientPrivateKey, |
|
sslClientCertificate, |
|
// 并行装载 |
|
parallelLoad, |
|
// HDFS |
|
hdfs, |
|
} = connectionData; |
|
const databaseType = getJdbcDatabaseType(database, driver); |
|
const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database); |
|
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; |
|
const { hgap, vgap } = CONNECTION_LAYOUT; |
|
|
|
return { |
|
type: BI.VerticalLayout.xtype, |
|
hgap, |
|
vgap, |
|
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, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: 'catalog', |
|
invisible: database !== 'starrocks', |
|
value: catalog, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'), |
|
value: databaseName, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Host'), |
|
value: host, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'), |
|
value: port, |
|
}, |
|
authType |
|
? { |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_AuthType'), |
|
value: authType, |
|
} |
|
: { |
|
type: BI.Layout.xtype, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_Principal') : BI.i18nText('Dec-Dcm_Connection_Form_UserName'), |
|
value: authType ? principal : user, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'), |
|
value: '******', |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), |
|
value: originalCharsetName ? originalCharsetName : BI.i18nText('Dec-Dcm_Connection_Form_Default'), |
|
}, |
|
// HDFS设置 |
|
{ |
|
type: FormItem.xtype, |
|
invisible: BI.isNull(hdfs), |
|
name: BI.i18nText('Dec-Dcm_Connection_Address', 'HDFS'), |
|
value: hdfs?.hdfsAddress, |
|
}, |
|
// 并行装载设置 |
|
{ |
|
type: Collapse.xtype, |
|
invisible: BI.isNull(parallelLoad), |
|
name: BI.i18nText('Dec-Dcm_Connection_Setting', BI.i18nText('Dec-Dcm_Connection_Parallel_Load')), |
|
listeners: [ |
|
{ |
|
eventName: EVENT_CHANGE, |
|
action: (isCollapse: boolean) => { |
|
this.parallelLoadSet.setVisible(!isCollapse); |
|
}, |
|
}, |
|
], |
|
}, |
|
{ |
|
type: BI.VerticalLayout.xtype, |
|
invisible: true, |
|
ref: (_ref: VerticalLayout) => { |
|
this.parallelLoadSet = _ref; |
|
}, |
|
items: [ |
|
{ |
|
type: FormItem.xtype, |
|
_bgap: vgap, |
|
name: `${BI.i18nText('Dec-Dcm_Connection_Server_Address')}-${BI.i18nText('Dec-Memory_Detection_Server_Cluster_Node', '1')}`, |
|
value: parallelLoad?.serverAddress, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
_bgap: vgap, |
|
name: BI.i18nText('Dec-Dcm_Connection_Reuse_Temporary_Table'), |
|
value: parallelLoad?.reuseTemporaryTable, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
_bgap: vgap, |
|
name: BI.i18nText('Dec-Dcm_Connection_Temporary_File_Pieces_Limit'), |
|
value: parallelLoad?.filePiecesLimit, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Temporary_File_Size_Limit'), |
|
value: parallelLoad?.fileSizeLimit, |
|
}, |
|
], |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'), |
|
value: schema, |
|
invisible: !databaseType.hasSchema, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'), |
|
value: url, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), |
|
value: connectionPoolAttr.maxActive, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'), |
|
value: connectionPoolAttr.testOnBorrow ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'), |
|
value: api.getPlain(connectionPoolAttr.validationQuery || ''), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), |
|
value: connectionPoolAttr.maxWait, |
|
unit: BI.i18nText('Dec-Dcm_Millisecond'), |
|
}, |
|
// ssh设置 |
|
{ |
|
type: Collapse.xtype, |
|
width: 100, |
|
invisible: !usingSsh, |
|
name: BI.i18nText('Dec-Dcm_Connection_Setting', 'SSH'), |
|
listeners: [ |
|
{ |
|
eventName: EVENT_CHANGE, |
|
action: (isCollapse: boolean) => { |
|
this.sshSet.setVisible(!isCollapse); |
|
}, |
|
}, |
|
], |
|
}, |
|
{ |
|
el: { |
|
type: BI.VerticalLayout.xtype, |
|
bgap: vgap, |
|
invisible: true, |
|
ref: (_ref: VerticalLayout) => { |
|
this.sshSet = _ref; |
|
}, |
|
items: [ |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Host'), |
|
value: sshIp, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'), |
|
value: sshPort, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_UserName'), |
|
value: sshUser, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_VerifyType'), |
|
value: CONNECT_SSH_TYPE.find((SSH_TYPE) => sshType === SSH_TYPE.value).text, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
invisible: sshType !== 'KEY', |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_PrivateKey'), |
|
value: sshPrivateKeyPath, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: CONNECT_SSH_TYPE.find((SSH_TYPE) => sshType === SSH_TYPE.value).secretFormName, |
|
value: sshSecret, |
|
}, |
|
], |
|
}, |
|
}, |
|
// ssl设置 |
|
{ |
|
type: Collapse.xtype, |
|
width: 100, |
|
invisible: !usingSsl, |
|
name: BI.i18nText('Dec-Dcm_Connection_Setting', 'SSL'), |
|
listeners: [ |
|
{ |
|
eventName: EVENT_CHANGE, |
|
action: (isCollapse: boolean) => { |
|
this.sslSet.setVisible(!isCollapse); |
|
}, |
|
}, |
|
], |
|
}, |
|
{ |
|
el: { |
|
type: BI.VerticalLayout.xtype, |
|
bgap: vgap, |
|
invisible: true, |
|
ref: (_ref: VerticalLayout) => { |
|
this.sslSet = _ref; |
|
}, |
|
items: [ |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_CA_Certificate'), |
|
value: caCertificate, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
invisible: !caCertificate, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Verify_CA_Certificate'), |
|
value: verifyCa ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Client') + BI.i18nText('Dec-Dcm_Connection_Form_SecretKey'), |
|
value: sslClientPrivateKey, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Client') + BI.i18nText('Dec-Dcm_Connection_Form_Certificate'), |
|
value: sslClientCertificate, |
|
}, |
|
], |
|
}, |
|
}, |
|
// 更多设置 |
|
{ |
|
type: Collapse.xtype, |
|
width: 100, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_More_Setting'), |
|
listeners: [ |
|
{ |
|
eventName: EVENT_CHANGE, |
|
action: (isCollapse: boolean) => { |
|
this.advancedSet.setVisible(!isCollapse); |
|
}, |
|
}, |
|
], |
|
}, |
|
{ |
|
el: { |
|
type: BI.VerticalLayout.xtype, |
|
bgap: vgap, |
|
invisible: true, |
|
ref: (_ref: VerticalLayout) => { |
|
this.advancedSet = _ref; |
|
}, |
|
items: [ |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'), |
|
value: connectionPoolAttr.initialSize, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'), |
|
value: connectionPoolAttr.minIdle, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Return'), |
|
value: connectionPoolAttr.testOnReturn ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_While_Idle'), |
|
value: connectionPoolAttr.testWhileIdle ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), |
|
value: connectionPoolAttr.timeBetweenEvictionRunsMillis, |
|
unit: BI.i18nText('Dec-Dcm_Millisecond'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), |
|
value: connectionPoolAttr.numTestsPerEvictionRun, |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), |
|
value: connectionPoolAttr.minEvictableIdleTimeMillis, |
|
unit: BI.i18nText('BI-Basic_Seconds'), |
|
}, |
|
{ |
|
type: FormItem.xtype, |
|
name: 'Fetchsize', |
|
value: fetchSize, |
|
}, |
|
], |
|
}, |
|
}, |
|
], |
|
}; |
|
} |
|
}
|
|
|