帆软决策平台数据连接界面库
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.

155 lines
6.9 KiB

import { shortcut, store } from '@core/core';
import { Vertical } from 'ui';
import { FormItemXtype } from '../components/form_item/form_item';
import { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import { ConnectionJdbcModelXtype, ConnectionJdecModel } from './connection_jdbc.model';
import { ConnectionJDBC } from 'src/modules/crud/crud.typings';
import { getAllDatabaseTypes, getJdbcDatabaseType } from '../../../app.service';
export const ConnectionJdbcXtype = 'dec.dcm.connection_jdbc';
@shortcut(ConnectionJdbcXtype)
@store(ConnectionJdbcModelXtype)
export class ConnectionJdbc extends BI.Widget {
advancedSet: any;
model: ConnectionJdecModel['model'];
allDatabaseTypes = getAllDatabaseTypes();
render () {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { driver, database, host, user, newCharsetName, schema, connectionPool, port, authType, principal, keyPath, url } = connectionData;
const databaseType = getJdbcDatabaseType(database, driver);
return {
type: Vertical,
hgap: 15,
vgap: 10,
items: [
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: driver,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),
value: databaseType.databaseType,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Host'),
value: host,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'),
value: port === 0 ? '' : port,
},
{
type: FormItemXtype,
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_Principal') : BI.i18nText('Dec-Dcm_Connection_Form_UserName'),
value: authType ? user : principal,
},
{
type: FormItemXtype,
name: authType ? BI.i18nText('Dec-Dcm_Connection_Form_KeyPath') : BI.i18nText('Dec-Dcm_Connection_Form_Password'),
value: authType ? keyPath : '******',
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),
value: newCharsetName ? newCharsetName : BI.i18nText('Dec-Dcm_Connection_Form_Auto'),
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
value: schema,
invisible: !databaseType.hasSchema,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'),
value: url,
},
{
type: CollapseXtype,
width: 70,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Advanced_Setting'),
listeners: [
{
eventName: EVENT_CHANGE,
action: (isCollapse: boolean) => {
this.advancedSet.setVisible(!isCollapse);
},
},
],
},
{
type: Vertical,
vgap: 10,
invisible: true,
ref: (_ref: any) => {
this.advancedSet = _ref;
},
items: [
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'),
value: connectionPool.initialSize,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'),
value: connectionPool.maxActive,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'),
value: connectionPool.maxIdle,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'),
value: connectionPool.maxWait,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Validation_Query'),
value: connectionPool.validationQuery,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Borrow'),
value: connectionPool.testOnBorrow,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_On_Return'),
value: connectionPool.testOnReturn,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_While_Idle'),
value: connectionPool.testWhileIdle,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'),
value: connectionPool.timeBetweenEvictionRunsMillis,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'),
value: connectionPool.numTestsPerEvictionRun,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'),
value: connectionPool.minEvictableIdleTimeMillis,
},
],
},
],
};
}
}