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. 20
      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, [ export const Constant = BI.constant(ConstantName, [
{ {
text: '自动', text: '自动',

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

@ -40,7 +40,7 @@ const Widget: WidgetType = {
handler() { handler() {
const result = BI.find(linkList, (idx: number, value: LinkType) => that.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== that.model.linkUpdate.connectionId); const result = BI.find(linkList, (idx: number, value: LinkType) => that.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== that.model.linkUpdate.connectionId);
if (result) { if (result) {
that.store.setConnectionNameErr('数据接名已存在'); that.store.setConnectionNameErr('数据接名已存在');
} else { } else {
saveConnection(that.model.linkUpdate).then(() => { saveConnection(that.model.linkUpdate).then(() => {
that.store.setEdit(false); that.store.setEdit(false);
@ -58,7 +58,6 @@ const Widget: WidgetType = {
that.store.setCancel(); 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 {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui';
import selectModel from '../link-set.model'; import selectModel from '../link-set.model';
import {moreLink} from '../more/more.link.service'; import {moreLink} from '../more/more.link.service';
const linkList = [ import connectList from './select.constant';
'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200',
];
const className = 'fr.linkset.select'; const className = 'fr.linkset.select';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -26,7 +24,7 @@ const Widget: WidgetType = {
el: { el: {
type: ButtonGroup, type: ButtonGroup,
cls:'database-link-items', cls:'database-link-items',
items: [...BI.map(linkList, (index: number, item: string) => { items: [...BI.map(BI.Constants.getConstant(connectList), (index: number, item: string) => {
return { return {
type: TextItem, type: TextItem,
height: 24, 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 className = 'fr.component.linkStatus.right.card';
const Widget: WidgetType = { const Widget: WidgetType = {
render() { render() {
const {maxActive, maxIdle, numActive, numIdle} = this.options;
return { return {
type: Left, type: Left,
items: [ items: [
@ -21,7 +23,7 @@ const Widget: WidgetType = {
type: Label, type: Label,
cls: 'right-status-text', cls: 'right-status-text',
extraCls: 'card-font1', extraCls: 'card-font1',
text: '0', text: numActive,
}, },
{ {
type: Label, type: Label,
@ -31,7 +33,7 @@ const Widget: WidgetType = {
{ {
type: Label, type: Label,
cls: 'right-status-text', cls: 'right-status-text',
text: '50', text: maxActive,
}, },
], ],
}, },
@ -59,7 +61,7 @@ const Widget: WidgetType = {
type: Label, type: Label,
cls: 'right-status-text', cls: 'right-status-text',
extraCls: 'card-font2', extraCls: 'card-font2',
text: '0', text: numIdle,
}, },
{ {
type: Label, type: Label,
@ -69,7 +71,7 @@ const Widget: WidgetType = {
{ {
type: Label, type: Label,
cls: 'right-status-text', cls: 'right-status-text',
text: '50', text: maxIdle,
}, },
], ],
}, },

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

@ -1,8 +1,11 @@
import {WidgetType, Vertical, Left, Label} from '@ui/index'; import {WidgetType, Vertical, Left, Label} from '@ui/index';
import Model from './right.model'; import Model from './right.model';
import {info} from '@shared/crud/crud.request';
import RightCard from './right.card.component'; import RightCard from './right.card.component';
import {InfoType} from './right.typings';
const className = 'fr.component.linkStatus.right'; const className = 'fr.component.linkStatus.right';
let Title: any = null; let Title: any = null;
let Group: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -11,6 +14,12 @@ const Widget: WidgetType = {
watch:{ watch:{
statusSelected(title: string) { statusSelected(title: string) {
Title.setText(`数据连接(${title})`); Title.setText(`数据连接(${title})`);
info(name, (res: InfoType) => {
Group.populate(BI.createItems([{
type: RightCard,
...res,
}]));
});
}, },
}, },
render() { render() {
@ -34,15 +43,16 @@ const Widget: WidgetType = {
}, { }, {
type: Vertical, type: Vertical,
cls: 'right-status-body', cls: 'right-status-body',
items: [ ref(ref: any) {
{ Group = ref;
type: RightCard, },
},
],
}, },
], ],
}; };
}, },
mounted() {
},
}; };
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className; 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> <script type="text/javascript" charset="UTF-8" src="./lib/bundle.min.js"></script>
</head> </head>
<body> <body>
<noscript> You need to enable JavaScript to run this app. </noscript>
</body> </body>
</html> </html>

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

@ -81,7 +81,7 @@ export function deleteConnection(id: string, cb: Function): void{
} }
} }
/** /**
* *
* @param id id * @param id id
* @param cb * @param cb
*/ */
@ -95,3 +95,14 @@ export function getConnectionStatus(id: string, cb: Function): void{
cb('success'); 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