Browse Source

feat: 优化代码

master
alan 6 years ago
parent
commit
ee42412d6f
  1. 15
      src/app/app.component.scss
  2. 4
      src/app/link_set/left/left.component.ts
  3. 8
      src/app/link_set/left/left.model.ts
  4. 4
      src/app/link_set/left/left_item/left.item.component.ts
  5. 5
      src/app/link_set/left/left_item/left.item.icon.component.ts
  6. 66
      src/app/link_set/left/left_item/left.item.model.ts
  7. 160
      src/app/link_set/link-set.model.ts
  8. 18
      src/app/link_set/link-set.service.ts
  9. 4
      src/app/link_set/right/right.component.ts
  10. 8
      src/app/link_set/right/right.model.ts
  11. 25
      src/app/link_set/right/right_detail/right.detail.component.ts
  12. 6
      src/app/link_set/right/right_detail/right.detail.model.ts
  13. 4
      src/app/link_set/right/right_edit/right.edit.component.ts
  14. 11
      src/app/link_set/right/right_edit/right.edit.model.ts
  15. 235
      src/app/link_set/right/right_edit/right.edit.mysql.component.ts
  16. 2
      src/app/link_set/right/right_show/right.show.component.ts
  17. 8
      src/app/link_set/right/right_show/right.show.model.ts
  18. 18
      src/app/link_set/right/right_title/right.title.component.ts
  19. 15
      src/app/link_set/right/right_title/right.title.model.ts
  20. 2
      src/app/link_set/select/select.component.ts
  21. 34
      src/app/link_set/select/select.model.ts
  22. BIN
      src/img/warning.png
  23. 42
      src/shared/crud/crud.request.ts
  24. 8
      src/shared/service/dialog.service.ts

15
src/app/app.component.scss

@ -139,7 +139,20 @@
color: #9ea6b2; color: #9ea6b2;
border-bottom: 1px solid #e8eaed; 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 { .link-font .b-font:before {
content: "\e759"; content: "\e759";
color: inherit; color: inherit;

4
src/app/link_set/left/left.component.ts

