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.
60 lines
2.1 KiB
60 lines
2.1 KiB
import { model, Model } from '@core/core'; |
|
import { AppModel } from 'src/modules/app.model'; |
|
import { Connection } from 'src/modules/crud/crud.typings'; |
|
import { ApiFactory } from 'src/modules/crud/apiFactory'; |
|
import { PAGE_INDEX } from '@constants/constant'; |
|
import { testConnection } from './form.server'; |
|
const api = new ApiFactory().create(); |
|
|
|
@model() |
|
export class MaintainFormModel extends Model<{ |
|
types : { |
|
datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; |
|
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; |
|
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; |
|
saveEvent: AppModel['TYPE']['saveEvent']; |
|
testEvent: AppModel['TYPE']['testEvent']; |
|
pageIndex: AppModel['TYPE']['pageIndex']; |
|
connections: AppModel['TYPE']['connections']; |
|
isCopy: AppModel['TYPE']['isCopy']; |
|
connectionSelected: AppModel['TYPE']['connectionSelected']; |
|
}, |
|
context: MaintainFormModel['context']; |
|
}> { |
|
static xtype = 'dec.dcm.model.maintain_form'; |
|
|
|
context = <const>[ |
|
'datebaseTypeSelected', |
|
'datebaseTypeSelectedOne', |
|
'connectionSelectedOne', |
|
'saveEvent', |
|
'pageIndex', |
|
'testEvent', |
|
'connections', |
|
'isCopy', |
|
'connectionSelected', |
|
]; |
|
|
|
actions = { |
|
addConnection: (data: Connection) => api.addConnection(data), |
|
updateConnection: (name: string, data: Connection) => { |
|
data.connectionId = name; |
|
|
|
return api.updateConnection(data); |
|
}, |
|
shutdownConnectionStatus: (name: string) => api.shutdownConnectionStatus(name), |
|
testConnection: (connection: Connection) => testConnection(connection), |
|
setIsCopy(isCopy: boolean) { |
|
this.model.isCopy = isCopy; |
|
}, |
|
isDriverError(errorCode: string) { |
|
return api.isDriverError(errorCode); |
|
}, |
|
goFirstPage() { |
|
this.model.pageIndex = PAGE_INDEX.CONNECTION; |
|
}, |
|
setConnectionSelected(name: string) { |
|
this.model.connectionSelected = name; |
|
} |
|
} |
|
}
|
|
|