Browse Source

feat: 完成连接池状态页面

master
alan 6 years ago
parent
commit
81e0bb5096
  1. 55
      src/app/app.component.scss
  2. 4
      src/app/app.model.ts
  3. 6
      src/app/link_set/link-set.model.ts
  4. 20
      src/app/link_set/right/right_edit/right.edit.component.ts
  5. 2
      src/app/link_set/right/right_edit/right.edit.service.ts
  6. 12
      src/app/link_set/right/right_title/right.title.component.ts
  7. 31
      src/app/link_status/left/left.component.ts
  8. 39
      src/app/link_status/left/left.item.component.ts
  9. 17
      src/app/link_status/left/left.model.ts
  10. 18
      src/app/link_status/left/left.service.ts
  11. 34
      src/app/link_status/link_status.component.ts
  12. 3
      src/app/link_status/link_status.model.ts
  13. 89
      src/app/link_status/right/right.card.component.ts
  14. 48
      src/app/link_status/right/right.component.ts
  15. 14
      src/app/link_status/right/right.model.ts
  16. 1
      src/ui/fineui.ts

55
src/app/app.component.scss

@ -45,6 +45,11 @@
} }
} }
} }
.status-title{
font-weight: 700;
margin-left: 12px;
margin-top: 12px;
}
} }
.left-list{ .left-list{
margin: 10px; margin: 10px;
@ -80,6 +85,8 @@
} }
} }
.database-right{ .database-right{
min-width: 400px;
overflow: auto;
.bi-flex-center-adapt-layout{ .bi-flex-center-adapt-layout{
height: 100%; height: 100%;
.data-connection-background{ .data-connection-background{
@ -87,6 +94,54 @@
background-size: contain; background-size: contain;
} }
} }
.right-status-title{
border-bottom: 1px solid #e8eaed;
color: #3d4d66;
line-height: 40px;
padding-left: 10px;
font-weight: 700;
}
.right-status-body{
margin: 10px 30px 0px 30px;
height: 50%;
.right-status-item{
height: 150px;
width: 50%;
top: 0; left: 0;
position: absolute !important;
.right-status-board { margin-left: 25px; position: relative !important; left: -25px;}
}
.right-status-right{
height: 150px;
width: 50%;
top: 0; right:0;
position: absolute !important;
.right-status-board { margin-right: 25px; position: relative !important; left: 25px; }
}
.right-status-board{
background-color: #f7f8fa;
color: #3d4d66;
width: 100%;
height: 100%;
.right-status-board-item{
text-align: center;
margin-top: 35px;
margin-bottom: 6px;
.right-status-text{
display: inline-block;
}
.card-font1{
color: #13CD66;
font-size: 32px;
}
.card-font2{
color: #3685F2;
font-size: 32px;
}
}
}
}
.right-content{ .right-content{
height: 100%; height: 100%;
.right-title{ .right-title{

4
src/app/app.model.ts

@ -4,7 +4,7 @@ import {LinkType} from '@ui/type';
const linkList: LinkType[] = []; const linkList: LinkType[] = [];
const Model: ModelType = { const Model: ModelType = {
childContext: ['tab', 'linkList', 'linkSelected', 'linkUpdate', 'moreLinkSelected'], childContext: ['tab', 'linkList', 'linkSelected', 'linkUpdate', 'moreLinkSelected', 'statusSelected', 'connectionNameErr'],
state () { state () {
return { return {
tab: '数据连接管理', tab: '数据连接管理',
@ -12,6 +12,8 @@ const Model: ModelType = {
linkSelected: {}, linkSelected: {},
linkUpdate: {}, linkUpdate: {},
moreLinkSelected:'', moreLinkSelected:'',
statusSelected:'',
connectionNameErr:'',
}; };
}, },
computed: { computed: {

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

@ -7,7 +7,7 @@ import {saveConnection} from './link-set.service';
const className = 'fr.model.linkset'; const className = 'fr.model.linkset';
const Model: ModelType = { const Model: ModelType = {
context: ['tab', 'linkList', 'linkSelected', 'linkUpdate'], context: ['tab', 'linkList', 'linkSelected', 'linkUpdate', 'connectionNameErr'],
actions: { actions: {
/** /**
* *
@ -161,7 +161,9 @@ const Model: ModelType = {
connectionName:name, connectionName:name,
}; };
}, },
setConnectionNameErr(err: string) {
this.model.connectionNameErr = err;
},
}, },
}; };
BI.model(className, BI.inherit(Fix.Model, Model)); BI.model(className, BI.inherit(Fix.Model, Model));

20
src/app/link_set/right/right_edit/right.edit.component.ts

@ -5,11 +5,23 @@ 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';
import {getDrivers} from './right.edit.service'; import {getDrivers} from './right.edit.service';
let ConnectionName: any = null;
const className = 'fr.component.right.edit'; const className = 'fr.component.right.edit';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
}, },
watch:{
connectionNameErr(msg: string) {
if (msg) {
BI.Bubbles.show('singleBubble', msg, ConnectionName, {
level: 'error',
});
} else {
BI.Bubbles.hide('singleBubble');
}
},
},
render() { render() {
const linkSelected: LinkType = this.model.linkSelected; const linkSelected: LinkType = this.model.linkSelected;
const that = this; const that = this;
@ -27,6 +39,9 @@ const Widget: WidgetType = {
cls: 'bi-border', cls: 'bi-border',
width: 300, width: 300,
value: linkSelected.connectionName, value: linkSelected.connectionName,
ref(ref: any) {
ConnectionName = ref;
},
listeners: [{ listeners: [{
eventName: BI.Editor.EVENT_CHANGE, eventName: BI.Editor.EVENT_CHANGE,
action() { action() {
@ -35,6 +50,11 @@ const Widget: WidgetType = {
connectionName: this.getValue(), connectionName: this.getValue(),
}); });
}, },
}, {
eventName: BI.Editor.EVENT_FOCUS,
action() {
that.store.setConnectionNameErr('');
},
}], }],
}, },
}, },

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

@ -2,7 +2,7 @@ import {LinkType} from '@ui/type';
export function getDrivers(linkSelected: LinkType): {text: string; value: string}[] { export function getDrivers(linkSelected: LinkType): {text: string; value: string}[] {
const drivers: {text: string; value: string}[] = []; const drivers: {text: string; value: string}[] = [];
if (linkSelected.drivers.length > 0) { if (linkSelected.drivers && linkSelected.drivers.length > 0) {
linkSelected.drivers.forEach(item => { linkSelected.drivers.forEach(item => {
drivers.push({ drivers.push({
text: item, text: item,

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

@ -9,6 +9,7 @@ const Widget: WidgetType = {
}, },
render() { render() {
const linkSelected: LinkType = this.model.linkSelected; const linkSelected: LinkType = this.model.linkSelected;
const linkList: LinkType[] = this.model.linkList;
const that = this; const that = this;
const {isEdit} = this.options; const {isEdit} = this.options;
@ -37,9 +38,14 @@ const Widget: WidgetType = {
invisible: !isEdit, invisible: !isEdit,
text: '保存', text: '保存',
handler() { handler() {
saveConnection(that.model.linkUpdate).then(() => { const result = BI.find(linkList, (idx: number, value: LinkType) => that.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== that.model.linkUpdate.connectionId);
that.store.setEdit(false); if (result) {
}); that.store.setConnectionNameErr('数据链接名已存在');
} else {
saveConnection(that.model.linkUpdate).then(() => {
that.store.setEdit(false);
});
}
}, },
}, },
{ {

31
src/app/link_status/left/left.component.ts

@ -0,0 +1,31 @@
import {WidgetType, Vertical} from '@ui';
import Model from './left.model';
import {LinkType} from '@ui/type';
import {getLinks} from './left.service';
const className = 'fr.component.linkStatus.left';
let leftContent: any = null;
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
watch:{
linkList(linkList: LinkType[]) {
const title = linkList.length > 0 ? linkList[0].connectionName : '';
this.store.setStatusSelected(title);
},
statusSelected(title: string) {
const linkList = this.model.linkList;
leftContent.populate(BI.createItems(getLinks(linkList, title)));
},
},
render() {
return {
type: Vertical,
ref(_ref: any) {
leftContent = _ref;
},
};
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

39
src/app/link_status/left/left.item.component.ts

@ -0,0 +1,39 @@
import {WidgetType, Left, Label} from '@ui';
import Model from './left.model';
const className = 'fr.component.linkStatus.left.item';
const Widget: WidgetType = {
props: {
title:'',
id:'',
creator: '',
},
_store() {
return BI.Models.getModel(Model);
},
render() {
const {title, extraCls, creator, text, id} = this.options;
return {
type: Left,
cls: 'left-item',
extraCls,
items: [
{
type: Label,
cls:'link-title',
textAlign: 'left',
text: title,
title,
},
],
};
},
mounted() {
const {title} = this.options;
this.element.on('click', () => {
this.store.setStatusSelected(title);
});
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

17
src/app/link_status/left/left.model.ts

@ -0,0 +1,17 @@
import {ModelType} from '@ui';
const className = 'fr.model.linkstatus.left';
const Model: ModelType = {
context: ['tab', 'linkList', 'statusSelected'],
state () {
return {
selected:'',
};
},
actions: {
setStatusSelected(title: string) {
this.model.statusSelected = title;
},
},
};
BI.model(className, BI.inherit(Fix.Model, Model));
export default className;

18
src/app/link_status/left/left.service.ts

@ -0,0 +1,18 @@
import {LinkType} from '@ui/type';
import LeftItem from './left.item.component';
export const getLinks = (linkList: LinkType[], selectTitle = ''): any => {
const links: any[] = [];
linkList.forEach((item: LinkType) => {
links.push({
type: LeftItem,
extraCls: item.connectionName === selectTitle ? 'left-item-selected' : '',
title: item.connectionName,
id: item.connectionId,
creator: item.creator,
text: item.text ? item.text : '默认',
});
});
return links;
};

34
src/app/link_status/link_status.component.ts

@ -1,5 +1,7 @@
import {WidgetType, Htape} from '@ui'; import {WidgetType, Htape, Vtape, Left, Label} from '@ui';
import linkStatusModel from './link_status.model'; import linkStatusModel from './link_status.model';
import LeftList from './left/left.component';
import Right from './right/right.component';
const className = 'fr.linkstatus'; const className = 'fr.linkstatus';
const Widget: WidgetType = { const Widget: WidgetType = {
@ -17,17 +19,31 @@ const Widget: WidgetType = {
cls: 'linkStatus', cls: 'linkStatus',
items: [{ items: [{
el: { el: {
type: 'bi.label', type: Vtape,
cls: 'layout-bg2', cls: 'database-left',
textAlign: 'left', items: [
text: '222', {
el: {
type: Left,
cls:'select-group',
items:[
{
type: Label,
cls:'status-title',
text: '数据连接',
},
],
},
height: 40,
}, {
type: LeftList,
cls: 'left-list',
},
],
}, },
width: 280, width: 280,
}, { }, {
type: 'bi.label', type: Right,
cls: 'layout-bg2',
textAlign: 'left',
text: '宽度充满剩余空间',
}], }],
}; };
}, },

3
src/app/link_status/link_status.model.ts

@ -1,9 +1,8 @@
import {ModelType} from '@ui'; import {ModelType} from '@ui';
const className = 'fr.model.linkstatus'; const className = 'fr.model.linkstatus';
const Model: ModelType = { const Model: ModelType = {
context: ['tab'], context: ['tab', 'linkList'],
actions: { actions: {
}, },
}; };
BI.model(className, BI.inherit(Fix.Model, Model)); BI.model(className, BI.inherit(Fix.Model, Model));

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

@ -0,0 +1,89 @@
import {WidgetType, Left, Label, Vertical} from '@ui/index';
const className = 'fr.component.linkStatus.right.card';
const Widget: WidgetType = {
render() {
return {
type: Left,
items: [
{
type: Left,
cls: 'right-status-item',
items: [
{
type: Vertical,
cls:'right-status-board',
items: [
{
type: Vertical,
cls:'right-status-board-item',
items: [
{
type: Label,
cls: 'right-status-text',
extraCls: 'card-font1',
text: '0',
},
{
type: Label,
cls: 'right-status-text',
text: '/',
},
{
type: Label,
cls: 'right-status-text',
text: '50',
},
],
},
{
type: Label,
text: '活动连接数',
},
],
},
],
},
{
type: Left,
cls: 'right-status-right',
items: [
{
type: Vertical,
cls:'right-status-board',
items: [
{
type: Vertical,
cls:'right-status-board-item',
items: [
{
type: Label,
cls: 'right-status-text',
extraCls: 'card-font2',
text: '0',
},
{
type: Label,
cls: 'right-status-text',
text: '/',
},
{
type: Label,
cls: 'right-status-text',
text: '50',
},
],
},
{
type: Label,
text: '空闲连接数',
},
],
},
],
},
],
};
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

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

@ -0,0 +1,48 @@
import {WidgetType, Vertical, Left, Label} from '@ui/index';
import Model from './right.model';
import RightCard from './right.card.component';
const className = 'fr.component.linkStatus.right';
let Title: any = null;
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
watch:{
statusSelected(title: string) {
Title.setText(`数据连接(${title})`);
},
},
render() {
return {
type:Vertical,
cls:'database-right',
items:[
{
type: Left,
height: 40,
cls: 'right-status-title',
items:[
{
type: Label,
text:'数据连接',
},
],
ref(ref: any) {
Title = ref;
},
}, {
type: Vertical,
cls: 'right-status-body',
items: [
{
type: RightCard,
},
],
},
],
};
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

14
src/app/link_status/right/right.model.ts

@ -0,0 +1,14 @@
import {ModelType} from '@ui';
const className = 'fr.model.linkstatus.right';
const Model: ModelType = {
context: ['linkList', 'statusSelected'],
state () {
return {
selected:'',
};
},
actions: {
},
};
BI.model(className, BI.inherit(Fix.Model, Model));
export default className;

1
src/ui/fineui.ts

@ -34,6 +34,7 @@ export const TextBubblePopupBarView = 'bi.text_bubble_bar_popup_view';
export const BubbleCombo = 'bi.bubble_combo'; export const BubbleCombo = 'bi.bubble_combo';
export const SearchEditor = 'bi.search_editor'; export const SearchEditor = 'bi.search_editor';
export const Img = 'bi.img'; export const Img = 'bi.img';
export const LeftRightVerticalAdapt = 'bi.left_right_vertical_adapt';
// 布局 // 布局
export const VerticalAdapt = 'bi.vertical_adapt'; export const VerticalAdapt = 'bi.vertical_adapt';

Loading…
Cancel
Save