Browse Source

Merge pull request #2 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:feature/10.0 to feature/10.0

* commit 'c77db613e9348db5327eeb528bfbe57126986b82':
  refactor: 避免使用页面上的text做判断
  style: 冒号后面加空格
  refactor: 将验证方法提取出来
  refactor: 去除自己绑定的按钮事件
  refactor: 将常量单独出来
  refactor: 将标识符配置为常量
  refactor: 修改国际化的引用方式
  refactor: 根据规范修改国际化的key
  feat: 国际化
  docs: update readme
  docs: update readme
  docs: update readme
qufenxi
alan 6 years ago
parent
commit
6905c8a6a3
  1. 1
      .eslintrc.js
  2. 8
      README.md
  3. 55
      i18n/zh_cn.properties
  4. 1
      package.json
  5. 8
      private/constants.ts
  6. 57
      private/i18n.ts
  7. 3
      readme.md
  8. 6
      src/app/app.component.scss
  9. 2
      src/app/app.component.ts
  10. 8
      src/app/app.model.ts
  11. 2
      src/app/link_set/left/left.service.ts
  12. 33
      src/app/link_set/left/left_item/left.item.component.ts
  13. 37
      src/app/link_set/left/left_item/left.item.icon.component.ts
  14. 9
      src/app/link_set/link-set.component.ts
  15. 16
      src/app/link_set/link-set.model.ts
  16. 21
      src/app/link_set/more/more.link.component.ts
  17. 8
      src/app/link_set/more/more.link.item.component.ts
  18. 6
      src/app/link_set/more/more.link.service.ts
  19. 9
      src/app/link_set/right/nothing.component.ts
  20. 102
      src/app/link_set/right/right_edit/right.edit.component.ts
  21. 5
      src/app/link_set/right/right_edit/right.edit.constant.ts
  22. 90
      src/app/link_set/right/right_edit/right.edit.mysql.component.ts
  23. 4
      src/app/link_set/right/right_edit/right.edit.service.ts
  24. 24
      src/app/link_set/right/right_show/right.show.component.ts
  25. 13
      src/app/link_set/right/right_title/right.title.component.ts
  26. 12
      src/app/link_set/select/select.component.ts
  27. 5
      src/app/link_set/select/select.service.ts
  28. 2
      src/app/link_status/left/left.component.ts
  29. 21
      src/app/link_status/left/left.item.component.ts
  30. 2
      src/app/link_status/left/left.model.ts
  31. 2
      src/app/link_status/left/left.service.ts
  32. 13
      src/app/link_status/link_status.component.ts
  33. 4
      src/app/link_status/right/right.card.component.ts
  34. 4
      src/app/link_status/right/right.component.ts
  35. 35
      src/app/title/title.component.ts
  36. 21
      src/app/title/title_item/title_item.component.ts
  37. 28
      src/demo/plugin.redis.edit.ts
  38. 16
      src/demo/plugin.redis.preview.ts
  39. 7
      src/demo/plugin.tedis.pool.ts
  40. 2
      src/index.html
  41. 3
      src/index.ts
  42. 38
      src/shared/service/dialog.service.ts
  43. 2
      tsconfig.json
  44. 1
      types/globals.d.ts
  45. 1
      webpack.config.js

1
.eslintrc.js