@ -1,12 +1,12 @@
import {WidgetType, Vertical} from '@ui'; import {WidgetType, Vertical} from '@ui';
import leftModel from './left.model'; import Model from '../link-set.model';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import {getLinks} from './left.service'; import {getLinks} from './left.service';
const className = 'fr.component.linkset.left'; const className = 'fr.component.linkset.left';
let leftContent: any = null; let leftContent: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(leftModel); return BI.Models.getModel(Model);
}, },
watch:{ watch:{
linkList(linkList: LinkType[]) { linkList(linkList: LinkType[]) {

8
src/app/link_set/left/left.model.ts

@ -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;

4
src/app/link_set/left/left_item/left.item.component.ts

@ -1,6 +1,6 @@
import {WidgetType, Left, Label, Icon} from '@ui'; import {WidgetType, Left, Label, Icon} from '@ui';
import ItemIcon from './left.item.icon.component'; 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 className = 'fr.component.linkSet.left.item';
const Widget: WidgetType = { const Widget: WidgetType = {
props: { props: {
@ -9,7 +9,7 @@ const Widget: WidgetType = {
creator: '', creator: '',
}, },
_store() { _store() {
return BI.Models.getModel(LeftItemModel); return BI.Models.getModel(Model);
}, },
render() { render() {
const {title, extraCls, creator, text, id} = this.options; const {title, extraCls, creator, text, id} = this.options;

5
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 {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 className = 'fr.component.linkSet.left.item.icon';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(LeftItemModel); return BI.Models.getModel(Model);
}, },
render() { render() {
const {cls, title, id} = this.options; const {cls, title, id} = this.options;

66
src/app/link_set/left/left_item/left.item.model.ts

@ -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;

160
src/app/link_set/link-set.model.ts

@ -1,10 +1,168 @@
import {ModelType} from '@ui/index'; 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 className = 'fr.model.linkset';
const Model: ModelType = { const Model: ModelType = {
context: ['tab'], context: ['tab', 'linkList', 'linkSelected', 'linkUpdate'],
actions: { 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)); BI.model(className, BI.inherit(Fix.Model, Model));

18
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<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);
});
}));
}

4
src/app/link_set/right/right.component.ts

@ -2,12 +2,12 @@ import {WidgetType, Vertical} from '@ui';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import Nothing from './nothing.component'; import Nothing from './nothing.component';
import RightDetail from './right_detail/right.detail.component'; import RightDetail from './right_detail/right.detail.component';
import RightModel from './right.model'; import Model from '../link-set.model';
let rightContent: any = null; let rightContent: any = null;
const className = 'fr.component.right'; const className = 'fr.component.right';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(RightModel); return BI.Models.getModel(Model);
}, },
watch:{ watch:{
linkSelected(linkSelected: LinkType) { linkSelected(linkSelected: LinkType) {

8
src/app/link_set/right/right.model.ts

@ -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;

25
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 {WidgetType, Vertical} from '@ui/index';
import RightDetailModel from './right.detail.model'; import Model from '../../link-set.model';
import Title from '../right_title/right.title.component'; import Title from '../right_title/right.title.component';
import RightShow from '../right_show/right.show.component'; import RightShow from '../right_show/right.show.component';
import RightEdit from '../right_edit/right.edit.component'; import RightEdit from '../right_edit/right.edit.component';
import RightEditMysql from '../right_edit/right.edit.mysql.component';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
const className = 'fr.component.right.detail'; const className = 'fr.component.right.detail';
let rightDetail: any = null; let rightDetail: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(RightDetailModel); return BI.Models.getModel(Model);
}, },
watch:{ watch:{
linkSelected(linkSelected: LinkType) { linkSelected(linkSelected: LinkType) {
if (linkSelected.isSelected) { const typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit;
rightDetail.populate(BI.createItems([ rightDetail.populate(BI.createItems([
{ {
type: Title, type: Title,
isEdit: true, isEdit: linkSelected.isSelected,
linkSelected, linkSelected,
}, { }, {
type: RightEdit, type: linkSelected.isSelected ? typeEdit : RightShow,
linkSelected, linkSelected,
}, },
])); ]));
} else {
rightDetail.populate(BI.createItems([
{
type: Title,
isEdit: false,
linkSelected,
}, {
type: RightShow,
linkSelected,
},
]));
}
}, },
}, },
render() { render() {

6
src/app/link_set/right/right_detail/right.detail.model.ts

@ -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;

4
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 {WidgetType, Vertical, MultiSelectItem, TextAreaEditor, Editor, Button, TextValueCombo} from '@ui/index';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import charset from './right.edit.constant'; 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 FormItem from '@shared/components/form.item.component';
import Title from '@shared/components/title.component'; import Title from '@shared/components/title.component';
const className = 'fr.component.right.edit'; const className = 'fr.component.right.edit';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(RightEditModel); return BI.Models.getModel(Model);
}, },
render() { render() {
const linkSelected: LinkType = this.model.linkSelected; const linkSelected: LinkType = this.model.linkSelected;

11
src/app/link_set/right/right_edit/right.edit.model.ts

@ -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;

235
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;

2
src/app/link_set/right/right_show/right.show.component.ts

@ -1,5 +1,5 @@
import {WidgetType, Vertical} from '@ui/index'; 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 BothSide from '@shared/components/both.side.component';
import Title from '@shared/components/title.component'; import Title from '@shared/components/title.component';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';

8
src/app/link_set/right/right_show/right.show.model.ts

@ -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;

18
src/app/link_set/right/right_title/right.title.component.ts

@ -1,7 +1,7 @@
import {WidgetType, Left, Label, Button} from '@ui/index'; 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 {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 className = 'fr.component.right.title';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -37,19 +37,9 @@ const Widget: WidgetType = {
invisible: !isEdit, invisible: !isEdit,
text: '保存', text: '保存',
handler() { handler() {
if (that.model.linkUpdate.connectionId) { saveConnection(that.model.linkUpdate).then(() => {
addConnection(that.model.linkUpdate, (res: string) => {
if (res === 'success') {
that.store.setEdit(false); that.store.setEdit(false);
}
}); });
} else {
updateConnection(that.model.linkUpdate, (res: string) => {
if (res === 'success') {
that.store.setEdit(false);
}
});
}
}, },
}, },
{ {
@ -59,7 +49,7 @@ const Widget: WidgetType = {
level: 'ignore', level: 'ignore',
text: '取消', text: '取消',
handler() { handler() {
that.store.setEdit(false); that.store.setCancel();
}, },
}, },

15
src/app/link_set/right/right_title/right.title.model.ts

@ -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;

2
src/app/link_set/select/select.component.ts

@ -1,5 +1,5 @@
import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui'; import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui';
import selectModel from './select.model'; import selectModel from '../link-set.model';
const linkList = [ const linkList = [
'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200', 'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200',
]; ];

34
src/app/link_set/select/select.model.ts

@ -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;

BIN
src/img/warning.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

42
src/shared/crud/crud.request.ts

@ -2,6 +2,10 @@ import {linkList} from './curd.mock';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
const Dec: any = (window as any).parent.Dec; const Dec: any = (window as any).parent.Dec;
/**
*
* @param callback
*/
export function fetchLinkList(callback: Function): void { export function fetchLinkList(callback: Function): void {
if (Dec) { if (Dec) {
Dec.reqGet('/v10/config/connection/list', 'getInstalledPlugins', (res: any) => { 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{ export function addConnection(data: LinkType, cb: Function): void{
console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data); console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data);
if (Dec) { 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{ export function updateConnection(data: LinkType, cb: Function): void{
console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data); console.log('%cdata: ', 'color: MidnightBlue; background: Aquamarine;', data);
if (Dec) { if (Dec) {
@ -33,7 +47,27 @@ export function updateConnection(data: LinkType, cb: Function): void{
cb('success'); 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{ export function deleteConnection(id: string, cb: Function): void{
console.log('%cid: ', 'color: MidnightBlue; background: Aquamarine;', id); console.log('%cid: ', 'color: MidnightBlue; background: Aquamarine;', id);
if (Dec) { if (Dec) {
@ -44,8 +78,12 @@ export function deleteConnection(id: string, cb: Function): void{
cb('success'); 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); console.log('%cid: ', 'color: MidnightBlue; background: Aquamarine;', id);
if (Dec) { if (Dec) {
Dec.reqDeleta(`/v10/config/connection/${id}/status`, (res: any) => { Dec.reqDeleta(`/v10/config/connection/${id}/status`, (res: any) => {

8
src/shared/service/dialog.service.ts

@ -26,7 +26,13 @@ export const confirm = (message: string, onConfirm: Function): void => {
{ {
eventName: 'EVENT_CONFIRM', eventName: 'EVENT_CONFIRM',
action () { action () {
onConfirm ? onConfirm() : null; onConfirm ? onConfirm(true) : null;
},
},
{
eventName: 'EVENT_CANCEL',
action () {
onConfirm ? onConfirm(false) : null;
}, },
}, },
], ],

Loading…
Cancel
Save