@ -5,6 +5,7 @@ import { TestStatus } from '../../../components/test_status/test_status';
import { getJdbcDatabaseType } from '../../../app.service' ;
import { getJdbcDatabaseType } from '../../../app.service' ;
import { ApiFactory } from '../../../crud/apiFactory' ;
import { ApiFactory } from '../../../crud/apiFactory' ;
const api = new ApiFactory ( ) . create ( ) ;
const api = new ApiFactory ( ) . create ( ) ;
export function testConnection ( value : Connection ) : Promise < string [ ] > {
export function testConnection ( value : Connection ) : Promise < string [ ] > {
return new Promise ( resolve = > {
return new Promise ( resolve = > {
let testStatus = null ;
let testStatus = null ;
@ -15,16 +16,18 @@ export function testConnection(value: Connection): Promise<string[]> {
return false ;
return false ;
}
}
const id = BI . UUID ( ) ;
const id = BI . UUID ( ) ;
const testConnection = ( ) = > {
const testConnection = ( ) = > {
const formValue = value ;
const formValue = value ;
api . testConnection ( formValue ) . then ( re = > {
api . testConnection ( formValue ) . then ( re = > {
if ( re && re . errorCode ) {
if ( re && re . errorCode ) {
if ( re . errorCode === DecCst . ErrorCode . NO_IP_AUTHORIZED ) {
if ( re . errorCode === DecCst . ErrorCode . NO_IP_AUTHORIZED ) {
testStatus . setFail ( ) ;
testStatus . setFail ( ) ;
return ;
return ;
}
}
// 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
// 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
if ( api . isDriverError ( re . errorCode ) ) {
if ( api . isDriverError ( re . errorCode ) ) {
if ( formValue . connectionType === connectionType . JDBC ) {
if ( formValue . connectionType === connectionType . JDBC ) {
const driver = ( formValue . connectionData as ConnectionJDBC ) . driver ;
const driver = ( formValue . connectionData as ConnectionJDBC ) . driver ;
@ -44,7 +47,11 @@ export function testConnection(value: Connection): Promise<string[]> {
} else if ( re . errorCode === errorCode . DUPLICATE_NAMES ) {
} else if ( re . errorCode === errorCode . DUPLICATE_NAMES ) {
testStatus . setFail ( BI . i18nText ( re . errorMsg ) ) ;
testStatus . setFail ( BI . i18nText ( re . errorMsg ) ) ;
} else {
} else {
// 不缺少驱动,但连接失败,打印出当前驱动加载路径,并显示检测驱动按钮
testStatus . setFail ( re . errorMsg ) ;
testStatus . setFail ( re . errorMsg ) ;
api . getDriverLoadPath ( formValue ) . then ( res = > {
testStatus . setExtraContainer ( createDriverTestContainer ( res . data ) ) ;
} )
}
}
} else if ( re . data ) {
} else if ( re . data ) {
testStatus . setSuccess ( ) ;
testStatus . setSuccess ( ) ;
@ -59,7 +66,54 @@ export function testConnection(value: Connection): Promise<string[]> {
BI . Maskers . remove ( id ) ;
BI . Maskers . remove ( id ) ;
}
}
} ) ;
} ) ;
/ * *
* 驱 动 及 冲 突 检 测 内 容 , 补 充 到 报 错 弹 窗 里
* /
function createDriverTestContainer ( path : string ) {
return {
type : BI . VerticalLayout . xtype ,
vgap : 5 ,
items : [
{
type : BI . Label . xtype ,
text : BI.i18nText ( 'Dec-Connection_Driver_Current_Load_Path' , path ) ,
textAlign : 'left' ,
whiteSpace : 'normal' ,
} ,
{
type : BI . TextButton . xtype ,
cls : 'bi-high-light' ,
text : BI.i18nText ( 'Dec-Connection_Driver_Check' ) ,
textAlign : 'left' ,
handler : ( ) = > {
api . checkDriverStatus ( {
driver : ( formValue . connectionData as ConnectionJDBC ) . driver ,
path ,
} ) . then ( res = > {
const isDriverConflict = res . data ;
testStatus . setExtraContainer ( {
type : BI . VerticalLayout . xtype ,
items : [
{
type : BI . Label . xtype ,
textAlign : 'left' ,
text : isDriverConflict
? BI . i18nText ( 'Dec-Connection_Driver_Has_Confilt_Tip' )
: BI . i18nText ( 'Dec-Connection_Driver_No_Confilt_Tip' ) ,
cls : isDriverConflict ? 'bi-error' : '' ,
}
]
} )
} ) ;
}
}
]
}
}
} ;
} ;
BI . Maskers . create ( id , null , {
BI . Maskers . create ( id , null , {
render : {
render : {
type : TestStatus . xtype ,
type : TestStatus . xtype ,