|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { shortcut, store } from '@core/core'; |
|
|
|
|
import { Label, LeftRightVerticalAdapt, IconLabel, Left, IconButton, BubbleCombo, TextBubblePopupBarView } from 'ui'; |
|
|
|
|
import { Label, LeftRightVerticalAdapt, IconLabel, IconButton, DownListCombo, SignEditor } from 'ui'; |
|
|
|
|
import './list_item.less'; |
|
|
|
|
import { ListItemModel, ListItemModelXtype } from './list_item.model'; |
|
|
|
|
import { PAGE_INDEX } from '@constants/constant'; |
|
|
|
@ -21,11 +21,22 @@ export class ListItem extends BI.BasicButton {
|
|
|
|
|
model: ListItemModel['model']; |
|
|
|
|
|
|
|
|
|
comboWidget: any; |
|
|
|
|
nameLabel: any; |
|
|
|
|
nameEditor: any; |
|
|
|
|
testStatus: TestStatus; |
|
|
|
|
|
|
|
|
|
watch = { |
|
|
|
|
isEdit: (isEdit: boolean) => { |
|
|
|
|
this.nameLabel.setVisible(!isEdit); |
|
|
|
|
this.nameEditor.setVisible(isEdit); |
|
|
|
|
if (isEdit) { |
|
|
|
|
this.nameEditor.focus(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { name, creator, databaseType } = this.options; |
|
|
|
|
const isRegistered = hasRegistered(databaseType); |
|
|
|
|
const { name } = this.options; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: LeftRightVerticalAdapt, |
|
|
|
@ -40,25 +51,115 @@ export class ListItem extends BI.BasicButton {
|
|
|
|
|
{ |
|
|
|
|
type: Label, |
|
|
|
|
text: name, |
|
|
|
|
ref: (_ref: any) => { |
|
|
|
|
this.nameLabel = _ref; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: SignEditor, |
|
|
|
|
value: name, |
|
|
|
|
width: 100, |
|
|
|
|
invisible: !this.model.isEdit, |
|
|
|
|
ref: (_ref: any) => { |
|
|
|
|
this.nameEditor = _ref; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.SignEditor.EVENT_BLUR, |
|
|
|
|
action: () => { |
|
|
|
|
const newName = this.nameEditor.getValue(); |
|
|
|
|
this.store.changeName(name, newName).then(() => { |
|
|
|
|
this.store.setIsEdit(false); |
|
|
|
|
this.nameLabel.setText(newName); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
right: [ |
|
|
|
|
{ |
|
|
|
|
type: Left, |
|
|
|
|
cls: 'link-item-icon bi-background', |
|
|
|
|
type: DownListCombo, |
|
|
|
|
cls: 'link-item-icon', |
|
|
|
|
stopPropagation: true, |
|
|
|
|
hgap: 8, |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: IconButton, |
|
|
|
|
cls: 'dcm-test-font icon-size-16', |
|
|
|
|
title: BI.i18nText('Dec-Dcm_Test_Connection'), |
|
|
|
|
stopPropagation: true, |
|
|
|
|
invisible: !isRegistered, |
|
|
|
|
handler: () => { |
|
|
|
|
cls: 'dcm-link-other-font icon-size-16', |
|
|
|
|
}, |
|
|
|
|
items: this.renderDownList(), |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.DownListCombo.EVENT_CHANGE, |
|
|
|
|
action: (value: string) => { |
|
|
|
|
this.itemActionCalculate().actionClac(value); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private renderDownList() { |
|
|
|
|
const { creator, databaseType } = this.options; |
|
|
|
|
const isRegistered = hasRegistered(databaseType); |
|
|
|
|
const otherIcons = [ |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Type', databaseType), |
|
|
|
|
cls: 'dcm-info-font', |
|
|
|
|
value: 12, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Creator', creator), |
|
|
|
|
value: 12, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
if (!isRegistered) { |
|
|
|
|
return [otherIcons]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
[ |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Test_Connection'), |
|
|
|
|
cls: 'dcm-test-font', |
|
|
|
|
value: 'test', |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Edit'), |
|
|
|
|
cls: 'dcm-link-edit-font', |
|
|
|
|
value: 'edit', |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Change_Name'), |
|
|
|
|
cls: 'dcm-change-name-font', |
|
|
|
|
value: 'changeName', |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Copy'), |
|
|
|
|
cls: 'copy-font', |
|
|
|
|
value: 'copy', |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Delete'), |
|
|
|
|
cls: 'dcm-delete-font', |
|
|
|
|
value: 'delete', |
|
|
|
|
bubble: BI.i18nText('Dec-Dcm_Connection_Make_Sure_Delete'), |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
otherIcons, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
doClick() { |
|
|
|
|
const { name } = this.options; |
|
|
|
|
this.store.setConnectionSelected(name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private testConnectionAction() { |
|
|
|
|
const { name } = this.options; |
|
|
|
|
const id = BI.UUID(); |
|
|
|
|
const testConnection = () => { |
|
|
|
|
this.store.testConnection().then(re => { |
|
|
|
|
this.store.testConnection(name).then(re => { |
|
|
|
|
if (re && re.errorCode) { |
|
|
|
|
this.testStatus.setFail(re.errorMsg); |
|
|
|
|
} else if (re.data) { |
|
|
|
@ -106,60 +207,39 @@ export class ListItem extends BI.BasicButton {
|
|
|
|
|
}); |
|
|
|
|
BI.Maskers.show(id); |
|
|
|
|
testConnection(); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: IconButton, |
|
|
|
|
cls: 'copy-font icon-size-16', |
|
|
|
|
title: BI.i18nText('Dec-Dcm_Copy'), |
|
|
|
|
stopPropagation: true, |
|
|
|
|
invisible: !isRegistered, |
|
|
|
|
handler: () => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private itemActionCalculate() { |
|
|
|
|
const { name } = this.options; |
|
|
|
|
const actionsMap = { |
|
|
|
|
test: this.testConnectionAction.bind(this), |
|
|
|
|
edit: () => { |
|
|
|
|
this.store.setConnectionSelected(name); |
|
|
|
|
this.store.getConnectionStatus().then(re => { |
|
|
|
|
if (re.data && re.data === 'success') { |
|
|
|
|
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: IconButton, |
|
|
|
|
cls: 'dcm-info-font icon-size-16', |
|
|
|
|
title: `${BI.i18nText('Dec-Dcm_Type', databaseType)}\r\n${BI.i18nText('Dec-Dcm_Creator', creator)}`, |
|
|
|
|
stopPropagation: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: BubbleCombo, |
|
|
|
|
stopPropagation: true, |
|
|
|
|
direction: 'bottom', |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.comboWidget = _ref; |
|
|
|
|
}, |
|
|
|
|
el: { |
|
|
|
|
type: IconLabel, |
|
|
|
|
cls: 'dcm-delete-font icon-size-16', |
|
|
|
|
title: BI.i18nText('Dec-Dcm_Delete'), |
|
|
|
|
}, |
|
|
|
|
popup: { |
|
|
|
|
type: TextBubblePopupBarView, |
|
|
|
|
text: BI.i18nText('Dec-Dcm_Connection_Make_Sure_Delete'), |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, |
|
|
|
|
action: (ok: boolean) => { |
|
|
|
|
this.comboWidget.hideView(); |
|
|
|
|
if (ok) { |
|
|
|
|
this.store.deleteConnection(name); |
|
|
|
|
this.store.setDatebaseTypeSelected(''); |
|
|
|
|
} else { |
|
|
|
|
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), { |
|
|
|
|
level: 'error', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
}, |
|
|
|
|
changeName: () => { |
|
|
|
|
this.store.setIsEdit(true); |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
copy: () => { |
|
|
|
|
this.store.setConnectionSelected(name); |
|
|
|
|
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
delete: () => { |
|
|
|
|
this.store.deleteConnection(name); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
doClick() { |
|
|
|
|
const { name } = this.options; |
|
|
|
|
this.store.setConnectionSelected(name); |
|
|
|
|
return { |
|
|
|
|
actionClac: (name: string) => actionsMap[name] && actionsMap[name](), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|