From ee42412d6ff7e69578d6de64cfdb930df70a58ce Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 7 May 2019 11:05:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.scss | 15 +- src/app/link_set/left/left.component.ts | 4 +- src/app/link_set/left/left.model.ts | 8 - .../left/left_item/left.item.component.ts | 4 +- .../left_item/left.item.icon.component.ts | 5 +- .../left/left_item/left.item.model.ts | 66 ----- src/app/link_set/link-set.model.ts | 162 +++++++++++- src/app/link_set/link-set.service.ts | 18 ++ src/app/link_set/right/right.component.ts | 4 +- src/app/link_set/right/right.model.ts | 8 - .../right_detail/right.detail.component.ts | 41 ++- .../right/right_detail/right.detail.model.ts | 6 - .../right/right_edit/right.edit.component.ts | 4 +- .../right/right_edit/right.edit.model.ts | 11 - .../right_edit/right.edit.mysql.component.ts | 235 ++++++++++++++++++ .../right/right_show/right.show.component.ts | 2 +- .../right/right_show/right.show.model.ts | 8 - .../right_title/right.title.component.ts | 22 +- .../right/right_title/right.title.model.ts | 15 -- src/app/link_set/select/select.component.ts | 2 +- src/app/link_set/select/select.model.ts | 34 --- src/img/warning.png | Bin 0 -> 6085 bytes src/shared/crud/crud.request.ts | 42 +++- src/shared/service/dialog.service.ts | 8 +- 24 files changed, 507 insertions(+), 217 deletions(-) delete mode 100644 src/app/link_set/left/left.model.ts delete mode 100644 src/app/link_set/left/left_item/left.item.model.ts create mode 100644 src/app/link_set/link-set.service.ts delete mode 100644 src/app/link_set/right/right.model.ts delete mode 100644 src/app/link_set/right/right_detail/right.detail.model.ts delete mode 100644 src/app/link_set/right/right_edit/right.edit.model.ts create mode 100644 src/app/link_set/right/right_edit/right.edit.mysql.component.ts delete mode 100644 src/app/link_set/right/right_show/right.show.model.ts delete mode 100644 src/app/link_set/right/right_title/right.title.model.ts delete mode 100644 src/app/link_set/select/select.model.ts create mode 100644 src/img/warning.png 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 0000000000000000000000000000000000000000..9e14cb51ba259632c79b2159e37578d95e561fb9 GIT binary patch literal 6085 zcmcIo_g7QF)=dJ28fj8OGj!=KNEd=2p;ryPOD`ftx|=^#ZwdIymr zEvO*U1z&t`eSgCD!=1alpv?;!;f+A5Q3 zEC9fmsG*854zT*37o5xbFn!>8NqL2xG7O=TqJfHSE3UX77hW5Q7pWyLJ+ldY%VO}1 z#(S;cE75A)&xa0{Y6kkYhmgw3%KQqT8YCf-N?)aQ3&ClrNJOfFiE`ibpIgw=)|oIjY~H!kM`Fl3u&?bHTvz13LLn3Efgs9}L4cXsFSB8@vXx95C>Z zM#1CkL&DH?@6^&73=L0J6gbEaOzGZn*ofgKZeL za%}CnJU-6X#~z}Dhg5OG1b>s*E_9R8`>UfsF44GF=2vRxA3w6r#KGr%Ou*>Qb+D)R z081xl_^~lhxjZd3+SgVwfap$vO&(Q$1p+P^ME1u?th%|moJ#0gl0A-Hl;%636HZGY z!n>D8$g@5aN~5c(eA6au5N0K1;vzD?IbZjX8Vjy+%$3Fq+{Ogs|s z^K;2><-ChfrpyoIs8nL|K|^Q#U_nivjftFSL$c5m&*0SZ7V~Xd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?NyOjP`W<~B|pB#r2Rji1mLiaH9WQiEv7;t-sm)U|U?LWLRC`MBx- c$?!*sHWzGd(m|6%D9-~l)O1y=Rcs>v0|tqAdH?_b literal 0 HcmV?d00001 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; }, }, ],