From 16263ffd981364379fe08bb74642bdc9e6dfecaf Mon Sep 17 00:00:00 2001 From: alan Date: Wed, 22 May 2019 11:59:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A0=E5=85=A5jdni=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/zh_cn.properties | 7 +- private/i18n.ts | 6 + src/app/app.component.ts | 6 +- src/plugins/jndi/jdni.scss | 3 + src/plugins/jndi/jdni.typing.d.ts | 25 +++ src/plugins/jndi/jndi.edit.ts | 187 +++++++++++++++++++ src/plugins/jndi/jndi.pool.ts | 54 ++++++ src/plugins/jndi/jndi.preview.ts | 139 ++++++++++++++ src/plugins/jndi/jndi.service.ts | 87 +++++++++ src/shared/components/form.item.component.ts | 6 +- 10 files changed, 513 insertions(+), 7 deletions(-) create mode 100644 src/plugins/jndi/jdni.scss create mode 100644 src/plugins/jndi/jdni.typing.d.ts create mode 100644 src/plugins/jndi/jndi.edit.ts create mode 100644 src/plugins/jndi/jndi.pool.ts create mode 100644 src/plugins/jndi/jndi.preview.ts create mode 100644 src/plugins/jndi/jndi.service.ts diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 6509988..32d7ec2 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -52,4 +52,9 @@ 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= 重新连接 \ No newline at end of file +Dec-Dcm_Connection_ReConnect= 重新连接 +Dec-Dcm_Connection_JNDI_Form_ConnectionName= JNDI的名字 +Dec-Dcm_Connection_Form_JNDI_Context= 上下文 +Dec-Dcm_Connection_Form_JNDI_Advanced= 高级 +Dec-Dcm_Connection_Form_JNDI_Other_Attributes= 其他属性 +Dec-Dcm_Connection_Form_JNDI_Collapse-Attributes= 收起 \ No newline at end of file diff --git a/private/i18n.ts b/private/i18n.ts index 3f234ea..a5bc85b 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -54,4 +54,10 @@ export default { 'Dec-Dcm_Connection_Form_Database_Port': '端口号', 'Dec-Dcm_Connection_Make_Sure_Delete': '确定删除该数据连接?', 'Dec-Dcm_Connection_ReConnect': '重新连接', + 'Dec-Dcm_Connection_JNDI_Form_ConnectionName': 'JNDI的名字', + 'Dec-Dcm_Connection_Form_JNDI_Context': '上下文', + 'Dec-Dcm_Connection_Form_JNDI_Advanced': '高级', + 'Dec-Dcm_Connection_Form_JNDI_Other_Attributes': '其他属性', + 'Dec-Dcm_Connection_Form_JNDI_Collapse-Attributes': '收起', + 'Dec-Dcm_Connection_Form_JNDI_Notice': '注意:需要把包含INITIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下.', }; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2a42856..c0806e2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -4,9 +4,9 @@ import appModel from './app.model'; import title from './title/title.component'; import linkSet from './link_set/link-set.component'; import linkStatus from './link_status/link_status.component'; -import '../demo/plugin.redis.edit'; -import '../demo/plugin.redis.preview'; -import '../demo/plugin.tedis.pool'; +import '../plugins/jndi/jndi.edit'; +import '../plugins/jndi/jndi.pool'; +import '../plugins/jndi/jndi.preview'; import {fetchLinkList} from '../shared/crud/crud.request'; import './app.component.scss'; diff --git a/src/plugins/jndi/jdni.scss b/src/plugins/jndi/jdni.scss new file mode 100644 index 0000000..a3294bb --- /dev/null +++ b/src/plugins/jndi/jdni.scss @@ -0,0 +1,3 @@ +.jndi-notice{ + color: red; +} \ No newline at end of file diff --git a/src/plugins/jndi/jdni.typing.d.ts b/src/plugins/jndi/jdni.typing.d.ts new file mode 100644 index 0000000..060bd1a --- /dev/null +++ b/src/plugins/jndi/jdni.typing.d.ts @@ -0,0 +1,25 @@ +export interface AttributeType { + text: string; + name: string; +} + +export interface FormType { + connectionName?: string; + factory?: string; + url?: string; + principal?: string; + credentials?: string; + originalCharsetName?: string; + + objectFactories?: string; + stateFactories?: string; + urlPkgPrefixes?: string; + dnsUrl?: string; + authoritative?: string; + batchSize?: string; + referral?: string; + securityProtocol?: string; + securityAuthentication?: string; + language?: string; + applet?: string; +} diff --git a/src/plugins/jndi/jndi.edit.ts b/src/plugins/jndi/jndi.edit.ts new file mode 100644 index 0000000..2dcc7d3 --- /dev/null +++ b/src/plugins/jndi/jndi.edit.ts @@ -0,0 +1,187 @@ +import {Vertical, Editor, TextValueCombo, TextButton, Label} from '@ui'; +import {factorys, otherAttributes, originalCharsetNames} from './jndi.service'; +import FormItem from '@shared/components/form.item.component'; +import {AttributeType, FormType} from './jdni.typing'; +import './jdni.scss'; +const RedisConstantName = 'dec.constant.database.conf.connect.form.jndi.value'; +const form: FormType = { + url: '192.168.1.22', +}; + +const classNameEdit = 'dec.plugin.jndi.edit'; +const Widget = BI.inherit(BI.Widget, { + render() { + return { + type: Vertical, + cls: 'right-show', + items: [ + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_JNDI_Form_ConnectionName'), + form: { + type: Editor, + cls: 'bi-border', + width: 300, + allowBlank: true, + value: form.connectionName, + }, + }, + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Context'), + height: 160, + ref: _ref => { + this.JndiForm = _ref; + }, + form: { + type: Vertical, + cls: 'right-form', + items: [ + { + type: FormItem, + text: 'INTIAL_CONTEXT_FACTORY', + width: 180, + form: { + type: TextValueCombo, + cls: 'bi-border', + width: 300, + value: form.factory, + items: BI.map(factorys, (index: number, item: string) => { + return { + text: item, + value: item, + }; + }), + }, + }, + { + type: FormItem, + text: 'PROVIDER_URL', + width: 180, + form: { + type: Editor, + cls: 'bi-border', + width: 300, + allowBlank: true, + value: form.url, + }, + }, + { + type: FormItem, + text: 'SECURITY_PRINCIPAL', + width: 180, + form: { + type: Editor, + cls: 'bi-border', + width: 300, + allowBlank: true, + value: form.principal, + }, + }, + { + type: FormItem, + text: 'SECURITY_CREDENTIALS', + width: 180, + form: { + type: Editor, + cls: 'bi-border', + width: 300, + allowBlank: true, + value: form.credentials, + }, + }, + { + type: FormItem, + width: 180, + form: { + type: TextButton, + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Other_Attributes'), + width: 300, + textAlign: 'right', + value: true, + ref: _ref => { + this.Collapse = _ref; + }, + handler: () => { + const isCollapse = this.Collapse.getValue(); + const height = isCollapse ? 550 : 160; + const text = isCollapse ? BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Collapse-Attributes') : BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Other_Attributes'); + this.JndiForm.setHeight(height); + this.Collapse.setValue(!isCollapse); + this.Collapse.setText(text); + this.OtherAttributes.setVisible(isCollapse); + }, + }, + }, + { + type: Vertical, + cls: 'right-form', + invisible: false, + ref: _ref => { + this.OtherAttributes = _ref; + }, + items: BI.map(otherAttributes, (index: number, item: AttributeType) => { + return { + type: FormItem, + text: item.text, + width: 180, + form: { + type: Editor, + cls: 'bi-border', + width: 300, + allowBlank: true, + value: form[item.name], + }, + }; + }), + }, + ], + }, + }, + { + type: FormItem, + text: '', + height: 25, + form: { + type: Label, + cls: 'jndi-notice', + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Notice'), + }, + }, + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Advanced'), + height: 25, + form: { + type: Vertical, + cls: 'right-form', + items: [ + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), + width: 180, + form: { + type: TextValueCombo, + cls: 'bi-border', + width: 300, + items: [{ + text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'), + value: form.originalCharsetName, + }, + ...originalCharsetNames, + ], + }, + }, + ], + }, + }, + ], + }; + }, +}); +BI.shortcut(classNameEdit, Widget); +export default classNameEdit; +export const ConstantName = 'dec.constant.database.conf.connect.list'; +BI.config(ConstantName, (datas: string[]) => [...datas, 'JNDI']); +BI.constant(RedisConstantName, form); +BI.constant('dec.constant.database.conf.connect.form.jndi.edit', classNameEdit); diff --git a/src/plugins/jndi/jndi.pool.ts b/src/plugins/jndi/jndi.pool.ts new file mode 100644 index 0000000..ba12135 --- /dev/null +++ b/src/plugins/jndi/jndi.pool.ts @@ -0,0 +1,54 @@ +const JndiPool = 'fr.plugin.jndi.pool'; + +const JndiWidget = BI.inherit(BI.Widget, { + render() { + const {maxActive, numActive} = this.options; + + return { + type: 'bi.left', + items: [ + { + type: 'bi.left', + cls: 'right-status-item', + items: [ + { + type: 'bi.vertical', + cls: 'right-status-board', + items: [ + { + type: 'bi.vertical', + cls: 'right-status-board-item', + items: [ + { + type: 'bi.label', + cls: 'right-status-text', + extraCls: 'card-font1', + text: numActive, + }, + { + type: 'bi.label', + cls: 'right-status-text', + text: '/', + }, + { + type: 'bi.label', + cls: 'right-status-text', + text: maxActive, + }, + ], + }, + { + type: 'bi.label', + height: 20, + text: BI.i18nText('Dec-Dcm_Active_Connections_Number'), + }, + ], + }, + ], + }, + ], + }; + }, +}); +BI.shortcut(JndiPool, JndiWidget); +BI.constant('dec.constant.database.conf.connect.form.jndi.pool', JndiPool); diff --git a/src/plugins/jndi/jndi.preview.ts b/src/plugins/jndi/jndi.preview.ts new file mode 100644 index 0000000..31f2ccc --- /dev/null +++ b/src/plugins/jndi/jndi.preview.ts @@ -0,0 +1,139 @@ +import {Vertical, Label, TextButton} from '@ui'; +import FormItem from '@shared/components/form.item.component'; +import {FormType, AttributeType} from './jdni.typing'; +import {otherAttributes} from './jndi.service'; + +const JndiPreview = 'fr.plugin.jndi.preview'; +const JndiConstantName = 'dec.constant.database.conf.connect.form.jndi.value'; +const jndiForm: FormType = BI.Constants.getConstant(JndiConstantName); + +const jndiWidget = BI.inherit(BI.Widget, { + render() { + return { + type: Vertical, + cls: 'right-show', + items: [ + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_JNDI_Form_ConnectionName'), + form: { + type: Label, + text: jndiForm.connectionName, + }, + }, + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Context'), + height: 160, + ref: _ref => { + this.JndiForm = _ref; + }, + form: { + type: Vertical, + cls: 'right-form', + items: [ + { + type: FormItem, + text: 'INTIAL_CONTEXT_FACTORY', + width: 180, + form: { + type: Label, + text: jndiForm.factory, + }, + }, + { + type: FormItem, + text: 'PROVIDER_URL', + width: 180, + form: { + type: Label, + text: jndiForm.url, + }, + }, + { + type: FormItem, + text: 'SECURITY_PRINCIPAL', + width: 180, + form: { + type: Label, + text: jndiForm.principal, + }, + }, + { + type: FormItem, + text: 'SECURITY_CREDENTIALS', + width: 180, + form: { + type: Label, + text: jndiForm.credentials, + }, + }, + { + type: FormItem, + width: 180, + form: { + type: TextButton, + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Other_Attributes'), + width: 300, + textAlign: 'right', + value: true, + ref: _ref => { + this.Collapse = _ref; + }, + handler: () => { + const isCollapse = this.Collapse.getValue(); + const height = isCollapse ? 550 : 160; + const text = isCollapse ? BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Collapse-Attributes') : BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Other_Attributes'); + this.JndiForm.setHeight(height); + this.Collapse.setValue(!isCollapse); + this.Collapse.setText(text); + this.OtherAttributes.setVisible(isCollapse); + }, + }, + }, + { + type: Vertical, + cls: 'right-form', + invisible: false, + ref: _ref => { + this.OtherAttributes = _ref; + }, + items: BI.map(otherAttributes, (index: number, item: AttributeType) => { + return { + type: FormItem, + text: item.text, + width: 180, + form: { + type: Label, + text: jndiForm[item.name], + }, + }; + }), + }, + ], + }, + }, + { + type: FormItem, + text: '', + height: 25, + form: { + type: Label, + cls: 'jndi-notice', + text: BI.i18nText('Dec-Dcm_Connection_Form_JNDI_Notice'), + }, + }, + { + type: FormItem, + text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), + form: { + type: Label, + text: jndiForm.originalCharsetName ? jndiForm.originalCharsetName : BI.i18nText('Dec-Dcm_Connection_Form_Auto'), + }, + }, + ], + }; + }, +}); +BI.shortcut(JndiPreview, jndiWidget); +BI.constant('dec.constant.database.conf.connect.form.jndi.preview', JndiPreview); diff --git a/src/plugins/jndi/jndi.service.ts b/src/plugins/jndi/jndi.service.ts new file mode 100644 index 0000000..381e827 --- /dev/null +++ b/src/plugins/jndi/jndi.service.ts @@ -0,0 +1,87 @@ +import {AttributeType} from './jdni.typing'; + +export const factorys = ['', 'weblogic.jndi.WLInitialContextFactory', 'com.ibm.websphere.naming.WsnInitialContextFactory', 'org.jboss.naming.HttpNamingContextFactory', 'org.jnp.interfaces.NamingContextFactory', 'com.caucho.burlap.BurlapContextFactory']; + +export const otherAttributes: AttributeType[] = [ + { + text: 'OBJECT_FACTORIES', + name: 'objectFactories', + }, + { + text: 'STATE_FACTORIES', + name: 'stateFactories', + }, + { + text: 'URL_PKG_PREFIXES', + name: 'urlPkgPrefixes', + }, + { + text: 'DNS_URL', + name: 'dnsUrl', + }, + { + text: 'AUTHORITATIVE', + name: 'authoritative', + }, + { + text: 'BATCHSIZE', + name: 'batchSize', + }, + { + text: 'REFERRAL', + name: 'referral', + }, + { + text: 'SECURITY_PROTOCOL', + name: 'securityProtocol', + }, + { + text: 'SECURITY_AUTHENTICATION', + name: 'securityAuthentication', + }, + { + text: 'LANGUAGE', + name: 'language', + }, + { + text: 'APPLET', + name: 'applet', + }, +]; + + +export const originalCharsetNames = [ + { + text: 'GBK', + value: 'GBK', + }, + { + text: 'BIG5', + value: 'BIG5', + }, + { + text: 'ISO-8859-1', + value: 'ISO-8859-1', + }, + { + text: 'UTF-8', + value: 'UTF-8', + }, + { + text: 'UTF-16', + value: 'UTF-16', + }, + { + text: 'EUC_JP', + value: 'EUC_JP', + }, + { + text: 'EUC_KR', + value: 'EUC_KR', + }, + { + text: 'CP850', + value: 'CP850', + }, +] +; diff --git a/src/shared/components/form.item.component.ts b/src/shared/components/form.item.component.ts index bc88f74..b15f3db 100644 --- a/src/shared/components/form.item.component.ts +++ b/src/shared/components/form.item.component.ts @@ -2,12 +2,12 @@ import {WidgetType, Htape, Label} from '@ui/index'; const className = 'fr.shared.component.form.item'; const Widget: WidgetType = { render() { - const {text, form, hint, height} = this.options; + const {text, form, hint, height, width = 115} = this.options; return { type: Htape, cls: 'both-side', - height:height ? height : 24, + height: height ? height : 24, items: [{ el: { type: Label, @@ -15,7 +15,7 @@ const Widget: WidgetType = { textAlign: 'left', text, }, - width: 115, + width, }, form, { type: Label, cls: 'hint',