Browse Source

feat: 更新插件接口

master
alan 6 years ago
parent
commit
fdf009c96c
  1. 12
      README.md
  2. 1
      src/app/app.component.ts
  3. 20
      src/app/app.plugin.ts
  4. 9
      src/app/link_set/link-set.model.ts
  5. 41
      src/app/link_set/right/right_detail/right.detail.component.ts
  6. 3
      src/app/link_set/select/select.constant.ts
  7. 25
      src/shared/service/dialog.service.ts

12
README.md

@ -17,4 +17,14 @@ yarn
开始开发 开始开发
``` ```
yarn start yarn start
``` ```
## 接口
### 增加数据连接类型
使用`BI.config`,ConstantName名称为`bi.constant.database.conf.connect.list`,值为连接的名称
### 数据连接表单
ConstantName名称为`bi.constant.database.conf.connect.form.${name.toLowerCase()}.edit`,值为组件shortcut的名称
### 数据连接显示
ConstantName名称为`bi.constant.database.conf.connect.form.${name.toLowerCase()}.show`,值为组件shortcut的名称

1
src/app/app.component.ts

@ -4,6 +4,7 @@ import appModel from './app.model';
import title from './title/title.component'; import title from './title/title.component';
import linkSet from './link_set/link-set.component'; import linkSet from './link_set/link-set.component';
import linkStatus from './link_status/link_status.component'; import linkStatus from './link_status/link_status.component';
import './app.plugin';
import {fetchLinkList} from '../shared/crud/crud.request'; import {fetchLinkList} from '../shared/crud/crud.request';
import './app.component.scss'; import './app.component.scss';

20
src/app/app.plugin.ts

@ -0,0 +1,20 @@
import {Left, WidgetType, Label} from '@ui/index';
const className = 'fr.plugin.text';
const Widget: WidgetType = {
render() {
return {
type: Left,
cls: 'title',
items: [{
type: Label,
text:'123',
}],
};
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;
BI.constant('bi.constant.database.conf.connect.form.redis.edit', className);
BI.constant('bi.constant.database.conf.connect.form.redis.show', className);

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

@ -123,6 +123,11 @@ const Model: ModelType = {
} }
}, },
setNewLink(value: string) { setNewLink(value: string) {
if (!databaseTyle.some(item => item.text === value) && !BI.Constants.getConstant(`bi.constant.database.conf.connect.form.${value.toLowerCase()}.edit`)) {
dialog.error('找不到该连接的配置信息');
return;
}
this.noSaveConfirm(() => { this.noSaveConfirm(() => {
this._setNewLink(value); this._setNewLink(value);
}); });
@ -140,6 +145,7 @@ const Model: ModelType = {
connectionName:name, connectionName:name,
isSelected: true, isSelected: true,
...data, ...data,
text: value,
}, },
...this.model.linkList, ...this.model.linkList,
]; ];
@ -147,6 +153,7 @@ const Model: ModelType = {
...data, ...data,
connectionName:name, connectionName:name,
isSelected: true, isSelected: true,
text: value,
}; };
this.model.linkUpdate = { this.model.linkUpdate = {
...data, ...data,
@ -161,7 +168,7 @@ const Model: ModelType = {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => { dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) { if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => { saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(true); this.setEdit(false);
}); });
} else { } else {
this.setCancel(); this.setCancel();

41
src/app/link_set/right/right_detail/right.detail.component.ts

@ -7,23 +7,30 @@ 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 renderEdit = (linkSelected: LinkType): void => {
let typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit;
if (!linkSelected.driver) {
typeEdit = BI.Constants.getConstant(`bi.constant.database.conf.connect.form.${linkSelected.text.toLowerCase()}.edit`);
}
const showPage = linkSelected.driver ? RightShow : BI.Constants.getConstant(`bi.constant.database.conf.connect.form.${linkSelected.text.toLowerCase()}.show`);
rightDetail.populate(BI.createItems([
{
type: Title,
isEdit: linkSelected.isSelected,
linkSelected,
}, {
type: linkSelected.isSelected ? typeEdit : showPage,
linkSelected,
},
]));
};
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
}, },
watch:{ watch:{
linkSelected(linkSelected: LinkType) { linkSelected(linkSelected: LinkType) {
const typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit; renderEdit(linkSelected);
rightDetail.populate(BI.createItems([
{
type: Title,
isEdit: linkSelected.isSelected,
linkSelected,
}, {
type: linkSelected.isSelected ? typeEdit : RightShow,
linkSelected,
},
]));
}, },
}, },
render() { render() {
@ -37,17 +44,7 @@ const Widget: WidgetType = {
}, },
mounted() { mounted() {
const linkSelected: LinkType = this.model.linkSelected; const linkSelected: LinkType = this.model.linkSelected;
const typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit; renderEdit(linkSelected);
rightDetail.populate(BI.createItems([
{
type: Title,
isEdit: linkSelected.isSelected,
linkSelected,
}, {
type: linkSelected.isSelected ? typeEdit : RightShow,
linkSelected,
},
]));
}, },
}; };
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.Widget, Widget));

3
src/app/link_set/select/select.constant.ts

@ -1,5 +1,6 @@
export const ConstantName = 'bi.constant.database.conf.connect.list'; export const ConstantName = 'bi.constant.database.conf.connect.list';
export const Constant = BI.constant(ConstantName, [ BI.constant(ConstantName, [
'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',
]); ]);
BI.config(ConstantName, (datas: string[]) => [...datas, 'Redis']);
export default ConstantName; export default ConstantName;

25
src/shared/service/dialog.service.ts

@ -98,6 +98,31 @@ class Dialog {
return this.show(body, 1000); return this.show(body, 1000);
} }
public error(message: string): string {
const body = {
type: 'bi.center_adapt',
cls: 'show-content',
items: [
{
type: Vertical,
items:[
{
type: 'bi.layout',
cls: 'error-icon',
width: 100,
height: 100,
},
{
type: Label,
text: message,
},
],
},
],
};
return this.show(body, 2000);
}
public linkFail(text: string, more: string, cb?: Function): string { public linkFail(text: string, more: string, cb?: Function): string {
let Popover: any = null; let Popover: any = null;

Loading…
Cancel
Save