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.
45 lines
1.6 KiB
45 lines
1.6 KiB
import { PAGE_INDEX, DATEBASE_FILTER_TYPE } from './constants/constant'; |
|
import { Model, model } from '@core/core'; |
|
import { Connection } from 'src/modules/crud/crud.typings'; |
|
import { getAllDatabaseTypes } from './app.service'; |
|
|
|
@model() |
|
export class AppModel extends Model { |
|
static xtype = 'dec.dcm.model.main'; |
|
|
|
childContext = <const>['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy', 'connectionLicInfo']; |
|
|
|
state() { |
|
return { |
|
pageIndex: PAGE_INDEX.CONNECTION, |
|
datebaseTypeSelected: '', |
|
filter: DATEBASE_FILTER_TYPE.COMMONLY, |
|
connections: [] as Connection[], |
|
connectionSelected: '', |
|
saveEvent: '', |
|
testEvent: '', |
|
isCopy: false, |
|
connectionLicInfo: { |
|
currentConnectionNum: 0, |
|
maxConnectionNum: 0, |
|
}, |
|
}; |
|
} |
|
|
|
computed = { |
|
connectionSelectedOne: () => this.model.connections.find(item => item.connectionName === this.model.connectionSelected), |
|
datebaseTypeSelectedOne: () => getAllDatabaseTypes().find(item => item.databaseType === this.model.datebaseTypeSelected), |
|
}; |
|
|
|
actions = { |
|
setPageIndex: (index: string) => { |
|
this.model.pageIndex = index; |
|
}, |
|
setFilter: (filter: string) => { |
|
this.model.filter = filter; |
|
}, |
|
setDatebaseTypeSelected: (datebaseTypeSelected: string) => { |
|
this.model.datebaseTypeSelected = datebaseTypeSelected; |
|
}, |
|
}; |
|
}
|
|
|