@ -25,6 +25,7 @@ module.exports = {
'for-direction': 2,
// 关键字前后必须有空格
'keyword-spacing': 2,
'key-spacing':2,
// 最大块嵌套深度为 5 层
'max-depth': [2, 5],
// 最大回调深度为 3 层

8
README.md

@ -1,7 +1,9 @@
# database-connection 数据连接设置页面
![start](https://img.shields.io/badge/start-2019%2F04%2F26-blue.svg) ![finui](https://img.shields.io/badge/lib-FinUi-blue.svg)
# Database Connection Manager
用于决策平台和设计器中管理数据连接的通用管理器
![finui](https://img.shields.io/badge/lib-FinUi-blue.svg)
[KERNEL-493](http://www.finedevelop.com:2016/browse/KERNEL-493)
## 开始
下载代码

55
i18n/zh_cn.properties

@ -0,0 +1,55 @@
Dec-Dcm_Connection_Management= 数据连接管理
Dec-Dcm_Pool_Connection_Management= 连接池管理
Dec-Dcm_Data_Connections= 数据连接
Dec-Dcm_Active_Connections_Number= 活动连接数
Dec-Dcm_Leisure_Connections_Number= 空闲连接数
Dec-Dcm_Connections= 连接
Dec-Dcm_Default= 默认
Dec-Dcm_Delete= 删除
Dec-Dcm_Test_Connection= 测试连接
Dec-Dcm_Copy= 复制
Dec-Dcm_Edit= 编辑
Dec-Dcm_Save= 保存
Dec-Dcm_Yes= 是
Dec-Dcm_No= 否
Dec-Dcm_Search= 搜索
Dec-Dcm_Type= 类型
Dec-Dcm_Other= 其他
Dec-Dcm_Tips= 提示
Dec-Dcm_Back= 返回
Dec-Dcm_Creator= 创建者
Dec-Dcm_First_Step= 第一步
Dec-Dcm_Second_Step= 第二步
Dec-Dcm_Third_Step= 第三步
Dec-Dcm_Connection_Detailed_Information= 详细信息
Dec-Dcm_Connection_Handup_Information= 收起信息
Dec-Dcm_Connection_Testing= 正在测试连接,请稍候...
Dec-Dcm_Connection_Test_Fail= 测试连接失败
Dec-Dcm_Connection_Test_Success= 连接成功
Dec-Dcm_Connection_Option_Cannot_Find= 找不到该连接的配置信息
Dec-Dcm_Connection_Config_No_Save= 当前设置尚未保存,是否保存?
Dec-Dcm_Connection_New= 新建数据连接
Dec-Dcm_Connection_More= 更多数据连接...
Dec-Dcm_Connection_More-Title= 更多数据连接
Dec-Dcm_Connection_Other= 其他
Dec-Dcm_Connection_Plase_Add_One= 请选择左侧数据连接或点击新建数据连接
Dec-Dcm_Connection_Is_Existence= 数据连接名已存在
Dec-Dcm_Connection_Form_ConnectionName= 数据连接名
Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm= *修改数据连接名会影响相关数据表和仪表板
Dec-Dcm_Connection_Form_Driver= 驱动器
Dec-Dcm_Connection_Form_URL= URL
Dec-Dcm_Connection_Form_Place_Input= 请输入
Dec-Dcm_Connection_Form_OriginalCharsetName= 编码
Dec-Dcm_Connection_Form_Auto= 自动
Dec-Dcm_Connection_Form_UserName= 用户名
Dec-Dcm_Connection_Form_Password= 密码
Dec-Dcm_Connection_Form_Pool_Properties= 连接池属性
Dec-Dcm_Connection_Form_SQL_Validation_Query= SQL验证查询
Dec-Dcm_Connection_Form_Connection-Check= 获取连接前校验
Dec-Dcm_Connection_Form_Connection_Max_Number= 最大活动连接数
Dec-Dcm_Connection_Form_Place_Input-Number= 请输入有效的正整数
Dec-Dcm_Connection_Form_Pattern= 模式
Dec-Dcm_Connection_Form_Database_Addr= 数据库地址
Dec-Dcm_Connection_Form_Database_Port= 端口号
Dec-Dcm_Connection_Make_Sure_Delete= 确定删除该数据连接?
Dec-Dcm_Connection_ReConnect= 重新连接

1
package.json

@ -10,6 +10,7 @@
"author": "alan <alan@fanrun.com>",
"license": "ISC",
"devDependencies": {
"@types/node": "^12.0.2",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"copy-webpack-plugin": "^5.0.2",

8
private/constants.ts

@ -0,0 +1,8 @@
export const OTHER_CONNECT = 'other';
export const DEFAULT_INFO = 'DESIGNER';
export const ACTION_DELETE = 'ACTION_DELETE';
export const ACTION_COPY = 'ACTION_COPY';
export const ACTION_TEST = 'ACTION_TEST';
export const TAB_LINK_SET = 'TAB_LINK_SET';
export const TAB_LINK_POOL = 'TAB_LINK_POOL';

57
private/i18n.ts

@ -0,0 +1,57 @@
export default {
'Dec-Dcm_Connection_Management': '数据连接管理',
'Dec-Dcm_Pool_Connection_Management': '连接池管理',
'Dec-Dcm_Data_Connections': '数据连接',
'Dec-Dcm_Active_Connections_Number': '活动连接数',
'Dec-Dcm_Leisure_Connections_Number': '空闲连接数',
'Dec-Dcm_Connections': '连接',
'Dec-Dcm_Default': '默认',
'Dec-Dcm_Delete': '删除',
'Dec-Dcm_Test_Connection': '测试连接',
'Dec-Dcm_Copy': '复制',
'Dec-Dcm_Edit': '编辑',
'Dec-Dcm_Save': '保存',
'Dec-Dcm_Yes': '是',
'Dec-Dcm_No': '否',
'Dec-Dcm_Search': '搜索',
'Dec-Dcm_Type': '类型',
'Dec-Dcm_Other': '其他',
'Dec-Dcm_Tips': '提示',
'Dec-Dcm_Back': '返回',
'Dec-Dcm_Creator': '创建者',
'Dec-Dcm_First_Step': '第一步',
'Dec-Dcm_Second_Step': '第二步',
'Dec-Dcm_Third_Step': '第三步',
'Dec-Dcm_Connection_Detailed_Information': '详细信息',
'Dec-Dcm_Connection_Handup_Information': '收起信息',
'Dec-Dcm_Connection_Testing': '正在测试连接,请稍候...',
'Dec-Dcm_Connection_Test_Fail': '测试连接失败',
'Dec-Dcm_Connection_Test_Success': '连接成功',
'Dec-Dcm_Connection_Option_Cannot_Find': '找不到该连接的配置信息',
'Dec-Dcm_Connection_Config_No_Save': '当前设置尚未保存,是否保存?',
'Dec-Dcm_Connection_New': '新建数据连接',
'Dec-Dcm_Connection_More': '更多数据连接...',
'Dec-Dcm_Connection_More-Title': '更多数据连接',
'Dec-Dcm_Connection_Other': '其他',
'Dec-Dcm_Connection_Plase_Add_One': '请选择左侧数据连接或点击新建数据连接',
'Dec-Dcm_Connection_Is_Existence': '数据连接名已存在',
'Dec-Dcm_Connection_Form_ConnectionName': '数据连接名',
'Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm': '*修改数据连接名会影响相关数据表和仪表板',
'Dec-Dcm_Connection_Form_Driver': '驱动器',
'Dec-Dcm_Connection_Form_URL': 'URL',
'Dec-Dcm_Connection_Form_Place_Input': '请输入',
'Dec-Dcm_Connection_Form_OriginalCharsetName': '编码',
'Dec-Dcm_Connection_Form_Auto': '自动',
'Dec-Dcm_Connection_Form_UserName': '用户名',
'Dec-Dcm_Connection_Form_Password': '密码',
'Dec-Dcm_Connection_Form_Pool_Properties': '连接池属性',
'Dec-Dcm_Connection_Form_SQL_Validation_Query': 'SQL验证查询',
'Dec-Dcm_Connection_Form_Connection-Check': '获取连接前校验',
'Dec-Dcm_Connection_Form_Connection_Max_Number': '最大活动连接数',
'Dec-Dcm_Connection_Form_Place_Input-Number': '请输入有效的正整数',
'Dec-Dcm_Connection_Form_Pattern': '模式',
'Dec-Dcm_Connection_Form_Database_Addr': '数据库地址',
'Dec-Dcm_Connection_Form_Database_Port': '端口号',
'Dec-Dcm_Connection_Make_Sure_Delete': '确定删除该数据连接?',
'Dec-Dcm_Connection_ReConnect': '重新连接',
};

3
readme.md

@ -1,3 +0,0 @@
# Database Connection Manager
用于决策平台和设计器中管理数据连接的通用管理器

6
src/app/app.component.scss

@ -5,7 +5,7 @@
.title{
background-color: #fff;
border-bottom: 1px solid #e8eaed;
.title-item{
.dec-title-item{
height: 39px;
line-height: 39px;
padding-left: 15px;
@ -19,6 +19,10 @@
font-weight: 700;
cursor: pointer;
}
.dec-title-item-selected{
color: #3685f2;
border-bottom: solid 2px #3685f2;
}
.close-button {
position: absolute !important;
right: 5px;

2
src/app/app.component.ts

@ -26,7 +26,7 @@ const Widget = BI.inherit(BI.Widget, {
height: 40,
},
{
type:linkSet,
type: linkSet,
},
{
type: linkStatus,

8
src/app/app.model.ts

@ -7,13 +7,13 @@ const Model: ModelType = {
childContext: ['tab', 'linkList', 'linkSelected', 'linkUpdate', 'moreLinkSelected', 'statusSelected', 'connectionNameErr'],
state () {
return {
tab: '数据连接管理',
tab: BI.i18nText('Dec-Dcm_Connection_Management'),
linkList,
linkSelected: {},
linkUpdate: {},
moreLinkSelected:'',
statusSelected:'',
connectionNameErr:'',
moreLinkSelected: '',
statusSelected: '',
connectionNameErr: '',
};
},
computed: {

2
src/app/link_set/left/left.service.ts

@ -10,7 +10,7 @@ export const getLinks = (linkList: LinkType[]): any => {
title: item.connectionName,
id: item.connectionId,
creator: item.creator,
text: item.text ? item.text : '默认',
text: item.text ? item.text : BI.i18nText('Dec-Dcm_Default'),
});
});

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

@ -1,11 +1,12 @@
import {WidgetType, Left, Label, Icon} from '@ui';
import {WidgetType, Left, Label, Icon, TextButton} from '@ui';
import ItemIcon from './left.item.icon.component';
import Model from '../../link-set.model';
import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/constants';
const className = 'fr.component.linkSet.left.item';
const Widget: WidgetType = {
props: {
title:'',
id:'',
title: '',
id: '',
creator: '',
},
_store() {
@ -24,15 +25,18 @@ const Widget: WidgetType = {
cls: 'link-font',
height: 24,
width: 26,
text: '连接',
text: BI.i18nText('Dec-Dcm_Connections'),
title,
},
{
type: Label,
cls:'link-title',
type: TextButton,
cls: 'link-title',
textAlign: 'left',
text: title,
title,
handler: () => {
this.store.setLinkSelected(title);
},
},
{
type: Left,
@ -41,25 +45,28 @@ const Widget: WidgetType = {
{
type: ItemIcon,
cls: 'link-text-font',
title: '测试连接',
title: BI.i18nText('Dec-Dcm_Test_Connection'),
value: ACTION_TEST,
id,
},
{
type: ItemIcon,
cls: 'copy-font',
title: '复制',
title: BI.i18nText('Dec-Dcm_Copy'),
value: ACTION_COPY,
id,
},
{
type: ItemIcon,
cls: 'info-font',
title: `类型${text === 'DESIGNER' ? '其他' : text} \r\n创建者${creator}`,
title: `${BI.i18nText('Dec-Dcm_Type')}${text === DEFAULT_INFO ? BI.i18nText('Dec-Dcm_Other') : text} \r\n${BI.i18nText('Dec-Dcm_Creator')}${creator}`,
id,
},
{
type: ItemIcon,
cls: 'delete-font',
title: '删除',
title: BI.i18nText('Dec-Dcm_Delete'),
value: ACTION_DELETE,
id,
},
],
@ -68,12 +75,6 @@ const Widget: WidgetType = {
],
};
},
mounted() {
const {title} = this.options;
this.element.on('click', () => {
this.store.setLinkSelected(title);
});
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

37
src/app/link_set/left/left_item/left.item.icon.component.ts

@ -1,16 +1,18 @@
import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView} from '@ui/index';
import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView, IconButton} from '@ui/index';
import Model from '../../link-set.model';
import {ACTION_DELETE} from '@private/constants';
const className = 'fr.component.linkSet.left.item.icon';
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
render() {
const {cls, title, id} = this.options;
const {cls, title, id, value} = this.options;
const that = this;
let iconContent: any = null;
let combo: any = null;
if (title === '删除') {
if (value === ACTION_DELETE) {
return {
type: BubbleCombo,
direction: 'bottom',
@ -20,7 +22,7 @@ const Widget: WidgetType = {
el: {
type: Icon,
cls,
extraCls: 'action-icon',
baseCls: 'action-icon',
height: 24,
width: 26,
title,
@ -30,7 +32,7 @@ const Widget: WidgetType = {
},
popup: {
type: TextBubblePopupBarView,
text: '确定删除该数据连接?',
text: BI.i18nText('Dec-Dcm_Connection_Make_Sure_Delete'),
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action (type: boolean) {
@ -45,14 +47,14 @@ const Widget: WidgetType = {
eventName: BI.BubbleCombo.EVENT_EXPAND,
action () {
iconContent.element.css({
visibility:'visible',
visibility: 'visible',
});
},
}, {
eventName: BI.BubbleCombo.EVENT_AFTER_HIDEVIEW,
action () {
iconContent.element.css({
visibility:'hidden',
visibility: 'hidden',
});
},
}],
@ -60,27 +62,20 @@ const Widget: WidgetType = {
}
return {
type: Icon,
type: IconButton,
cls,
extraCls: 'action-icon',
height: 24,
width: 26,
title,
handler: () => {
const {value, id, title} = this.options;
if (value !== ACTION_DELETE) {
this.store.onIconClick(title, id);
}
},
};
},
mounted() {
const {title, id} = this.options;
if (title !== '删除') {
this.element.on('click', (event: any) => {
event.stopPropagation();
this.store.onIconClick(title, id);
});
} else {
this.element.on('click', (event: any) => {
event.stopPropagation();
});
}
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

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

@ -3,14 +3,15 @@ import LeftList from './left/left.component';
import linkSetModel from './link-set.model';
import Select from './select/select.component';
import Right from './right/right.component';
import {TAB_LINK_SET} from '@private/constants';
const className = 'fr.linkset';
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(linkSetModel);
},
watch:{
watch: {
tab(tab: string) {
this.setVisible(tab === '数据连接管理');
this.setVisible(tab === TAB_LINK_SET);
},
},
render() {
@ -25,8 +26,8 @@ const Widget: WidgetType = {
{
el: {
type: Left,
cls:'select-group',
items:[
cls: 'select-group',
items: [
{
type: Select,
},

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

@ -33,17 +33,17 @@ const Model: ModelType = {
},
onIconClick(title: string, id: string) {
switch (title) {
case '删除':
case BI.i18nText('Dec-Dcm_Delete'):
deleteConnection(id, () => {
this.model.linkList = [...this.model.linkList.filter((item: LinkType) => item.connectionId !== id)];
this.model.linkSelected = {};
this.model.linkUpdate = {};
});
break;
case '测试连接':
case BI.i18nText('Dec-Dcm_Test_Connection'):
this._textLink(id);
break;
case '复制':
case BI.i18nText('Dec-Dcm_Copy'):
this.noSaveConfirm(() => {
this.copyLink(id);
});
@ -53,16 +53,16 @@ const Model: ModelType = {
}
},
_textLink(id: string) {
const loadingId = dialog.loading('正在测试连接,请稍候...');
const loadingId = dialog.loading(BI.i18nText('Dec-Dcm_Connection_Testing'));
const link = this.model.linkList.find((item: LinkType) => item.connectionId === id);
testConnection(link, (res: any) => {
dialog.close(loadingId);
if (res && res.errorCode) {
dialog.linkFail(`${link.connectionName}测试连接失败`, res.errorMsg, () => {
dialog.linkFail(`${link.connectionName}${BI.i18nText('Dec-Dcm_Connection_Test_Fail')}`, res.errorMsg, () => {
this._textLink(id);
});
} else {
dialog.success('连接成功');
dialog.success(BI.i18nText('Dec-Dcm_Connection_Test_Success'));
}
});
},
@ -125,7 +125,7 @@ const Model: ModelType = {
},
setNewLink(value: string) {
if (!databaseTyle.some(item => item.text === value) && !BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${value.toLowerCase()}.edit`)) {
dialog.error('找不到该连接的配置信息');
dialog.error(BI.i18nText('Dec-Dcm_Connection_Option_Cannot_Find'));
return;
}
@ -167,7 +167,7 @@ const Model: ModelType = {
},
noSaveConfirm(cb: Function) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
dialog.confirm(BI.i18nText('Dec-Dcm_Connection_Config_No_Save'), (isConfirm: boolean) => {
if (isConfirm) {
this.saveLink();
} else {

21
src/app/link_set/more/more.link.component.ts

@ -10,19 +10,19 @@ const Widget: WidgetType = {
cls: 'more-link',
items: [
{
el:{
el: {
type: Vertical,
items:[{
items: [{
type: SearchEditor,
width: 300,
watermark: '搜索',
watermark: BI.i18nText('Dec-Dcm_Search'),
}],
},
height: 30,
},
{
type: Left,
cls:'more-link-item',
cls: 'more-link-item',
ref(ref: any) {
morkLinkItem = ref;
},
@ -43,15 +43,10 @@ const Widget: WidgetType = {
text: item.text,
name: item.databaseType,
selected: text === item.text,
listeners: [
{
eventName: 'EVENT_SELECT',
action (text: string) {
that._renderItems(text);
that.fireEvent('EVENT_SELECT', text);
},
},
],
handler: () => {
that._renderItems(item.text);
that.fireEvent('EVENT_SELECT', item.text);
},
});
});
morkLinkItem.populate(BI.createItems(items));

8
src/app/link_set/more/more.link.item.component.ts

@ -29,12 +29,6 @@ const Widget: WidgetType = {
],
};
},
mounted() {
const {text} = this.options;
this.element.on('click', () => {
this.fireEvent('EVENT_SELECT', text);
});
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
BI.shortcut(className, BI.inherit(BI.BasicButton, Widget));
export default className;

6
src/app/link_set/more/more.link.service.ts

@ -7,7 +7,7 @@ export const moreLink = (onConfirm?: Function): void => {
BI.Popovers.create(id, {
type: 'bi.bar_popover',
size: 'normal',
header: '更多数据连接',
header: BI.i18nText('Dec-Dcm_Connection_More-Title'),
width: 550,
height: 500,
body: {
@ -27,7 +27,7 @@ export const moreLink = (onConfirm?: Function): void => {
lgap: 10,
items: [{
type: 'bi.button',
text: '取消',
text: BI.i18nText('BI-Basic_Cancel'),
value: 1,
level: 'ignore',
handler (v: any) {
@ -35,7 +35,7 @@ export const moreLink = (onConfirm?: Function): void => {
},
}, {
type: 'bi.button',
text: '确定',
text: BI.i18nText('BI-Basic_Sure'),
disabled: true,
value: 0,
ref(ref: any) {

9
src/app/link_set/right/nothing.component.ts

@ -17,15 +17,8 @@ const Widget: WidgetType = {
},
{
type:Label,
cls: 'bi-tips',
height: 20,
text:'请选择左侧数据连接或点击新建数据连接',
},
{
type:Label,
cls: 'bi-tips',
height: 20,
text:'平台仅支持使用JDBC的数据连接的管理',
text: BI.i18nText('Dec-Dcm_Connection_Plase_Add_One'),
},
],

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

@ -4,14 +4,14 @@ 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';
import {getDrivers} from './right.edit.service';
import {getDrivers, connectNameChecker} from './right.edit.service';
let ConnectionName: any = null;
const className = 'fr.component.right.edit';
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
watch:{
watch: {
connectionNameErr(msg: string) {
if (msg) {
BI.Bubbles.show('singleBubble', msg, ConnectionName, {
@ -32,9 +32,9 @@ const Widget: WidgetType = {
items: [
{
type: FormItem,
text: '数据连接名',
hint: '*修改数据连接名会影响相关数据表和仪表板',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'),
hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'),
form: {
type: Editor,
cls: 'bi-border',
width: 300,
@ -60,16 +60,16 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '第一步',
text: BI.i18nText('Dec-Dcm_First_Step'),
height: 400,
form:{
form: {
type: Vertical,
cls: 'right-form',
items:[
items: [
{
type: FormItem,
text: '驱动器',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
form: {
type: TextValueCombo,
cls: 'bi-border',
width: 300,
@ -88,11 +88,11 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: 'URL',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_URL'),
form: {
type: Editor,
cls: 'bi-border',
watermark:'请输入',
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.url,
listeners: [{
@ -108,13 +108,19 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '编码',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),
form: {
type: TextValueCombo,
cls: 'bi-border',
width: 300,
text: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName,
items: BI.Constants.getConstant(charset),
text: linkSelected.originalCharsetName === '' ? BI.i18nText('Dec-Dcm_Connection_Form_Auto') : linkSelected.originalCharsetName,
items: [
{
text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'),
value: '',
},
...BI.Constants.getConstant(charset),
],
listeners: [{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action() {
@ -128,12 +134,12 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '用户名',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_UserName'),
form: {
type: Editor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.user,
listeners: [{
@ -149,13 +155,13 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '密码',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Password'),
form: {
type: Editor,
cls: 'bi-border',
inputType:'password',
allowBlank:true,
watermark:'请输入',
inputType: 'password',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.password,
listeners: [{
@ -171,19 +177,19 @@ const Widget: WidgetType = {
},
{
type: Title,
text: '连接池属性',
text: BI.i18nText('Dec-Dcm_Connection_Form_Pool_Properties'),
},
{
type: FormItem,
text: 'SQL验证查询',
text: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'),
height: 100,
form:{
form: {
type: TextAreaEditor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
height:100,
height: 100,
value: linkSelected.validationQuery,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
@ -198,10 +204,10 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '获取连接前校验',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'),
form: {
type: MultiSelectItem,
text: '是',
text: BI.i18nText('Dec-Dcm_Yes'),
selected: linkSelected.testOnBorrow,
width: 60,
listeners: [{
@ -217,22 +223,16 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '最大活动连接数',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Connection_Max_Number'),
form: {
type: Editor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 60,
value: linkSelected.maxActive,
errorText: '请输入有效的正整数',
validationChecker (v: string) {
if (/^\+?[1-9][0-9]*$/.test(v)) {
return true;
}
return false;
},
errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'),
validationChecker: connectNameChecker,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action() {
@ -249,19 +249,19 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '第二步',
text: BI.i18nText('Dec-Dcm_Second_Step'),
form: {
type: Button,
text: '测试连接',
text: BI.i18nText('Dec-Dcm_Test_Connection'),
level: 'ignore',
},
},
{
type: FormItem,
text: '第三步',
text: BI.i18nText('Dec-Dcm_Third_Step'),
form: {
type: FormItem,
text: '模式',
text: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
form: {
type: Editor,
cls: 'bi-border',

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

@ -1,9 +1,6 @@
export const ConstantName = 'bi.constant.database.conf.charset.list';
export const Constant = BI.constant(ConstantName, [
{
text: '自动',
value: '',
},
{
text: 'GBK',
value: 'GBK',

90
src/app/link_set/right/right_edit/right.edit.mysql.component.ts

@ -4,7 +4,7 @@ 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';
import {getDrivers} from './right.edit.service';
import {getDrivers, connectNameChecker} from './right.edit.service';
const className = 'fr.component.right.edit.mysql';
const Widget: WidgetType = {
_store() {
@ -20,9 +20,9 @@ const Widget: WidgetType = {
items: [
{
type: FormItem,
text: '数据连接名',
hint: '*修改数据连接名会影响相关数据表和仪表板',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'),
hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'),
form: {
type: Editor,
cls: 'bi-border',
width: 300,
@ -40,8 +40,8 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '驱动器',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
form: {
type: TextValueCombo,
cls: 'bi-border',
width: 300,
@ -60,11 +60,11 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: 'URL',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_URL'),
form: {
type: Editor,
cls: 'bi-border',
watermark:'请输入',
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.url,
listeners: [{
@ -80,13 +80,19 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '编码',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),
form: {
type: TextValueCombo,
cls: 'bi-border',
width: 300,
text: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName,
items: BI.Constants.getConstant(charset),
text: linkSelected.originalCharsetName === '' ? BI.i18nText('Dec-Dcm_Connection_Form_Auto') : linkSelected.originalCharsetName,
items: [
{
text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'),
value: '',
},
...BI.Constants.getConstant(charset),
],
listeners: [{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action() {
@ -100,12 +106,12 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '用户名',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_UserName'),
form: {
type: Editor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.user,
listeners: [{
@ -121,13 +127,13 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '密码',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Password'),
form: {
type: Editor,
cls: 'bi-border',
inputType:'password',
allowBlank:true,
watermark:'请输入',
inputType: 'password',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
value: linkSelected.password,
listeners: [{
@ -143,19 +149,19 @@ const Widget: WidgetType = {
},
{
type: Title,
text: '连接池属性',
text: BI.i18nText('Dec-Dcm_Connection_Form_Pool_Properties'),
},
{
type: FormItem,
text: 'SQL验证查询',
text: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'),
height: 100,
form:{
form: {
type: TextAreaEditor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 300,
height:100,
height: 100,
value: linkSelected.validationQuery,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
@ -170,10 +176,10 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '获取连接前校验',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'),
form: {
type: MultiSelectItem,
text: '是',
text: BI.i18nText('Dec-Dcm_Yes'),
selected: linkSelected.testOnBorrow,
width: 60,
listeners: [{
@ -189,22 +195,16 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '最大活动连接数',
form:{
text: BI.i18nText('Dec-Dcm_Connection_Form_Connection_Max_Number'),
form: {
type: Editor,
cls: 'bi-border',
allowBlank:true,
watermark:'请输入',
allowBlank: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'),
width: 60,
value: linkSelected.maxActive,
errorText: '请输入有效的正整数',
validationChecker (v: string) {
if (/^\+?[1-9][0-9]*$/.test(v)) {
return true;
}
return false;
},
errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'),
validationChecker: connectNameChecker,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action() {
@ -218,10 +218,10 @@ const Widget: WidgetType = {
},
{
type: FormItem,
text: '测试连接',
text: BI.i18nText('Dec-Dcm_Test_Connection'),
form: {
type: Button,
text: '测试连接',
text: BI.i18nText('Dec-Dcm_Test_Connection'),
level: 'ignore',
},
},

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

@ -18,3 +18,7 @@ export function getDrivers(linkSelected: LinkType): {text: string; value: string
return drivers;
}
export function connectNameChecker(name: string): boolean {
return /^\+?[1-9][0-9]*$/.test(name);
}

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

@ -17,51 +17,51 @@ const Widget: WidgetType = {
items: [
{
type: BothSide,
leftText: '数据连接名',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'),
rightText: linkSelected.connectionName,
},
{
type: BothSide,
leftText: '驱动器',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
rightText: linkSelected.driver,
},
{
type: BothSide,
leftText: 'URL',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_URL'),
rightText: linkSelected.url,
},
{
type: BothSide,
leftText: '编码',
rightText: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName,
leftText: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'),
rightText: linkSelected.originalCharsetName === '' ? BI.i18nText('Dec-Dcm_Connection_Form_Auto') : linkSelected.originalCharsetName,
},
{
type: BothSide,
leftText: '用户名',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_UserName'),
rightText: linkSelected.user,
},
{
type: BothSide,
leftText: '密码',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_Password'),
rightText: linkSelected.password,
},
{
type: Title,
text: '连接池属性',
text: BI.i18nText('Dec-Dcm_Connection_Form_Pool_Properties'),
},
{
type: BothSide,
leftText: 'SQL验证查询',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'),
rightText: linkSelected.validationQuery,
},
{
type: BothSide,
leftText: '获取连接前校验',
rightText: linkSelected.testOnBorrow ? '是' : '否',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'),
rightText: linkSelected.testOnBorrow ? BI.i18nText('Dec-Dcm_Yes') : BI.i18nText('Dec-Dcm_No'),
},
{
type: BothSide,
leftText: '最大连接数量',
leftText: BI.i18nText('Dec-Dcm_Connection_Form_Connection_Max_Number'),
rightText: linkSelected.maxActive,
},
],

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

@ -1,7 +1,7 @@
import {WidgetType, Left, Label, Button} from '@ui/index';
import RightTitleModel from '../../link-set.model';
import {LinkType} from '@ui/type';
import {saveConnection} from '../../link-set.service';
import {OTHER_CONNECT} from '@private/constants';
const className = 'fr.component.right.title';
const Widget: WidgetType = {
_store() {
@ -12,6 +12,7 @@ const Widget: WidgetType = {
const linkList: LinkType[] = this.model.linkList;
const that = this;
const {isEdit} = this.options;
const title = linkSelected.text === OTHER_CONNECT ? BI.i18nText('Dec-Dcm_Connection_Other') : linkSelected.text;
return {
type: Left,
@ -21,13 +22,13 @@ const Widget: WidgetType = {
{
type: Label,
cls: 'right-title-text',
text: `数据连接(${linkSelected.text ? linkSelected.text : '默认'})`,
text: `${BI.i18nText('Dec-Dcm_Data_Connections')}(${title ? title : BI.i18nText('Dec-Dcm_Default')})`,
},
{
type: Button,
cls:'right-title-button',
invisible: isEdit,
text: '编辑',
text: BI.i18nText('Dec-Dcm_Edit'),
handler() {
that.store.setEdit(true);
},
@ -36,11 +37,11 @@ const Widget: WidgetType = {
type: Button,
cls:'right-title-button',
invisible: !isEdit,
text: '保存',
text: BI.i18nText('Dec-Dcm_Save'),
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(BI.i18nText('Dec-Dcm_Connection_Is_Existence'));
} else {
that.store.saveLink();
}
@ -51,7 +52,7 @@ const Widget: WidgetType = {
cls:'right-title-button',
invisible: !isEdit,
level: 'ignore',
text: '取消',
text: BI.i18nText('BI-Basic_Cancel'),
handler() {
that.store.setCancel();
},

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

@ -17,7 +17,7 @@ const Widget: WidgetType = {
adjustYOffset: 4,
el: {
type: 'bi.button',
text: '新建数据连接',
text: BI.i18nText('Dec-Dcm_Connection_New'),
height: 24,
},
popup: {
@ -38,17 +38,17 @@ const Widget: WidgetType = {
cls: 'link-item',
height: 24,
width: 152,
text: '更多数据连接...',
title:'更多数据连接...',
text: BI.i18nText('Dec-Dcm_Connection_More'),
title: BI.i18nText('Dec-Dcm_Connection_More'),
value: 'more',
}, {
type: TextItem,
cls: 'link-item',
height: 24,
width: 152,
text: '其他',
title:'其他',
value: '其他',
text: BI.i18nText('Dec-Dcm_Connection_Other'),
title: BI.i18nText('Dec-Dcm_Connection_Other'),
value: 'other',
}],
layouts: [{
type: Vertical,

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

@ -1,5 +1,6 @@
import {LinkType} from '@ui/type';
import pluginListConstant from '../../app.constant';
import {OTHER_CONNECT} from '@private/constants';
export const databaseTyle = [
{
@ -70,7 +71,7 @@ export const databaseTyle = [
url: 'jdbc:mysql://localhost/dbname',
},
{
text:'其他',
text: OTHER_CONNECT,
databaseType: 'other',
driver: 'org.h2.Driver',
drivers:['org.h2.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'],
@ -266,7 +267,7 @@ export const getCnnectionName = (links: LinkType[], name: string): string => {
let nameIndex = 0;
const title = name.replace(/[0-9]/g, '');
const isPlugin = BI.some(plugins, (index: number, item: string) => item === title);
const startWith = isPlugin ? title : '数据连接';
const startWith = isPlugin ? title : BI.i18nText('Dec-Dcm_Data_Connections');
links.forEach(link => {
link.isSelected = false;

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

@ -8,7 +8,7 @@ const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
watch:{
watch: {
linkList(linkList: LinkType[]) {
const title = linkList.length > 0 ? linkList[0].connectionName : '';
this.store.setStatusSelected(title);

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

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

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

@ -4,7 +4,7 @@ const Model: ModelType = {
context: ['tab', 'linkList', 'statusSelected'],
state () {
return {
selected:'',
selected: '',
};
},
actions: {

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

@ -10,7 +10,7 @@ export const getLinks = (linkList: LinkType[], selectTitle = ''): any => {
title: item.connectionName,
id: item.connectionId,
creator: item.creator,
text: item.text ? item.text : '默认',
text: item.text ? item.text : BI.i18nText('Dec-Dcm_Default'),
});
});

13
src/app/link_status/link_status.component.ts

@ -2,15 +2,16 @@ import {WidgetType, Htape, Vtape, Left, Label} from '@ui';
import linkStatusModel from './link_status.model';
import LeftList from './left/left.component';
import Right from './right/right.component';
import {TAB_LINK_POOL} from '@private/constants';
const className = 'fr.linkstatus';
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(linkStatusModel);
},
watch:{
watch: {
tab(tab: string) {
this.setVisible(tab === '连接池状态');
this.setVisible(tab === TAB_LINK_POOL);
},
},
render() {
@ -25,12 +26,12 @@ const Widget: WidgetType = {
{
el: {
type: Left,
cls:'select-group',
items:[
cls: 'select-group',
items: [
{
type: Label,
cls:'status-title',
text: '数据连接',
cls: 'status-title',
text: BI.i18nText('Dec-Dcm_Data_Connections'),
},
],
},

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

@ -40,7 +40,7 @@ const Widget: WidgetType = {
{
type: Label,
height: 20,
text: '活动连接数',
text: BI.i18nText('Dec-Dcm_Active_Connections_Number'),
},
],
},
@ -79,7 +79,7 @@ const Widget: WidgetType = {
{
type: Label,
height: 20,
text: '空闲连接数',
text: BI.i18nText('Dec-Dcm_Leisure_Connections_Number'),
},
],
},

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

@ -26,7 +26,7 @@ const Widget: WidgetType = {
...res,
}]));
});
Title.setText(`数据连接(${title})`);
Title.setText(`${BI.i18nText('Dec-Dcm_Data_Connections')}(${title})`);
},
},
render() {
@ -41,7 +41,7 @@ const Widget: WidgetType = {
items:[
{
type: Label,
text:'数据连接',
text:BI.i18nText('Dec-Dcm_Data_Connections'),
},
],
ref(ref: any) {

35
src/app/title/title.component.ts

@ -1,7 +1,7 @@
import {Left, WidgetType, IconButton} from '@ui/index';
import TitleItem from './title_item/title_item.component';
import {isDesigner, closeWindow} from '@shared/crud/crud.request';
const tabs = ['数据连接管理', '连接池状态'];
import {TAB_LINK_SET, TAB_LINK_POOL} from '@private/constants';
const className = 'fr.title';
const Widget: WidgetType = {
render() {
@ -9,15 +9,32 @@ const Widget: WidgetType = {
type: Left,
cls: 'title',
items: [
...BI.map(tabs, (index: number, text: string) => {
return {
type: TitleItem,
text,
};
}),
{
type:IconButton,
cls:'close-button',
type: TitleItem,
cls: 'dec-title-item-selected',
text: BI.i18nText('Dec-Dcm_Connection_Management'),
value: TAB_LINK_SET,
ref: _ref => {
this.ConnectSet = _ref;
},
handler: () => {
this.ConnectSet.select();
},
},
{
type: TitleItem,
text: BI.i18nText('Dec-Dcm_Pool_Connection_Management'),
value: TAB_LINK_POOL,
ref: _ref => {
this.ConnectPool = _ref;
},
handler: () => {
this.ConnectPool.select();
},
},
{
type: IconButton,
cls: 'close-button',
handler() {
closeWindow();
},

21
src/app/title/title_item/title_item.component.ts

@ -2,17 +2,17 @@ import {Label} from '@ui';
import tableItemModel from './title_item.model';
import {getSelectStyle} from './title_item.service';
const className = 'fr.title.item';
const Widget = BI.inherit(BI.Widget, {
const Widget = BI.inherit(BI.BasicButton, {
props: {
text:'',
text: '',
},
_store() {
return BI.Models.getModel(tableItemModel);
},
watch:{
watch: {
tab(tab: string) {
const {text} = this.options;
this.element.css(getSelectStyle(text, tab));
const {value} = this.options;
this.element.css(getSelectStyle(value, tab));
},
},
render() {
@ -20,16 +20,13 @@ const Widget = BI.inherit(BI.Widget, {
return {
type: Label,
cls: 'title-item',
cls: 'dec-title-item',
text,
};
},
mounted() {
const {text} = this.options;
this.element.css(getSelectStyle('数据连接管理', text));
this.element.on('click', () => {
this.store.setTab(text);
});
select() {
const {value} = this.options;
this.store.setTab(value);
},
});
BI.shortcut(className, Widget);

28
src/demo/plugin.redis.edit.ts

@ -1,7 +1,7 @@
import './style.scss';
const RedisConstantName = 'dec.constant.database.conf.connect.form.redis.value';
const form = {
url:'192.168.1.22',
url: '192.168.1.22',
port: 6379,
password: '123456',
};
@ -11,8 +11,8 @@ const Widget = BI.inherit(BI.Widget, {
render() {
return {
type: 'bi.vertical',
cls:'bi-plugin-redis',
bgap:10,
cls: 'bi-plugin-redis',
bgap: 10,
items: [
{
type: 'bi.left',
@ -20,7 +20,7 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '数据库地址:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Database_Addr'),
height: 24,
width: 115,
textAlign: 'left',
@ -28,8 +28,8 @@ const Widget = BI.inherit(BI.Widget, {
{
type: 'bi.editor',
cls: 'bi-border',
watermark: '数据库地址',
value:form.url,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Addr'),
value: form.url,
allowBlank: true,
width: 300,
height: 24,
@ -41,7 +41,7 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '端口:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'),
height: 24,
width: 115,
textAlign: 'left',
@ -49,18 +49,14 @@ const Widget = BI.inherit(BI.Widget, {
{
type: 'bi.editor',
cls: 'bi-border',
watermark: '端口',
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'),
allowBlank: true,
width: 300,
height: 24,
value: form.port,
errorText: '请输入有效的正整数',
errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'),
validationChecker (v: string) {
if (/^\+?[1-9][0-9]*$/.test(v)) {
return true;
}
return false;
return /^\+?[1-9][0-9]*$/.test(v);
},
}],
},
@ -70,7 +66,7 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '密码:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Password'),
height: 24,
width: 115,
textAlign: 'left',
@ -78,7 +74,7 @@ const Widget = BI.inherit(BI.Widget, {
{
type: 'bi.editor',
cls: 'bi-border',
inputType:'password',
inputType: 'password',
value: form.password,
allowBlank: true,
width: 300,

16
src/demo/plugin.redis.preview.ts

@ -6,8 +6,8 @@ const Widget = BI.inherit(BI.Widget, {
render() {
return {
type: 'bi.vertical',
cls:'bi-plugin-redis',
bgap:10,
cls: 'bi-plugin-redis',
bgap: 10,
items: [
{
type: 'bi.left',
@ -15,14 +15,14 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '数据库地址:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Database_Addr'),
height: 24,
width: 115,
textAlign: 'left',
},
{
type: 'bi.label',
text:form.url,
text: form.url,
height: 24,
}],
},
@ -32,14 +32,14 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '端口:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Database_Port'),
height: 24,
width: 115,
textAlign: 'left',
},
{
type: 'bi.label',
text:form.port,
text: form.port,
height: 24,
}],
},
@ -49,14 +49,14 @@ const Widget = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.label',
text: '密码:',
text: BI.i18nText('Dec-Dcm_Connection_Form_Password'),
height: 24,
width: 115,
textAlign: 'left',
},
{
type: 'bi.label',
text:'********',
text: '********',
height: 24,
}],
},

7
src/demo/plugin.tedis.pool.ts

@ -13,11 +13,11 @@ const WidgetPool = BI.inherit(BI.Widget, {
items: [
{
type: 'bi.vertical',
cls:'right-status-board',
cls: 'right-status-board',
items: [
{
type: 'bi.vertical',
cls:'right-status-board-item',
cls: 'right-status-board-item',
items: [
{
type: 'bi.label',
@ -39,7 +39,8 @@ const WidgetPool = BI.inherit(BI.Widget, {
},
{
type: 'bi.label',
text: 'Redis连接数',
height: 20,
text: BI.i18nText('Dec-Dcm_Active_Connections_Number'),
},
],
},

2
src/index.html

@ -5,6 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>数据库连接设置</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 先这样引用方便前端调试 -->
<link rel="stylesheet" type="text/css" href="./lib/fineui.min.css" />
<script type="text/javascript" charset="UTF-8" src="./lib/fineui.min.js"></script>
</head>

3
src/index.ts

@ -1,5 +1,8 @@
import i18n from '../private/i18n';
BI.DOM.ready(() => {
const app = require('./app/app.component').default;
// TODO: 先采用这种方式方便前端调试
BI.addI18n(i18n);
BI.createWidget({
type:app,
element: 'body',

38
src/shared/service/dialog.service.ts

@ -10,7 +10,7 @@ class Dialog {
BI.Popovers.create(id, {
type: 'bi.bar_popover',
size: 'normal',
header: '提示',
header: BI.i18nText('Dec-Dcm_Tips'),
width: 450,
height: 220,
body: {
@ -54,7 +54,7 @@ class Dialog {
items: [
{
type: Vertical,
items:[
items: [
{
type: 'bi.layout',
cls: 'loading-icon',
@ -80,7 +80,7 @@ class Dialog {
items: [
{
type: Vertical,
items:[
items: [
{
type: 'bi.layout',
cls: 'success-icon',
@ -105,7 +105,7 @@ class Dialog {
items: [
{
type: Vertical,
items:[
items: [
{
type: 'bi.layout',
cls: 'error-icon',
@ -135,11 +135,11 @@ class Dialog {
{
type: 'bi.center_adapt',
cls: 'show-content',
tgap:10,
tgap: 10,
items: [
{
type: Vertical,
items:[
items: [
{
type: Layout,
cls: 'error-icon',
@ -152,24 +152,24 @@ class Dialog {
},
{
type: Left,
cls:'buttons',
items:[
cls: 'buttons',
items: [
{
type: Button,
text:'详细信息',
text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'),
level: 'ignore',
handler() {
const isHide = this.getText() === '详细信息';
const isHide = !More.isVisible();
Popover.element.css({
height: isHide ? '290' : '220',
});
More.setVisible(isHide);
this.setText(isHide ? '收起信息' : '详细信息');
this.setText(isHide ? BI.i18nText('Dec-Dcm_Connection_Handup_Information') : BI.i18nText('Dec-Dcm_Connection_Detailed_Information'));
},
},
{
type: Button,
text:'返回',
text: BI.i18nText('Dec-Dcm_Back'),
level: 'ignore',
handler() {
that.close(id);
@ -177,7 +177,7 @@ class Dialog {
},
{
type: Button,
text:'重新连接',
text: BI.i18nText('Dec-Dcm_Connection_ReConnect'),
handler() {
that.close(id);
cb ? cb() : null;
@ -191,9 +191,11 @@ class Dialog {
],
}, {
type: Label,
cls:'show-more',
text:more,
cls: 'show-more',
text: more,
invisible: true,
height: 73,
value: false,
ref(ref: any) {
More = ref;
},
@ -202,8 +204,7 @@ class Dialog {
};
BI.Popovers.create(id, {
type: 'bi.popover',
cls:'popover-notitle',
extraCls:'bi-custom-show',
cls: 'popover-notitle bi-custom-show',
size: 'normal',
width: 450,
height: 220,
@ -223,8 +224,7 @@ class Dialog {
const id = BI.UUID();
BI.Popovers.create(id, {
type: 'bi.popover',
cls:'popover-notitle',
extraCls:'bi-custom-show',
cls: 'popover-notitle bi-custom-show',
size: 'normal',
width: 450,
height: 220,

2
tsconfig.json

@ -17,6 +17,8 @@
"@types": ["src/ui/index"],
"@shared/*": ["src/shared/*"],
"@shared": ["src/shared"],
"@private/*": ["private/*"],
"@private": ["private"],
}
},
"include": [

1
types/globals.d.ts vendored

@ -6,3 +6,4 @@ declare let BI: Obj;
declare const Fix: Obj;
declare const Dec: Obj;
declare const PluginHelper: Obj;
declare const Store: Obj;

1
webpack.config.js

@ -24,6 +24,7 @@ module.exports = env => {
"@ui": path.resolve("src/ui"),
"@types": path.resolve("types"),
"@shared": path.resolve("src/shared"),
"@private": path.resolve("private"),
}
},
plugins: [htmlWebpackPlugin, new MiniCssExtractPlugin({filename: `style.css`}), new CopyPlugin([

Loading…
Cancel
Save