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