Browse Source

feat: 提供插件接口已便于拓展开发

master
alan 6 years ago
parent
commit
8fd592d293
  1. 2
      src/app/link_set/right/right_edit/right.edit.constant.ts
  2. 3
      src/app/link_set/right/right_title/right.title.component.ts
  3. 6
      src/app/link_set/select/select.component.ts
  4. 5
      src/app/link_set/select/select.constant.ts
  5. 10
      src/app/link_status/right/right.card.component.ts
  6. 18
      src/app/link_status/right/right.component.ts
  7. 6
      src/app/link_status/right/right.typings.d.ts
  8. 1
      src/index.html
  9. 13
      src/shared/crud/crud.request.ts

2
src/app/link_set/right/right_edit/right.edit.constant.ts

@ -1,4 +1,4 @@
export const ConstantName = 'bi.constant.linkSet.right.edit.charset';
export const ConstantName = 'bi.constant.database.conf.charset.list';
export const Constant = BI.constant(ConstantName, [
{
text: '自动',

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

@ -40,7 +40,7 @@ const Widget: WidgetType = {
handler() {
const result = BI.find(linkList, (idx: number, value: LinkType) => that.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== that.model.linkUpdate.connectionId);
if (result) {
that.store.setConnectionNameErr('数据接名已存在');
that.store.setConnectionNameErr('数据接名已存在');
} else {
saveConnection(that.model.linkUpdate).then(() => {
that.store.setEdit(false);
@ -58,7 +58,6 @@ const Widget: WidgetType = {
that.store.setCancel();
},
},
],
};
},

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

@ -1,9 +1,7 @@
import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui';
import selectModel from '../link-set.model';
import {moreLink} from '../more/more.link.service';
const linkList = [
'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200',
];
import connectList from './select.constant';
const className = 'fr.linkset.select';
const Widget: WidgetType = {
_store() {
@ -26,7 +24,7 @@ const Widget: WidgetType = {
el: {
type: ButtonGroup,
cls:'database-link-items',
items: [...BI.map(linkList, (index: number, item: string) => {
items: [...BI.map(BI.Constants.getConstant(connectList), (index: number, item: string) => {
return {
type: TextItem,
height: 24,

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

@ -0,0 +1,5 @@
export const ConstantName = 'bi.constant.database.conf.connect.list';
export const Constant = BI.constant(ConstantName, [
'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200',
]);
export default ConstantName;

10
src/app/link_status/right/right.card.component.ts

@ -2,6 +2,8 @@ import {WidgetType, Left, Label, Vertical} from '@ui/index';
const className = 'fr.component.linkStatus.right.card';
const Widget: WidgetType = {
render() {
const {maxActive, maxIdle, numActive, numIdle} = this.options;
return {
type: Left,
items: [
@ -21,7 +23,7 @@ const Widget: WidgetType = {
type: Label,
cls: 'right-status-text',
extraCls: 'card-font1',
text: '0',
text: numActive,
},
{
type: Label,
@ -31,7 +33,7 @@ const Widget: WidgetType = {
{
type: Label,
cls: 'right-status-text',
text: '50',
text: maxActive,
},
],
},
@ -59,7 +61,7 @@ const Widget: WidgetType = {
type: Label,
cls: 'right-status-text',
extraCls: 'card-font2',
text: '0',
text: numIdle,
},
{
type: Label,
@ -69,7 +71,7 @@ const Widget: WidgetType = {
{
type: Label,
cls: 'right-status-text',
text: '50',
text: maxIdle,
},
],
},

18
src/app/link_status/right/right.component.ts

@ -1,8 +1,11 @@
import {WidgetType, Vertical, Left, Label} from '@ui/index';
import Model from './right.model';
import {info} from '@shared/crud/crud.request';
import RightCard from './right.card.component';
import {InfoType} from './right.typings';
const className = 'fr.component.linkStatus.right';
let Title: any = null;
let Group: any = null;
const Widget: WidgetType = {
_store() {
@ -11,6 +14,12 @@ const Widget: WidgetType = {
watch:{
statusSelected(title: string) {
Title.setText(`数据连接(${title})`);
info(name, (res: InfoType) => {
Group.populate(BI.createItems([{
type: RightCard,
...res,
}]));
});
},
},
render() {
@ -34,15 +43,16 @@ const Widget: WidgetType = {
}, {
type: Vertical,
cls: 'right-status-body',
items: [
{
type: RightCard,
ref(ref: any) {
Group = ref;
},
],
},
],
};
},
mounted() {
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

6
src/app/link_status/right/right.typings.d.ts vendored

@ -0,0 +1,6 @@
export interface InfoType{
maxActive: number;
maxIdle: number;
numActive: number;
numIdle: number;
}

1
src/index.html

@ -9,5 +9,6 @@
<script type="text/javascript" charset="UTF-8" src="./lib/bundle.min.js"></script>
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
</body>
</html>

13
src/shared/crud/crud.request.ts

@ -81,7 +81,7 @@ export function deleteConnection(id: string, cb: Function): void{
}
}
/**
*
*
* @param id id
* @param cb
*/
@ -95,3 +95,14 @@ export function getConnectionStatus(id: string, cb: Function): void{
cb('success');
}
}
export function info(name: string, cb: Function): void{
console.log('%cname: ', 'color: MidnightBlue; background: Aquamarine;', name);
if (Dec) {
Dec.reqDeleta(`/v10/config/connection/pool/info?connectionName=${name}`, (res: any) => {
cb(res.data);
});
} else {
cb({maxActive:50, maxIdle:10, numActive:0, numIdle:0});
}
}

Loading…
Cancel
Save