@ -6,7 +6,7 @@ import { FormPlugin } from './components/form.plugin';
import { connectionType , errorCode } from '@constants/env' ;
import { ConnectionJDBC , Connection , ResultType } from 'src/modules/crud/crud.typings' ;
import { DEFAULT_JNDI_DATA , DEFAULT_JDBC_POOL , DATEBASE_FILTER_TYPE } from '@constants/constant' ;
import { getJdbcDatabaseType , getChartLength } from '../../../app.service' ;
import { getJdbcDatabaseType , getChartLength , getAllDatabaseTypes } from '../../../app.service' ;
import { NAME_MAX_LENGTH } from '../../../app.constant' ;
import { checkIllegalStrings } from "@core/index" ;
@ -14,6 +14,7 @@ import { checkIllegalStrings } from "@core/index";
@store ( MaintainFormModel )
export class MaintainForm extends BI . Widget {
static xtype = 'dec.dcm.maintain.form' ;
static EVENT_TESTCONNECTION = 'EVENT_TEST_CONNECTION' ;
props = {
connectionType : '' ,
@ -29,34 +30,36 @@ export class MaintainForm extends BI.Widget {
watch = {
saveEvent : ( ) = > {
if ( ! this . testValue ( ) ) {
return ;
}
if ( this . connectionName && ! this . model . isCopy ) {
const value = this . form . getSubmitValue ( ) ;
( value . connectionData as ConnectionJDBC ) . creator = BI . get ( this . getFormData ( ) , 'creator' ) ;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
value . creator = BI . get ( this . getFormData ( ) , 'creator' ) ;
this . store . updateConnection ( this . connectionName , value ) . then ( result = > {
if ( result . errorCode ) {
if ( result . errorCode === DecCst . ErrorCode . NO_IP_AUTHORIZED ) {
BI . Msg . toast ( BI . i18nText ( "Dec-Basic_Save_Fail" ) , {
level : "error" ,
} ) ;
}
this . showError ( result ) ;
const sonSave = this . form . getSaveFn ? . ( ) ;
if ( sonSave ) {
sonSave ( ) . then ( ( success : boolean ) = > {
if ( success ) {
BI . Msg . toast ( BI . i18nText ( "Dec-Basic_Save_Success" ) , {
level : "success" ,
} ) ;
} else {
BI . Msg . toast ( BI . i18nText ( "Dec-Basic_Save_Fail" ) , {
level : "error" ,
} ) ;
}
} ) ;
//只有外来插件才可以使用是否不执行平台的保存逻辑
if ( this . model . datebaseTypeSelected ) {
const isPluginDatabase = BI . some ( BI . Providers . getProvider ( 'dec.connection.provider.datebase' ) . customDatabaseType , ( _index , value ) = > value . databaseType === this . model . datebaseTypeSelected ) ;
if ( isPluginDatabase && this . model . datebaseTypeSelectedOne . isNoSave ) {
return ;
}
this . store . goFirstPage ( ) ;
} ) ;
} else {
const form = this . form . getSubmitValue ( ) ;
form . connectionId = this . connectionName ;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
form . creator = Dec ? Dec . personal . username : '' ;
this . addConnection ( form ) ;
} else {
const databaseType = this . model . connectionSelectedOne . connectionType ;
const database = BI . find ( getAllDatabaseTypes ( ) , ( _index , value ) = > value . databaseType === databaseType ) ;
if ( this . model . connectionSelectedOne . pluginConnection && database ? . isNoSave ) {
return ;
}
}
}
this . save ( ) ;
} ,
testEvent : ( ) = > {
this . testConnection ( ) ;
@ -77,7 +80,7 @@ export class MaintainForm extends BI.Widget {
this . form = _ref ;
} ,
listeners : [ {
eventName : 'EVENT_TEST_CONNECTION' ,
eventName : MaintainForm.EVENT_TESTCONNECTION ,
action : ( ) = > {
this . testConnection ( ) ;
} ,
@ -295,4 +298,35 @@ export class MaintainForm extends BI.Widget {
this . store . setIsCopy ( false ) ;
} ) ;
}
private save() {
if ( ! this . testValue ( ) ) {
return ;
}
if ( this . connectionName && ! this . model . isCopy ) {
const value = this . form . getSubmitValue ( ) ;
( value . connectionData as ConnectionJDBC ) . creator = BI . get ( this . getFormData ( ) , 'creator' ) ;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
value . creator = BI . get ( this . getFormData ( ) , 'creator' ) ;
this . store . updateConnection ( this . connectionName , value ) . then ( result = > {
if ( result . errorCode ) {
if ( result . errorCode === DecCst . ErrorCode . NO_IP_AUTHORIZED ) {
BI . Msg . toast ( BI . i18nText ( "Dec-Basic_Save_Fail" ) , {
level : "error" ,
} ) ;
}
this . showError ( result ) ;
return ;
}
this . store . goFirstPage ( ) ;
} ) ;
} else {
const form = this . form . getSubmitValue ( ) ;
form . connectionId = this . connectionName ;
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
form . creator = Dec ? Dec . personal . username : '' ;
this . addConnection ( form ) ;
}
}
}