From f466d42980d7f8b593ce0c089a4982be514ab61e Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Mon, 31 May 2021 17:13:40 +0800 Subject: [PATCH] =?UTF-8?q?DEC-18828=20feat:=20=E9=9A=94=E7=A6=BB=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81kerberos=E8=AE=A4=E8=AF=81=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=BA=A4=E4=BA=92connectionData=E4=B8=AD?= =?UTF-8?q?=E6=96=B0=E5=A2=9EuseJaas=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/crud/crud.typings.d.ts | 3 +- .../maintain/forms/components/form.jdbc.ts | 72 ++++++++++++++----- .../maintain/forms/components/form.jndi.ts | 32 +++++---- .../maintain/forms/components/form.plugin.ts | 12 ++-- 4 files changed, 77 insertions(+), 42 deletions(-) diff --git a/src/modules/crud/crud.typings.d.ts b/src/modules/crud/crud.typings.d.ts index 239180e..84181fe 100644 --- a/src/modules/crud/crud.typings.d.ts +++ b/src/modules/crud/crud.typings.d.ts @@ -1,4 +1,3 @@ - export interface CrudReqOpts { url?: string; type?: 'GET' | 'POST' | 'DELETE' | 'PUT'; @@ -83,7 +82,7 @@ export interface ConnectionJDBC { /** * 端口号 */ - port?: number|''; + port?: number | ''; /** * 主机名 */ diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index a527cd6..1684f5e 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -1,13 +1,22 @@ -import { shortcut } from '@core/core'; -import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; -import { FormItem } from '../../components/form_item/form_item'; -import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; -import { connectionType } from '@constants/env'; -import { CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE } from '@constants/constant'; -import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service'; -import { TextChecker } from '../../../../components/text_checker/text_checker'; -import { ApiFactory } from 'src/modules/crud/apiFactory'; -import { Editor, EditorIconCheckCombo, Label, TextAreaEditor, TextEditor, TextValueCombo, VerticalLayout } from '@fui/core'; +import {shortcut} from '@core/core'; +import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse'; +import {FormItem} from '../../components/form_item/form_item'; +import {Connection, ConnectionJDBC, ConnectionPoolJDBC} from 'src/modules/crud/crud.typings'; +import {connectionType} from '@constants/env'; +import {CONNECT_CHARSET, CONNECTION_LAYOUT, INT_MAX_VALUE, INT_MIN_VALUE} from '@constants/constant'; +import {getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl} from '../../../../app.service'; +import {TextChecker} from '../../../../components/text_checker/text_checker'; +import {ApiFactory} from 'src/modules/crud/apiFactory'; +import { + Editor, + EditorIconCheckCombo, + Label, + TextAreaEditor, + TextEditor, + TextValueCombo, + VerticalLayout +} from '@fui/core'; + const api = new ApiFactory().create(); @shortcut() @@ -57,13 +66,38 @@ export class FormJdbc extends BI.Widget { }; render() { - const { connectionName, connectionData } = this.options.formData; - const { driver, user, password, originalCharsetName, schema, url, connectionPoolAttr, database, authType, principal, keyPath } = connectionData as ConnectionJDBC; - const { initialSize, maxActive, maxIdle, maxWait, validationQuery, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minIdle, minEvictableIdleTimeMillis } = connectionPoolAttr as ConnectionPoolJDBC; + const {connectionName, connectionData} = this.options.formData; + const { + driver, + user, + password, + originalCharsetName, + schema, + url, + connectionPoolAttr, + database, + authType, + principal, + keyPath + } = connectionData as ConnectionJDBC; + const { + initialSize, + maxActive, + maxIdle, + maxWait, + validationQuery, + testOnBorrow, + testOnReturn, + testWhileIdle, + timeBetweenEvictionRunsMillis, + numTestsPerEvictionRun, + minIdle, + minEvictableIdleTimeMillis + } = connectionPoolAttr as ConnectionPoolJDBC; const databaseType = getJdbcDatabaseType(database, driver); this.oldPassword = password; - const { host, port, databaseName } = resolveUrlInfo(url, database); - const { hgap, vgap } = CONNECTION_LAYOUT; + const {host, port, databaseName} = resolveUrlInfo(url, database); + const {hgap, vgap} = CONNECTION_LAYOUT; const valueRangeConfig = { errorText: BI.i18nText('Dec-Dcm_Connection_Value_Out_Range'), @@ -360,7 +394,7 @@ export class FormJdbc extends BI.Widget { vgap: 15, disabled: true, value: schema, - items: schema ? [{ text: schema, value: schema }] : [], + items: schema ? [{text: schema, value: schema}] : [], ref: (_ref: TextValueCombo) => { this.form.schema = _ref; }, @@ -733,7 +767,7 @@ export class FormJdbc extends BI.Widget { } private onHostPortChange(databaseType) { - const { urls, url } = databaseType; + const {urls, url} = databaseType; const driver = this.form.driver.getValue(); const selectUrl = BI.get(urls, driver) || url; const host = this.form.host.getValue(); @@ -766,7 +800,7 @@ export class FormJdbc extends BI.Widget { connectionType: connectionType.JDBC, connectionId: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(), - connectionData: { + connectionData: BI.extend({}, connectionData, { database: connectionData.database, connectionName: this.form.connectionName.getValue(), driver: this.form.driver.getValue(), @@ -796,7 +830,7 @@ export class FormJdbc extends BI.Widget { numTestsPerEvictionRun: this.form.numTestsPerEvictionRun.getValue(), minEvictableIdleTimeMillis: this.form.minEvictableIdleTimeMillis.getValue(), }, - }, + }), }; } } diff --git a/src/modules/pages/maintain/forms/components/form.jndi.ts b/src/modules/pages/maintain/forms/components/form.jndi.ts index 7295a93..c3ff9c3 100644 --- a/src/modules/pages/maintain/forms/components/form.jndi.ts +++ b/src/modules/pages/maintain/forms/components/form.jndi.ts @@ -1,11 +1,11 @@ -import { shortcut } from '@core/core'; -import { FormItem } from '../../components/form_item/form_item'; -import { ConnectionJNDI, Connection, ContextHashtable } from 'src/modules/crud/crud.typings'; -import { CONNECT_CHARSET, CONNECTION_LAYOUT, JNDI_FACTORYS } from '@constants/constant'; -import { Collapse, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; -import { connectionType } from '@constants/env'; -import { TextChecker } from '../../../../components/text_checker/text_checker'; -import { EditorIconCheckCombo, TextEditor, TextValueCombo, VerticalLayout } from '@fui/core'; +import {shortcut} from '@core/core'; +import {FormItem} from '../../components/form_item/form_item'; +import {ConnectionJNDI, Connection, ContextHashtable} from 'src/modules/crud/crud.typings'; +import {CONNECT_CHARSET, CONNECTION_LAYOUT, JNDI_FACTORYS} from '@constants/constant'; +import {Collapse, EVENT_CHANGE} from 'src/modules/components/collapse/collapse'; +import {connectionType} from '@constants/env'; +import {TextChecker} from '../../../../components/text_checker/text_checker'; +import {EditorIconCheckCombo, TextEditor, TextValueCombo, VerticalLayout} from '@fui/core'; @shortcut() export class FormJndi extends BI.Widget { @@ -37,9 +37,9 @@ export class FormJndi extends BI.Widget { } render() { - const { connectionName, connectionData } = this.options.formData; - const { jndiName, newCharsetName, contextHashtable } = connectionData as ConnectionJNDI; - const { hgap, vgap } = CONNECTION_LAYOUT; + const {connectionName, connectionData} = this.options.formData; + const {jndiName, newCharsetName, contextHashtable} = connectionData as ConnectionJNDI; + const {hgap, vgap} = CONNECTION_LAYOUT; return { type: BI.VerticalLayout.xtype, @@ -399,7 +399,9 @@ export class FormJndi extends BI.Widget { this.form.connectionName.setError(value); } - public getSubmitValue():Connection { + public getSubmitValue(): Connection { + const connectionData = this.options.formData.connectionData as ConnectionJNDI; + const contextHashtable = { 'java.naming.factory.initial': this.form.initial.getValue(), 'java.naming.provider.url': this.form.providerUrl.getValue(), @@ -423,18 +425,18 @@ export class FormJndi extends BI.Widget { delete contextHashtable[propName]; } } - + return { connectionId: this.form.connectionName.getValue(), connectionName: this.form.connectionName.getValue(), connectionType: connectionType.JNDI, - connectionData: { + connectionData: BI.extend({}, connectionData, { jndiName: this.form.jndiName.getValue(), newCharsetName: this.form.newCharsetName.getValue()[0] || '', originalCharsetName: this.form.newCharsetName.getValue()[0] || '', creator: Dec ? Dec.personal.username : '', contextHashtable: contextHashtable as ContextHashtable, - }, + }), }; } } diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index 8fd8fc9..6282203 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/src/modules/pages/maintain/forms/components/form.plugin.ts @@ -1,13 +1,13 @@ -import {shortcut} from '@core/core'; -import {Connection} from 'src/modules/crud/crud.typings'; -import {getPluginWidgetEdit} from '../../../../app.service'; +import { shortcut } from '@core/core'; +import { Connection, ConnectionPlugin } from 'src/modules/crud/crud.typings'; +import { getPluginWidgetEdit } from '../../../../app.service'; @shortcut() export class FormPlugin extends BI.Widget { static xtype = 'dec.dcm.maintain_plugin'; props = { formData: {} as Connection, - } + }; plugin: any; @@ -28,13 +28,13 @@ export class FormPlugin extends BI.Widget { } public getSubmitValue(): Connection { - const { connectionType, connectionId, connectionName } = this.options.formData; + const { connectionType, connectionId, connectionName, connectionData } = this.options.formData; return { connectionId, connectionType, connectionName: this.plugin.getConnectionName ? this.plugin.getConnectionName() : connectionName, - connectionData: this.plugin.getValue(), + connectionData: BI.extend({}, connectionData, this.plugin.getValue()), }; } }