|
|
@ -1,6 +1,7 @@ |
|
|
|
import { model, Model } from '@core/core'; |
|
|
|
import { model, Model } from '@core/core'; |
|
|
|
import { AppModel } from '../../../../app.model'; |
|
|
|
import { AppModel } from '../../../../app.model'; |
|
|
|
import { ApiFactory } from 'src/modules/crud/apiFactory'; |
|
|
|
import { ApiFactory } from '../../../../crud/apiFactory'; |
|
|
|
|
|
|
|
import { ResultType } from '../../../../crud/crud.typings'; |
|
|
|
const api = new ApiFactory().create(); |
|
|
|
const api = new ApiFactory().create(); |
|
|
|
|
|
|
|
|
|
|
|
export const ListItemModelXtype = 'dec.dcm.model.connection.list_item'; |
|
|
|
export const ListItemModelXtype = 'dec.dcm.model.connection.list_item'; |
|
|
@ -39,18 +40,16 @@ export class ListItemModel extends Model<{ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setPageIndex(pageIndex: string) { |
|
|
|
setPageIndex: (pageIndex: string) => { |
|
|
|
this.model.pageIndex = pageIndex; |
|
|
|
this.model.pageIndex = pageIndex; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
testConnection: (name: string) => api.testConnection(this.model.connections.find(item => item.connectionName === name)), |
|
|
|
testConnection: (name: string) => api.testConnection(this.model.connections.find(item => item.connectionName === name)), |
|
|
|
getConnectionStatus() { |
|
|
|
getConnectionStatus: () => api.getConnectionStatus(this.model.connectionSelected), |
|
|
|
return api.getConnectionStatus(this.model.connectionSelected); |
|
|
|
setDatebaseTypeSelected: (name: string) => { |
|
|
|
}, |
|
|
|
|
|
|
|
setDatebaseTypeSelected(name: string) { |
|
|
|
|
|
|
|
this.model.datebaseTypeSelected = name; |
|
|
|
this.model.datebaseTypeSelected = name; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setIsEdit(isEdit: boolean, name: string) { |
|
|
|
setIsEdit: (isEdit: boolean, name: string) => { |
|
|
|
if (isEdit) { |
|
|
|
if (isEdit) { |
|
|
|
api.getConnectionStatus(name).then(re => { |
|
|
|
api.getConnectionStatus(name).then(re => { |
|
|
|
if (re.data && re.data === 'success') { |
|
|
|
if (re.data && re.data === 'success') { |
|
|
@ -66,30 +65,42 @@ export class ListItemModel extends Model<{ |
|
|
|
this.model.isEdit = false; |
|
|
|
this.model.isEdit = false; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
changeName(oldName: string, newName: string) { |
|
|
|
changeName: (oldName: string, newName: string): Promise<ResultType> => { |
|
|
|
const connection = this.model.connections.find(item => item.connectionName === oldName); |
|
|
|
if (!newName) { |
|
|
|
|
|
|
|
return new Promise(resolve => { |
|
|
|
|
|
|
|
resolve({ errorCode: '1', errorMsg: 'Dec-Dcm_Connection_ConnectionName_Cannt_Null' }); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const hasNamed = this.model.connections.some(item => item.connectionName === newName); |
|
|
|
|
|
|
|
if (hasNamed && oldName !== newName) { |
|
|
|
|
|
|
|
return new Promise(resolve => { |
|
|
|
|
|
|
|
resolve({ errorCode: '1', errorMsg: 'Dec-Dcm_Connection_Is_Existence' }); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const connection = BI.clone(this.model.connections.find(item => item.connectionName === oldName)); |
|
|
|
connection.connectionId = oldName; |
|
|
|
connection.connectionId = oldName; |
|
|
|
connection.connectionName = newName; |
|
|
|
connection.connectionName = newName; |
|
|
|
this.model.connections = this.model.connections.map(item => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...item, |
|
|
|
|
|
|
|
connectionName: item.connectionName === oldName ? newName : item.connectionName, |
|
|
|
|
|
|
|
connectionId: item.connectionName === oldName ? newName : item.connectionName, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return api.updateConnection(connection).then(re => { |
|
|
|
return api.updateConnection(connection).then(re => { |
|
|
|
this.setIsEdit(false, oldName); |
|
|
|
if (!re.errorCode) { |
|
|
|
|
|
|
|
this.store.setIsEdit(false, oldName); |
|
|
|
|
|
|
|
this.model.connections = this.model.connections.map(item => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...item, |
|
|
|
|
|
|
|
connectionName: item.connectionName === oldName ? newName : item.connectionName, |
|
|
|
|
|
|
|
connectionId: item.connectionName === oldName ? newName : item.connectionName, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return re; |
|
|
|
return re; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setIsCopy(isCopy: boolean) { |
|
|
|
setIsCopy: (isCopy: boolean) => { |
|
|
|
this.model.isCopy = isCopy; |
|
|
|
this.model.isCopy = isCopy; |
|
|
|
}, |
|
|
|
}, |
|
|
|
isDriverError(errorCode: string) { |
|
|
|
isDriverError: (errorCode: string) => api.isDriverError(errorCode), |
|
|
|
return api.isDriverError(errorCode); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
removeConnection(name: string) { |
|
|
|
removeConnection(name: string) { |
|
|
|
api.deleteConnection(name).then(re => api.getConnectionlist()) |
|
|
|
api.deleteConnection(name).then(re => api.getConnectionlist()) |
|
|
|