diff --git a/src/app/app.component.scss b/src/app/app.component.scss index f94699f..71407ba 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -139,7 +139,20 @@ color: #9ea6b2; border-bottom: 1px solid #e8eaed; } - +.comfirm-content{ + margin-top: 40px; + margin-left: 20px; + .comfirm-icon{ + background-image: url("../img/warning.png"); + background-size: contain; + margin-right: 12px; + } + .bi-text{ + height: 50px; + line-height: 50px; + margin-left: 12px; + } +} .link-font .b-font:before { content: "\e759"; color: inherit; diff --git a/src/app/link_set/left/left.component.ts b/src/app/link_set/left/left.component.ts index 4a5feaf..0d4c53a 100644 --- a/src/app/link_set/left/left.component.ts +++ b/src/app/link_set/left/left.component.ts @@ -1,12 +1,12 @@ import {WidgetType, Vertical} from '@ui'; -import leftModel from './left.model'; +import Model from '../link-set.model'; import {LinkType} from '@ui/type'; import {getLinks} from './left.service'; const className = 'fr.component.linkset.left'; let leftContent: any = null; const Widget: WidgetType = { _store() { - return BI.Models.getModel(leftModel); + return BI.Models.getModel(Model); }, watch:{ linkList(linkList: LinkType[]) { diff --git a/src/app/link_set/left/left.model.ts b/src/app/link_set/left/left.model.ts deleted file mode 100644 index eb6102e..0000000 --- a/src/app/link_set/left/left.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/left/left_item/left.item.component.ts b/src/app/link_set/left/left_item/left.item.component.ts index 0d34029..dab4019 100644 --- a/src/app/link_set/left/left_item/left.item.component.ts +++ b/src/app/link_set/left/left_item/left.item.component.ts @@ -1,6 +1,6 @@ import {WidgetType, Left, Label, Icon} from '@ui'; import ItemIcon from './left.item.icon.component'; -import LeftItemModel from './left.item.model'; +import Model from '../../link-set.model'; const className = 'fr.component.linkSet.left.item'; const Widget: WidgetType = { props: { @@ -9,7 +9,7 @@ const Widget: WidgetType = { creator: '', }, _store() { - return BI.Models.getModel(LeftItemModel); + return BI.Models.getModel(Model); }, render() { const {title, extraCls, creator, text, id} = this.options; diff --git a/src/app/link_set/left/left_item/left.item.icon.component.ts b/src/app/link_set/left/left_item/left.item.icon.component.ts index 4f3b63a..fa7354c 100644 --- a/src/app/link_set/left/left_item/left.item.icon.component.ts +++ b/src/app/link_set/left/left_item/left.item.icon.component.ts @@ -1,10 +1,9 @@ import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView} from '@ui/index'; -import LeftItemModel from './left.item.model'; - +import Model from '../../link-set.model'; const className = 'fr.component.linkSet.left.item.icon'; const Widget: WidgetType = { _store() { - return BI.Models.getModel(LeftItemModel); + return BI.Models.getModel(Model); }, render() { const {cls, title, id} = this.options; diff --git a/src/app/link_set/left/left_item/left.item.model.ts b/src/app/link_set/left/left_item/left.item.model.ts deleted file mode 100644 index 0349cd3..0000000 --- a/src/app/link_set/left/left_item/left.item.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/link-set.model.ts b/src/app/link_set/link-set.model.ts index b1f4533..3dd6846 100644 --- a/src/app/link_set/link-set.model.ts +++ b/src/app/link_set/link-set.model.ts @@ -1,10 +1,168 @@ import {ModelType} from '@ui/index'; +import {LinkType} from '@ui/type'; +import {deleteConnection, getConnectionStatus} from '@shared/crud/crud.request'; +import {databaseTyle, getCnnectionName} from './select/select.service'; +import {confirm} from '@shared/service/dialog.service'; +import {saveConnection} from './link-set.service'; const className = 'fr.model.linkset'; const Model: ModelType = { - context: ['tab'], + context: ['tab', 'linkList', 'linkSelected', 'linkUpdate'], actions: { - + /** + * 左侧点击链接选中 + * @param name + */ + setLinkSelected(name: string) { + if (this.model.linkSelected && this.model.linkSelected.isSelected) { + confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => { + if (isConfirm) { + saveConnection(this.model.linkUpdate).then(() => { + this.setEdit(false); + }); + } else { + this.setCancel(); + } + this._setLinkSelected(name); + }); + } else { + this._setLinkSelected(name); + } + }, + _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]; + this.model.linkUpdate = this.model.linkSelected; + }, + onIconClick(title: string, id: string) { + switch (title) { + case '删除': + deleteConnection(id, (res: string) => { + + }); + break; + case '测试连接': + getConnectionStatus(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 = [ + { + ...data, + isSelected: true, + connectionName:name, + }, + ...this.model.linkList, + ]; + this.model.linkSelected = { + ...data, + isSelected: true, + connectionName:name, + }; + this.model.linkUpdate = { + ...data, + connectionName:name, + }; + }, + setLinkUpdate(value: any) { + this.model.linkUpdate = value; + }, + setEdit(type: boolean) { + this.model.linkSelected = { + ...this.model.linkSelected, + isSelected: type, + }; + this.model.linkUpdate = this.model.linkSelected; + }, + setCancel() { + const linkSelected: LinkType = this.model.linkSelected; + const linkList: LinkType[] = this.model.linkList; + + if (linkSelected.connectionId) { + this.setEdit(false); + } else { + this.model.linkList = [ + ...linkList.filter(item => !!item.connectionId), + ]; + if (this.model.linkList.length > 0) { + this.model.linkList[0].isSelected = true; + this.model.linkSelected = { + ...this.model.linkList[0], + isSelected: false, + }; + } else { + this.model.linkSelected = {}; + } + this.model.linkUpdate = this.model.linkSelected; + } + }, + setNewLink(value: string) { + console.log('%cvalue: ', 'color: MidnightBlue; background: Aquamarine;', value); + console.log(this.model.linkSelected); + if (this.model.linkSelected && this.model.linkSelected.isSelected) { + confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => { + if (isConfirm) { + saveConnection(this.model.linkUpdate).then(() => { + this.setEdit(false); + }); + } else { + this.setCancel(); + } + this._setNewLink(value); + }); + } else { + this._setNewLink(value); + } + }, + _setNewLink(value: string) { + const name = getCnnectionName(this.model.linkList); + let data = {}; + databaseTyle.forEach(item => { + if (item.text === value) { + data = item; + } + }); + this.model.linkList = [ + { + connectionName:name, + isSelected: true, + ...data, + }, + ...this.model.linkList, + ]; + this.model.linkSelected = { + connectionName:name, + isSelected: true, + ...data, + }; + this.model.linkUpdate = { + connectionName:name, + ...data, + }; + }, }, }; BI.model(className, BI.inherit(Fix.Model, Model)); diff --git a/src/app/link_set/link-set.service.ts b/src/app/link_set/link-set.service.ts new file mode 100644 index 0000000..4befbe1 --- /dev/null +++ b/src/app/link_set/link-set.service.ts @@ -0,0 +1,18 @@ +import {LinkType} from '@ui/type'; +import {addConnection, updateConnection} from '@shared/crud/crud.request'; + +export function saveConnection(linkUpdate: LinkType): Promise { + 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); + }); + })); +} diff --git a/src/app/link_set/right/right.component.ts b/src/app/link_set/right/right.component.ts index a0b0180..f801138 100644 --- a/src/app/link_set/right/right.component.ts +++ b/src/app/link_set/right/right.component.ts @@ -2,12 +2,12 @@ import {WidgetType, Vertical} from '@ui'; import {LinkType} from '@ui/type'; import Nothing from './nothing.component'; import RightDetail from './right_detail/right.detail.component'; -import RightModel from './right.model'; +import Model from '../link-set.model'; let rightContent: any = null; const className = 'fr.component.right'; const Widget: WidgetType = { _store() { - return BI.Models.getModel(RightModel); + return BI.Models.getModel(Model); }, watch:{ linkSelected(linkSelected: LinkType) { diff --git a/src/app/link_set/right/right.model.ts b/src/app/link_set/right/right.model.ts deleted file mode 100644 index c1eba8d..0000000 --- a/src/app/link_set/right/right.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/right/right_detail/right.detail.component.ts b/src/app/link_set/right/right_detail/right.detail.component.ts index 73f1ee8..532e869 100644 --- a/src/app/link_set/right/right_detail/right.detail.component.ts +++ b/src/app/link_set/right/right_detail/right.detail.component.ts @@ -1,40 +1,29 @@ -import {WidgetType, Vertical, Left, Label, Button} from '@ui/index'; -import RightDetailModel from './right.detail.model'; +import {WidgetType, Vertical} from '@ui/index'; +import Model from '../../link-set.model'; import Title from '../right_title/right.title.component'; import RightShow from '../right_show/right.show.component'; import RightEdit from '../right_edit/right.edit.component'; +import RightEditMysql from '../right_edit/right.edit.mysql.component'; import {LinkType} from '@ui/type'; const className = 'fr.component.right.detail'; let rightDetail: any = null; const Widget: WidgetType = { _store() { - return BI.Models.getModel(RightDetailModel); + return BI.Models.getModel(Model); }, watch:{ linkSelected(linkSelected: LinkType) { - if (linkSelected.isSelected) { - rightDetail.populate(BI.createItems([ - { - type: Title, - isEdit: true, - linkSelected, - }, { - type: RightEdit, - linkSelected, - }, - ])); - } else { - rightDetail.populate(BI.createItems([ - { - type: Title, - isEdit: false, - linkSelected, - }, { - type: RightShow, - linkSelected, - }, - ])); - } + const typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit; + rightDetail.populate(BI.createItems([ + { + type: Title, + isEdit: linkSelected.isSelected, + linkSelected, + }, { + type: linkSelected.isSelected ? typeEdit : RightShow, + linkSelected, + }, + ])); }, }, render() { diff --git a/src/app/link_set/right/right_detail/right.detail.model.ts b/src/app/link_set/right/right_detail/right.detail.model.ts deleted file mode 100644 index 8b258bf..0000000 --- a/src/app/link_set/right/right_detail/right.detail.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/right/right_edit/right.edit.component.ts b/src/app/link_set/right/right_edit/right.edit.component.ts index ff8fad7..48ffa9e 100644 --- a/src/app/link_set/right/right_edit/right.edit.component.ts +++ b/src/app/link_set/right/right_edit/right.edit.component.ts @@ -1,13 +1,13 @@ import {WidgetType, Vertical, MultiSelectItem, TextAreaEditor, Editor, Button, TextValueCombo} from '@ui/index'; import {LinkType} from '@ui/type'; import charset from './right.edit.constant'; -import RightEditModel from './right.edit.model'; +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'; const Widget: WidgetType = { _store() { - return BI.Models.getModel(RightEditModel); + return BI.Models.getModel(Model); }, render() { const linkSelected: LinkType = this.model.linkSelected; diff --git a/src/app/link_set/right/right_edit/right.edit.model.ts b/src/app/link_set/right/right_edit/right.edit.model.ts deleted file mode 100644 index b6901c1..0000000 --- a/src/app/link_set/right/right_edit/right.edit.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/right/right_edit/right.edit.mysql.component.ts b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts new file mode 100644 index 0000000..65e391e --- /dev/null +++ b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts @@ -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; diff --git a/src/app/link_set/right/right_show/right.show.component.ts b/src/app/link_set/right/right_show/right.show.component.ts index 0344da2..fa6b668 100644 --- a/src/app/link_set/right/right_show/right.show.component.ts +++ b/src/app/link_set/right/right_show/right.show.component.ts @@ -1,5 +1,5 @@ import {WidgetType, Vertical} from '@ui/index'; -import RightShowModel from './right.show.model'; +import RightShowModel from '../../link-set.model'; import BothSide from '@shared/components/both.side.component'; import Title from '@shared/components/title.component'; import {LinkType} from '@ui/type'; diff --git a/src/app/link_set/right/right_show/right.show.model.ts b/src/app/link_set/right/right_show/right.show.model.ts deleted file mode 100644 index 80161f0..0000000 --- a/src/app/link_set/right/right_show/right.show.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/right/right_title/right.title.component.ts b/src/app/link_set/right/right_title/right.title.component.ts index fb0e5a8..2a8e509 100644 --- a/src/app/link_set/right/right_title/right.title.component.ts +++ b/src/app/link_set/right/right_title/right.title.component.ts @@ -1,7 +1,7 @@ import {WidgetType, Left, Label, Button} from '@ui/index'; -import RightTitleModel from './right.title.model'; +import RightTitleModel from '../../link-set.model'; import {LinkType} from '@ui/type'; -import {addConnection, updateConnection} from '@shared/crud/crud.request'; +import {saveConnection} from '../../link-set.service'; const className = 'fr.component.right.title'; const Widget: WidgetType = { _store() { @@ -37,19 +37,9 @@ const Widget: WidgetType = { invisible: !isEdit, text: '保存', handler() { - if (that.model.linkUpdate.connectionId) { - addConnection(that.model.linkUpdate, (res: string) => { - if (res === 'success') { - that.store.setEdit(false); - } - }); - } else { - updateConnection(that.model.linkUpdate, (res: string) => { - if (res === 'success') { - that.store.setEdit(false); - } - }); - } + saveConnection(that.model.linkUpdate).then(() => { + that.store.setEdit(false); + }); }, }, { @@ -59,7 +49,7 @@ const Widget: WidgetType = { level: 'ignore', text: '取消', handler() { - that.store.setEdit(false); + that.store.setCancel(); }, }, diff --git a/src/app/link_set/right/right_title/right.title.model.ts b/src/app/link_set/right/right_title/right.title.model.ts deleted file mode 100644 index 37fc937..0000000 --- a/src/app/link_set/right/right_title/right.title.model.ts +++ /dev/null @@ -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; diff --git a/src/app/link_set/select/select.component.ts b/src/app/link_set/select/select.component.ts index d0b039c..8127aab 100644 --- a/src/app/link_set/select/select.component.ts +++ b/src/app/link_set/select/select.component.ts @@ -1,5 +1,5 @@ import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui'; -import selectModel from './select.model'; +import selectModel from '../link-set.model'; const linkList = [ 'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200', ]; diff --git a/src/app/link_set/select/select.model.ts b/src/app/link_set/select/select.model.ts deleted file mode 100644 index a7b0461..0000000 --- a/src/app/link_set/select/select.model.ts +++ /dev/null @@ -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; diff --git a/src/img/warning.png b/src/img/warning.png new file mode 100644 index 0000000..9e14cb5 Binary files /dev/null and b/src/img/warning.png differ diff --git a/src/shared/crud/crud.request.ts b/src/shared/crud/crud.request.ts index a60a5c3..85d2be3 100644 --- a/src/shared/crud/crud.request.ts +++ b/src/shared/crud/crud.request.ts @@ -2,6 +2,10 @@ import {linkList} from './curd.mock'; import {LinkType} from '@ui/type'; const Dec: any = (window as any).parent.Dec; +/** + * 获取数据连接列表 + * @param callback 回调函数 + */ export function fetchLinkList(callback: Function): void { if (Dec) { Dec.reqGet('/v10/config/connection/list', 'getInstalledPlugins', (res: any) => { @@ -12,6 +16,11 @@ export function fetchLinkList(callback: Function): void { } } +/** + * 新增数据连接 + * @param data 数据连接参数 + * @param cb 回调函数 + */ export function addConnection(data: LinkType, cb: Function): void{ console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data); if (Dec) { @@ -23,6 +32,11 @@ export function addConnection(data: LinkType, cb: Function): void{ } } +/** + * 更新数据连接 + * @param data 数据连接参数 + * @param cb 回调函数 + */ export function updateConnection(data: LinkType, cb: Function): void{ console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data); if (Dec) { @@ -33,7 +47,27 @@ export function updateConnection(data: LinkType, cb: Function): void{ cb('success'); } } +/** + * 测试数据连接 + * @param data 数据连接参数 + * @param cb 回调函数 + */ +export function testConnection(data: LinkType, cb: Function): void{ + console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data); + if (Dec) { + Dec.reqPost(`/v10/config/connection/test`, data, (res: any) => { + cb(res.data); + }); + } else { + cb('success'); + } +} +/** + * 删除数据连接 + * @param id 数据连接id + * @param cb 回调函数 + */ export function deleteConnection(id: string, cb: Function): void{ console.log('%cid: ', 'color: MidnightBlue; background: Aquamarine;', id); if (Dec) { @@ -44,8 +78,12 @@ export function deleteConnection(id: string, cb: Function): void{ cb('success'); } } - -export function testConnection(id: string, cb: Function): void{ +/** + * 检查数据连接状态 + * @param id 数据连接id + * @param cb 回调函数 + */ +export function getConnectionStatus(id: string, cb: Function): void{ console.log('%cid: ', 'color: MidnightBlue; background: Aquamarine;', id); if (Dec) { Dec.reqDeleta(`/v10/config/connection/${id}/status`, (res: any) => { diff --git a/src/shared/service/dialog.service.ts b/src/shared/service/dialog.service.ts index 7c3073d..dcc172b 100644 --- a/src/shared/service/dialog.service.ts +++ b/src/shared/service/dialog.service.ts @@ -26,7 +26,13 @@ export const confirm = (message: string, onConfirm: Function): void => { { eventName: 'EVENT_CONFIRM', action () { - onConfirm ? onConfirm() : null; + onConfirm ? onConfirm(true) : null; + }, + }, + { + eventName: 'EVENT_CANCEL', + action () { + onConfirm ? onConfirm(false) : null; }, }, ],