alan
6 years ago
24 changed files with 507 additions and 217 deletions
@ -1,8 +0,0 @@
|
||||
const className = 'fr.model.linkSet.left'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList'], |
||||
actions: { |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
@ -1,66 +0,0 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
import {deleteConnection, testConnection} from '@shared/crud/crud.request'; |
||||
import {databaseTyle, getCnnectionName} from '../../select/select.service'; |
||||
import {confirm} from '@shared/service/dialog.service'; |
||||
const className = 'fr.model.linkSet.left.item'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected'], |
||||
actions: { |
||||
setLinkSelected(name: string) { |
||||
this.model.linkList.forEach((item: LinkType) => { |
||||
item.isSelected = item.connectionName === name; |
||||
if (item.connectionName === name) { |
||||
this.model.linkSelected = { |
||||
...item, |
||||
isSelected: false, |
||||
}; |
||||
} |
||||
}); |
||||
this.model.linkList = [...this.model.linkList]; |
||||
}, |
||||
onIconClick(title: string, id: string) { |
||||
switch (title) { |
||||
case '删除': |
||||
deleteConnection(id, (res: string) => { |
||||
|
||||
}); |
||||
break; |
||||
case '测试连接': |
||||
testConnection(id, (res: any) => { |
||||
|
||||
}); |
||||
break; |
||||
case '复制': |
||||
this.copyLink(id); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}, |
||||
copyLink(id: string) { |
||||
const name = getCnnectionName(this.model.linkList); |
||||
let data = {}; |
||||
this.model.linkList.forEach((item: LinkType) => { |
||||
if (item.connectionId === id) { |
||||
data = item; |
||||
} |
||||
}); |
||||
this.model.linkList.push({ |
||||
...data, |
||||
connectionName:name, |
||||
isSelected: true, |
||||
}); |
||||
this.model.linkSelected = { |
||||
...data, |
||||
isSelected: true, |
||||
connectionName:name, |
||||
}; |
||||
this.model.linkUpdate = { |
||||
...data, |
||||
connectionName:name, |
||||
}; |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
@ -0,0 +1,18 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
import {addConnection, updateConnection} from '@shared/crud/crud.request'; |
||||
|
||||
export function saveConnection(linkUpdate: LinkType): Promise<string> { |
||||
if (linkUpdate.connectionId) { |
||||
return new Promise(((resolve, reject) => { |
||||
addConnection(linkUpdate, (res: string) => { |
||||
resolve(res); |
||||
}); |
||||
})); |
||||
} |
||||
|
||||
return new Promise(((resolve, reject) => { |
||||
updateConnection(linkUpdate, (res: string) => { |
||||
resolve(res); |
||||
}); |
||||
})); |
||||
} |
@ -1,8 +0,0 @@
|
||||
const className = 'fr.model.linkSet.right'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected'], |
||||
actions: { |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
@ -1,6 +0,0 @@
|
||||
const RightDetailModel = 'fr.model.linkSet.right.detail'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected'], |
||||
}); |
||||
BI.model(RightDetailModel, Model); |
||||
export default RightDetailModel; |
@ -1,11 +0,0 @@
|
||||
const RightEditModel = 'fr.model.linkSet.right.edit'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected', 'linkUpdate'], |
||||
actions: { |
||||
setLinkUpdate(value: any) { |
||||
this.model.linkUpdate = value; |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(RightEditModel, Model); |
||||
export default RightEditModel; |
@ -0,0 +1,235 @@
|
||||
import {WidgetType, Vertical, MultiSelectItem, TextAreaEditor, Editor, Button, TextValueCombo} from '@ui/index'; |
||||
import {LinkType} from '@ui/type'; |
||||
import charset from './right.edit.constant'; |
||||
import Model from '../../link-set.model'; |
||||
import FormItem from '@shared/components/form.item.component'; |
||||
import Title from '@shared/components/title.component'; |
||||
const className = 'fr.component.right.edit.mysql'; |
||||
const Widget: WidgetType = { |
||||
_store() { |
||||
return BI.Models.getModel(Model); |
||||
}, |
||||
render() { |
||||
const linkSelected: LinkType = this.model.linkSelected; |
||||
const that = this; |
||||
|
||||
return { |
||||
type: Vertical, |
||||
cls: 'right-show', |
||||
items: [ |
||||
{ |
||||
type: FormItem, |
||||
text: '数据连接名', |
||||
hint: '*修改数据连接名会影响相关数据表和仪表板', |
||||
form:{ |
||||
type: Editor, |
||||
cls: 'bi-border', |
||||
width: 300, |
||||
value: linkSelected.connectionName, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
connectionName: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '驱动器', |
||||
form:{ |
||||
type: TextValueCombo, |
||||
cls: 'bi-border', |
||||
width: 300, |
||||
text: linkSelected.driver, |
||||
items: [{ |
||||
text: linkSelected.driver, |
||||
value: linkSelected.driver, |
||||
}], |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
driver: this.getValue()[0], |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: 'URL', |
||||
form:{ |
||||
type: Editor, |
||||
cls: 'bi-border', |
||||
watermark:'请输入', |
||||
width: 300, |
||||
value: linkSelected.url, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
url: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '编码', |
||||
form:{ |
||||
type: TextValueCombo, |
||||
cls: 'bi-border', |
||||
width: 300, |
||||
text: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName, |
||||
items: BI.Constants.getConstant(charset), |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
originalCharsetName: this.getValue()[0], |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '用户名', |
||||
form:{ |
||||
type: Editor, |
||||
cls: 'bi-border', |
||||
allowBlank:true, |
||||
watermark:'请输入', |
||||
width: 300, |
||||
value: linkSelected.user, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
user: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '密码', |
||||
form:{ |
||||
type: Editor, |
||||
cls: 'bi-border', |
||||
inputType:'password', |
||||
allowBlank:true, |
||||
watermark:'请输入', |
||||
width: 300, |
||||
value: linkSelected.password, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
password: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: Title, |
||||
text: '连接池属性', |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: 'SQL验证查询', |
||||
height: 100, |
||||
form:{ |
||||
type: TextAreaEditor, |
||||
cls: 'bi-border', |
||||
allowBlank:true, |
||||
watermark:'请输入', |
||||
width: 300, |
||||
height:100, |
||||
value: linkSelected.validationQuery, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
validationQuery: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '获取连接前校验', |
||||
form:{ |
||||
type: MultiSelectItem, |
||||
text: '是', |
||||
selected: linkSelected.testOnBorrow, |
||||
width: 60, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
testOnBorrow: this.isSelected(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '最大活动连接数', |
||||
form:{ |
||||
type: Editor, |
||||
cls: 'bi-border', |
||||
allowBlank:true, |
||||
watermark:'请输入', |
||||
width: 60, |
||||
value: linkSelected.maxActive, |
||||
errorText: '请输入有效的正整数', |
||||
validationChecker (v: string) { |
||||
if (/^\+?[1-9][0-9]*$/.test(v)) { |
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action() { |
||||
that.store.setLinkUpdate({ |
||||
...that.model.linkUpdate, |
||||
maxActive: this.getValue(), |
||||
}); |
||||
}, |
||||
}], |
||||
}, |
||||
}, |
||||
{ |
||||
type: FormItem, |
||||
text: '测试连接', |
||||
form: { |
||||
type: Button, |
||||
text: '测试连接', |
||||
level: 'ignore', |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
}, |
||||
}; |
||||
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); |
||||
export default className; |
@ -1,8 +0,0 @@
|
||||
const RightShowModel = 'fr.model.linkSet.right.show'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected'], |
||||
actions: { |
||||
}, |
||||
}); |
||||
BI.model(RightShowModel, Model); |
||||
export default RightShowModel; |
@ -1,15 +0,0 @@
|
||||
const RightTitleModel = 'fr.model.linkSet.right.title'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected', 'linkUpdate'], |
||||
actions: { |
||||
setEdit(type: boolean) { |
||||
this.model.linkSelected = { |
||||
...this.model.linkSelected, |
||||
isSelected: type, |
||||
}; |
||||
this.model.linkUpdate = this.model.linkSelected; |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(RightTitleModel, Model); |
||||
export default RightTitleModel; |
@ -1,34 +0,0 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
import {databaseTyle, getCnnectionName} from './select.service'; |
||||
|
||||
const className = 'fr.model.linkset.select'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected', 'linkUpdate'], |
||||
actions: { |
||||
setNewLink(value: string) { |
||||
const name = getCnnectionName(this.model.linkList); |
||||
let data = {}; |
||||
databaseTyle.forEach(item => { |
||||
if (item.text === value) { |
||||
data = item; |
||||
} |
||||
}); |
||||
this.model.linkList.push({ |
||||
connectionName:name, |
||||
isSelected: true, |
||||
...data, |
||||
}); |
||||
this.model.linkSelected = { |
||||
connectionName:name, |
||||
isSelected: true, |
||||
...data, |
||||
}; |
||||
this.model.linkUpdate = { |
||||
connectionName:name, |
||||
...data, |
||||
}; |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
After Width: | Height: | Size: 5.9 KiB |
Loading…
Reference in new issue