|
|
|
@ -5,6 +5,7 @@ import { TestStatus } from '../../../components/test_status/test_status';
|
|
|
|
|
import { getJdbcDatabaseType } from '../../../app.service'; |
|
|
|
|
import { ApiFactory } from '../../../crud/apiFactory'; |
|
|
|
|
const api = new ApiFactory().create(); |
|
|
|
|
|
|
|
|
|
export function testConnection(value: Connection): Promise<string[]> { |
|
|
|
|
return new Promise(resolve => { |
|
|
|
|
let testStatus = null; |
|
|
|
@ -15,9 +16,11 @@ export function testConnection(value: Connection): Promise<string[]> {
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const id = BI.UUID(); |
|
|
|
|
const testConnection = () => { |
|
|
|
|
const formValue = value; |
|
|
|
|
|
|
|
|
|
api.testConnection(formValue).then(re => { |
|
|
|
|
if (re && re.errorCode) { |
|
|
|
|
if (re.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) { |
|
|
|
@ -44,7 +47,11 @@ export function testConnection(value: Connection): Promise<string[]> {
|
|
|
|
|
} else if (re.errorCode === errorCode.DUPLICATE_NAMES) { |
|
|
|
|
testStatus.setFail(BI.i18nText(re.errorMsg)); |
|
|
|
|
} else { |
|
|
|
|
// 不缺少驱动,但连接失败,打印出当前驱动加载路径,并显示检测驱动按钮
|
|
|
|
|
testStatus.setFail(re.errorMsg); |
|
|
|
|
api.getDriverLoadPath(formValue).then(res => { |
|
|
|
|
testStatus.setExtraContainer(createDriverTestContainer(res.data)); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} else if (re.data) { |
|
|
|
|
testStatus.setSuccess(); |
|
|
|
@ -59,7 +66,54 @@ export function testConnection(value: Connection): Promise<string[]> {
|
|
|
|
|
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, { |
|
|
|
|
render: { |
|
|
|
|
type: TestStatus.xtype, |
|
|
|
|