diff --git a/assets/scripts/dec.js b/assets/scripts/dec.js index a9a806e..7e9ad92 100644 --- a/assets/scripts/dec.js +++ b/assets/scripts/dec.js @@ -3,6 +3,9 @@ window.DecCst = { CONNECTION_DELETED: '21300035', CONNECTION_UNDER_EDIT: '21300034', DUPLICATE_NAMES: '21300005', + LOGIN_INFO_NOT_AVAILABLE: '21300014', + LOGIN_INFO_ERROR: '21300018', + TIMEOUT: '21300001', }, Connect: { ConnectionType: { diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 1f0edee..4154eed 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -111,6 +111,7 @@ Dec-Dcm_Connection_Click_Connect_Database=点击连接数据库 Dec-Dcm_Connection_Read_Mode_List=以读取模式列表 Dec-Dcm_Connection_NO_Connection_Pool=无数据连接,可在数据连接管理页面添加 Dec-Dcm_Connection_Cannot_Too_Lang=文本长度不能大于200个字符 +Dec-Dcm_Login_Error=登录信息已失效,请重新登录 BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_YMD= 年月日 diff --git a/index.html b/index.html index 6bac9ec..cfb9c39 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
- + diff --git a/package.json b/package.json index 764e348..fe532bf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@babel/core": "7.4.5", "@babel/plugin-proposal-class-properties": "^7.5.0", "@babel/plugin-proposal-decorators": "7.4.4", - "@babel/polyfill": "7.4.4", "@babel/preset-env": "7.4.5", "@babel/preset-typescript": "7.3.3", "@types/jest": "24.0.11", diff --git a/private/i18n.ts b/private/i18n.ts index 1fdf08b..77be638 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -110,6 +110,7 @@ export default { 'Dec-Dcm_Connection_Read_Mode_List': '以读取模式列表', 'Dec-Dcm_Connection_NO_Connection_Pool': '无数据连接,可在数据连接管理页面添加', 'Dec-Dcm_Connection_Cannot_Too_Lang': '文本长度不能大于200个字符', + 'Dec-Dcm_Login_Error': '登录信息已失效,请重新登录', 'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_YMD': '年月日', diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index a770f78..9139f32 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -26,11 +26,14 @@ export function getPluginWidgetEdit(plugin: string) { // 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型 export function getJdbcDatabaseType(database: string, driver: string): DatabaseType { let databaseType = null; - if (database && DATA_BASE_TYPES.some(item => item.databaseType === database)) { + // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 + if (database && database !== 'other' && DATA_BASE_TYPES.some(item => item.databaseType === database)) { databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); } else { - const desingDatabase = DESIGN_DRIVER_TYPE.find(item => item.driver === driver); - databaseType = DATA_BASE_TYPES.find(item => item.databaseType === BI.get(desingDatabase, 'type')); + const designDatabase = DESIGN_DRIVER_TYPE.find(item => item.driver === driver); + const decisionDatabase = DATA_BASE_TYPES.find(item => item.driver === driver); + const type = designDatabase ? BI.get(designDatabase, 'type') : BI.get(decisionDatabase, 'databaseType'); + databaseType = DATA_BASE_TYPES.find(item => item.databaseType === type); } if (!databaseType) { return DATA_BASE_TYPES_OTHER; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index df50774..20f0200 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -678,8 +678,9 @@ export const DEFAULT_JDBC_POOL = { }; export const CONNECTION_LAYOUT = { - hgap: 15, + hgap: 5, vgap: 15, + labelHeight: 24, }; diff --git a/src/modules/constants/env.ts b/src/modules/constants/env.ts index 3ddd37c..3030fbb 100644 --- a/src/modules/constants/env.ts +++ b/src/modules/constants/env.ts @@ -3,12 +3,21 @@ export const ReqPrefix = `${fineServletURL}/v10/config/connection`; export const ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`; export const PluginImgPrefix = `${fineServletURL}/resources?path=`; -export const connectionType = DecCst.Connect.ConnectionType; +export const connectionType: { + JDBC: string; + JNDI: string; +} = DecCst.Connect.ConnectionType; -export const editStatusEvent = DecCst.Connect.EditStatusEvent; +export const editStatusEvent: { + OPEN: string; + SHUTDOWN: string; +} = DecCst.Connect.EditStatusEvent; export const errorCode: { CONNECTION_DELETED: string; CONNECTION_UNDER_EDIT: string; DUPLICATE_NAMES: string; + LOGIN_INFO_NOT_AVAILABLE: string; + LOGIN_INFO_ERROR: string; + TIMEOUT: string; } = DecCst.ErrorCode; diff --git a/src/modules/crud/crud.service.ts b/src/modules/crud/crud.service.ts index c67636e..483b918 100644 --- a/src/modules/crud/crud.service.ts +++ b/src/modules/crud/crud.service.ts @@ -1,7 +1,7 @@ import 'es6-promise/auto'; import axios, { AxiosResponse, AxiosError } from 'axios'; import { CrudReqOpts, CrudParams, ResultType } from './crud.typings.d'; -import { ReqPrefix } from '../constants/env'; +import { ReqPrefix, errorCode } from '../constants/env'; const defaultHeaders = { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', @@ -15,7 +15,7 @@ export function paramsSerializer(params: { [key: string]: any }) { let value = ''; if (BI.isObject(paramValue)) { - value = BI.encodeURIComponent(JSON.stringify(paramValue)); + value = encodeURIComponent(JSON.stringify(paramValue)); } else { value = paramValue; } @@ -39,6 +39,26 @@ function getCookieByName(name: string):string { return value; } +function checkStatus(response: AxiosResponse) { + const status = response.status; + const noLoginErr = [errorCode.LOGIN_INFO_ERROR, errorCode.LOGIN_INFO_NOT_AVAILABLE, errorCode.TIMEOUT]; + + const resData = status === 200 + ? typeof response.data === 'string' + ? BI.jsonDecode(response.data) + : response.data + : {}; + if (noLoginErr.includes(BI.get(resData, 'errorCode'))) { + BI.Msg.alert(BI.i18nText('BI-Basic_Prompt'), BI.i18nText('Dec-Dcm_Login_Error'), () => { + window.location.reload(true); + }); + + return new Promise(() => {}); + } + + return resData; +} + export async function request(reqOptions: CrudReqOpts = {}): Promise { const { url, type, headers, data, params } = reqOptions; @@ -57,15 +77,7 @@ export async function request(reqOptions: CrudReqOpts = {}): Promise paramsSerializer, data, }) - .then((response: AxiosResponse) => { - const status = response.status; - - return status === 200 - ? typeof response.data === 'string' - ? BI.jsonDecode(response.data) - : response.data - : {}; - }) + .then(checkStatus) .catch((error: AxiosError) => { console.log(error); }); diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index 23223be..55096b1 100644 --- a/src/modules/crud/decision.api.ts +++ b/src/modules/crud/decision.api.ts @@ -45,7 +45,7 @@ export class DecisionApi implements Api { } getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}> { - return requestGet(`pool/info?connectionName=${BI.encodeURIComponent(name)}`, {}); + return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {}); } getConnectionStatus(name: string): Promise { diff --git a/src/modules/pages/connection/components/form_item/form_item.ts b/src/modules/pages/connection/components/form_item/form_item.ts index 24dacd8..723ecaa 100644 --- a/src/modules/pages/connection/components/form_item/form_item.ts +++ b/src/modules/pages/connection/components/form_item/form_item.ts @@ -7,6 +7,7 @@ export class FormItem extends BI.Widget { name: '', value: '', unit: '', + isBold: true, nameWidth: 140, } @@ -20,7 +21,7 @@ export class FormItem extends BI.Widget { { el: { type: Label, - cls: 'bi-font-bold', + cls: this.options.isBold ? 'bi-font-bold' : '', textAlign: 'left', text: this.options.name, }, diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 6714de9..b7bab2b 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -49,17 +49,18 @@ export class Connection extends BI.Widget { return { type: Htape, + hgap: 10, items: [ { el: { type: Vtape, cls: 'bi-border-right', + rgap: 10, items: [ { el: { type: VerticalAdapt, cls: 'bi-border-bottom', - lgap: 10, items: [{ type: Button, text: BI.i18nText('Dec-Dcm_Connection_New'), @@ -72,7 +73,7 @@ export class Connection extends BI.Widget { }, { type: ConnectionListXtype, - tgap: 5, + tgap: 10, }, ], }, @@ -91,7 +92,6 @@ export class Connection extends BI.Widget { items: [ { type: Label, - lgap: 5, textAlign: 'left', ref: (_ref: any) => { this.connectionTitleWidget = _ref; @@ -102,7 +102,6 @@ export class Connection extends BI.Widget { type: VerticalAdapt, items: [{ type: Button, - level: 'ignore', invisible: true, text: BI.i18nText('Dec-Dcm_Edit'), ref: (_ref: any) => { @@ -125,7 +124,6 @@ export class Connection extends BI.Widget { }, { type: ListView, - vgap: 15, ref: (_ref: any) => { this.listView = _ref; }, diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 1c1c9af..627438d 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -96,6 +96,7 @@ export class ConnectionJdbc extends BI.Widget { }, { type: Vertical, + tgap: -15, vgap, invisible: true, ref: (_ref: any) => { diff --git a/src/modules/pages/connection/connection_jndi/connection_jndi.ts b/src/modules/pages/connection/connection_jndi/connection_jndi.ts index db04856..db99250 100644 --- a/src/modules/pages/connection/connection_jndi/connection_jndi.ts +++ b/src/modules/pages/connection/connection_jndi/connection_jndi.ts @@ -32,7 +32,7 @@ export class ConnectionJdbc extends BI.Widget { }, { type: Htape, - height: 120, + height: 115, items: [ { el: { @@ -50,31 +50,37 @@ export class ConnectionJdbc extends BI.Widget { }, { type: Vertical, - bgap: 10, + bgap: 15, + height: 115, items: [ { type: FormItemXtype, name: 'INTIAL_CONTEXT_FACTORY', nameWidth: 200, + isBold: false, value: contextHashtable['java.naming.factory.initial'], }, { type: FormItemXtype, name: 'PROVIDER_URL', nameWidth: 200, + isBold: false, value: contextHashtable['java.naming.provider.url'], }, { type: FormItemXtype, name: 'SECURITY_PRINCIPAL', nameWidth: 200, + isBold: false, value: contextHashtable['java.naming.security.principal'], }, { type: FormItemXtype, name: 'SECURITY_CREDENTIALS', nameWidth: 200, + isBold: false, value: contextHashtable['java.naming.security.credentials'], + bgap: -15, }, ], }, @@ -102,6 +108,7 @@ export class ConnectionJdbc extends BI.Widget { { type: Vertical, vgap, + tgap: -15, invisible: true, ref: (_ref: any) => { this.advancedSet = _ref; diff --git a/src/modules/pages/connection/list/list_item/list_item.ts b/src/modules/pages/connection/list/list_item/list_item.ts index cc1c054..be73a60 100644 --- a/src/modules/pages/connection/list/list_item/list_item.ts +++ b/src/modules/pages/connection/list/list_item/list_item.ts @@ -1,5 +1,5 @@ import { shortcut, store } from '@core/core'; -import { Label, LeftRightVerticalAdapt, IconLabel, IconButton, DownListCombo, SignEditor, Layout } from 'ui'; +import { Label, IconLabel, IconButton, DownListCombo, SignEditor, Layout, Htape, Vertical } from 'ui'; import './list_item.less'; import { ListItemModel, ListItemModelXtype } from './list_item.model'; import { PAGE_INDEX } from '@constants/constant'; @@ -41,20 +41,23 @@ export class ListItem extends BI.BasicButton { const { name, databaseType } = this.options; return { - type: LeftRightVerticalAdapt, - items: { - left: [ - { - type: IconLabel, - cls: 'dcm-link-font icon-size-16', - width: 25, - title: name, - }, + type: Htape, + items: [{ + el: { + type: IconLabel, + cls: 'dcm-link-font icon-size-16', + title: name, + }, + width: 25, + }, { + type: Vertical, + items: [ { type: Label, text: name, - width: 200, textAlign: 'left', + height: 25, + title: name, ref: (_ref: any) => { this.nameLabel = _ref; }, @@ -62,7 +65,6 @@ export class ListItem extends BI.BasicButton { { type: SignEditor, value: name, - width: 200, invisible: !this.model.isEdit, ref: (_ref: any) => { this.nameEditor = _ref; @@ -97,37 +99,37 @@ export class ListItem extends BI.BasicButton { }], }, ], - right: [ - databaseType ? { - type: DownListCombo, - cls: 'link-item-icon', - stopPropagation: true, - hgap: 8, - el: { - type: IconButton, - cls: 'dcm-link-other-font icon-size-16', + }, { + el: databaseType ? { + type: DownListCombo, + cls: 'link-item-icon', + stopPropagation: true, + hgap: 8, + el: { + type: IconButton, + cls: 'dcm-link-other-font icon-size-16', + }, + items: this.renderDownList(), + ref: (_ref: any) => { + this.downListCombo = _ref; + }, + listeners: [{ + eventName: BI.DownListCombo.EVENT_CHANGE, + action: (value: string) => { + this.itemActionCalculate().actionClac(value); }, - items: this.renderDownList(), - ref: (_ref: any) => { - this.downListCombo = _ref; + }, { + eventName: BI.DownListCombo.EVENT_BEFORE_POPUPVIEW, + action: () => { + this.downListCombo.setValue(''); }, - listeners: [{ - eventName: BI.DownListCombo.EVENT_CHANGE, - action: (value: string) => { - this.itemActionCalculate().actionClac(value); - }, - }, { - eventName: BI.DownListCombo.EVENT_BEFORE_POPUPVIEW, - action: () => { - this.downListCombo.setValue(''); - }, - }], - - } : { - type: Layout, - }, - ], - }, + }], + + } : { + type: Layout, + }, + width: 25, + }], }; } diff --git a/src/modules/pages/connection_pool/list_item/list_item.ts b/src/modules/pages/connection_pool/list_item/list_item.ts index baf8d3c..814255e 100644 --- a/src/modules/pages/connection_pool/list_item/list_item.ts +++ b/src/modules/pages/connection_pool/list_item/list_item.ts @@ -21,6 +21,7 @@ export class ListItem extends BI.BasicButton { { type: Label, text: this.options.name, + title: this.options.name, width: 250, textAlign: 'left', }, diff --git a/src/modules/pages/maintain/components/form_item/form_item.ts b/src/modules/pages/maintain/components/form_item/form_item.ts index 6635e56..159332d 100644 --- a/src/modules/pages/maintain/components/form_item/form_item.ts +++ b/src/modules/pages/maintain/components/form_item/form_item.ts @@ -1,5 +1,6 @@ import { shortcut } from '@core/core'; import { Label, Left } from 'ui'; +import { CONNECTION_LAYOUT } from '@constants/constant'; export const FormItemXtype = 'dec.dcm.Maintain_form_item'; @shortcut(FormItemXtype) export class FormItem extends BI.Widget { @@ -7,6 +8,7 @@ export class FormItem extends BI.Widget { name: '', forms: '', nameWidth: 140, + isBold: true, } render () { @@ -15,9 +17,10 @@ export class FormItem extends BI.Widget { items: [ { type: Label, - cls: 'bi-font-bold', + cls: this.options.isBold ? 'bi-font-bold' : '', width: this.options.nameWidth, textAlign: 'left', + height: CONNECTION_LAYOUT.labelHeight, text: this.options.name, }, ...this.options.forms, diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 9aed141..637e1bd 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -1,5 +1,5 @@ import { shortcut } from '@core/core'; -import { Vertical, TextEditor, TextValueCombo, Label, TextAreaEditor, Editor, EdirotIconCheckCombo, Left, TextButton } from 'ui'; +import { Vertical, TextEditor, TextValueCombo, Label, TextAreaEditor, Editor, EdirotIconCheckCombo, Left, TextButton, Layout } from 'ui'; import { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/collapse'; import { FormItemXtype } from '../../components/form_item/form_item'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; @@ -237,7 +237,7 @@ export class FormJdbc extends BI.Widget { }, forms: [{ type: Editor, - cls: 'bi-border', + cls: 'bi-border bi-border-radius', width: 300, height: 20, allowBlank: true, @@ -313,6 +313,7 @@ export class FormJdbc extends BI.Widget { { type: FormItemXtype, invisible: !databaseType.hasSchema, + height: 64, name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'), forms: [{ type: Vertical, @@ -344,6 +345,11 @@ export class FormJdbc extends BI.Widget { }], }], }, + { + type: Layout, + cls: 'bi-border-top', + bgap: 8, + }, { type: FormItemXtype, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_URL'), @@ -383,6 +389,7 @@ export class FormJdbc extends BI.Widget { { type: Vertical, vgap, + tgap: -15, invisible: true, ref: (_ref: any) => { this.advancedSet = _ref; @@ -394,7 +401,7 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: initialSize, validationChecker: [{ errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'), @@ -413,7 +420,7 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: maxActive, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Active'), validationChecker: [{ @@ -432,7 +439,7 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: maxIdle, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'), validationChecker: [{ @@ -451,7 +458,7 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: minIdle, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'), validationChecker: [{ @@ -471,7 +478,7 @@ export class FormJdbc extends BI.Widget { { type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: maxWait, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'), validationChecker: [{ @@ -486,6 +493,7 @@ export class FormJdbc extends BI.Widget { { type: Label, lgap: 5, + height: CONNECTION_LAYOUT.labelHeight, text: BI.i18nText('Dec-Dcm_Millisecond'), }, ], @@ -558,7 +566,7 @@ export class FormJdbc extends BI.Widget { { type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: timeBetweenEvictionRunsMillis, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Test_Between_Eviction_Millis'), validationChecker: [{ @@ -573,6 +581,7 @@ export class FormJdbc extends BI.Widget { { type: Label, lgap: 5, + height: CONNECTION_LAYOUT.labelHeight, text: BI.i18nText('Dec-Dcm_Millisecond'), }, ], @@ -583,7 +592,7 @@ export class FormJdbc extends BI.Widget { forms: [{ type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: numTestsPerEvictionRun, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Tests_PerEviction_Run_Num'), validationChecker: [{ @@ -603,7 +612,7 @@ export class FormJdbc extends BI.Widget { { type: TextCheckerXtype, width: 300, - allowBlank: true, + allowBlank: false, value: minEvictableIdleTimeMillis, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Evictable_Idle_Time_Millis'), validationChecker: [{ @@ -618,6 +627,7 @@ export class FormJdbc extends BI.Widget { { type: Label, lgap: 5, + height: CONNECTION_LAYOUT.labelHeight, text: BI.i18nText('BI-Basic_Seconds'), }, ], diff --git a/src/modules/pages/maintain/forms/components/form.jndi.ts b/src/modules/pages/maintain/forms/components/form.jndi.ts index 5be5737..360e3bb 100644 --- a/src/modules/pages/maintain/forms/components/form.jndi.ts +++ b/src/modules/pages/maintain/forms/components/form.jndi.ts @@ -74,7 +74,7 @@ export class FormJndi extends BI.Widget { }, { type: Htape, - height: 180, + height: 175, items: [ { el: { @@ -92,12 +92,14 @@ export class FormJndi extends BI.Widget { }, { type: Vertical, - bgap: 10, + bgap: 15, + height: 175, items: [ { type: FormItemXtype, name: 'INTIAL_CONTEXT_FACTORY', nameWidth: 200, + isBold: false, forms: [{ type: EdirotIconCheckCombo, width: 300, @@ -124,6 +126,7 @@ export class FormJndi extends BI.Widget { { type: FormItemXtype, name: 'PROVIDER_URL', + isBold: false, nameWidth: 200, forms: [{ type: TextEditor, @@ -138,6 +141,7 @@ export class FormJndi extends BI.Widget { { type: FormItemXtype, name: 'SECURITY_PRINCIPAL', + isBold: false, nameWidth: 200, forms: [{ type: TextEditor, @@ -152,6 +156,7 @@ export class FormJndi extends BI.Widget { { type: FormItemXtype, name: 'SECURITY_CREDENTIALS', + isBold: false, nameWidth: 200, forms: [{ type: TextEditor, @@ -165,6 +170,7 @@ export class FormJndi extends BI.Widget { }, { type: Label, + bgap: -15, cls: 'bi-tips', textAlign: 'left', text: BI.i18nText('Dec-Dcm_Connection_JNDI_Warning'), @@ -203,6 +209,7 @@ export class FormJndi extends BI.Widget { { type: Vertical, vgap, + tgap: -15, invisible: true, ref: (_ref: any) => { this.advancedSet = _ref; diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 3214c1e..34fa0f2 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -31,6 +31,8 @@ export class MaintainForm extends BI.Widget { if (this.connectionName && !this.model.isCopy) { const value = this.form.getSubmitValue(); (value.connectionData as ConnectionJDBC).creator = BI.get(this.getFormData(), 'creator'); + // DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段 + value.creator = BI.get(this.getFormData(), 'creator'); this.store.updateConnection(this.connectionName, value).then(result => { if (result.errorCode) { this.showError(result); @@ -42,15 +44,9 @@ export class MaintainForm extends BI.Widget { } else { const form = this.form.getSubmitValue(); form.connectionId = this.connectionName; - this.store.addConnection(form).then(result => { - if (result.errorCode) { - this.showError(result); - - return; - } - this.store.goFirstPage(); - this.store.setIsCopy(false); - }); + // DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段 + form.creator = Dec ? Dec.personal.username : ''; + this.addConnection(form); } }, testEvent: () => { @@ -214,19 +210,7 @@ export class MaintainForm extends BI.Widget { } private getConnectionName(name = BI.i18nText('Dec-Dcm_Data_Connections')) { - const connections = this.model.connections.filter(item => item.connectionName.startsWith(name)); - if (connections.length === 0) { - return name; - } - let index = 0; - connections.forEach(item => { - const num = parseFloat(item.connectionName.replace(name, '')); - if (num > index) { - index = num; - } - }); - - return `${name}${index + 1}`; + return BI.Func.createDistinctName(this.model.connections.map(item => item.connectionName), name); } private testConnection() { @@ -248,4 +232,32 @@ export class MaintainForm extends BI.Widget { this.form.setSchemas(re); }); } + + private addConnection(form: Connection) { + this.store.addConnection(form).then(result => { + if (result.errorCode) { + if (result.errorCode === errorCode.DUPLICATE_NAMES) { + if (form.connectionType !== connectionType.JDBC && form.connectionType !== connectionType.JNDI) { + // 如果不是jdbc或jndi,即如果是插件,名称重复的时候需要修改名字重新提交给后台 + const newName = `${form.connectionName}${Math.floor(Math.random() * 10)}`; + form.connectionName = newName; + if (!this.model.isCopy) { + form.connectionId = newName; + } + this.addConnection(form); + } else { + this.setFromError(BI.i18nText(result.errorMsg)); + } + } else { + BI.Msg.toast(BI.i18nText(result.errorMsg), { + level: 'error', + }); + } + + return; + } + this.store.goFirstPage(); + this.store.setIsCopy(false); + }); + } } diff --git a/src/modules/pages/maintain/maintain.ts b/src/modules/pages/maintain/maintain.ts index 526dd10..7f25441 100644 --- a/src/modules/pages/maintain/maintain.ts +++ b/src/modules/pages/maintain/maintain.ts @@ -25,17 +25,18 @@ export class Maintain extends BI.Widget { return { type: Vtape, - hgap: 10, - vgap: 10, + hgap: 5, items: [ { type: VerticalAdapt, cls: 'bi-border-bottom', + height: 40, + hgap: 5, items: [ { type: IconButton, - hgap: 5, cls: 'dcm-back-font', + height: 15, invisible: this.model.isCopy || isEdit, handler: () => { this.store.setPageIndex(PAGE_INDEX.DATEBASE); @@ -44,9 +45,9 @@ export class Maintain extends BI.Widget { { type: Label, text: titleText, + height: 15, }, ], - height: 40, }, { type: ListView, diff --git a/webpack/webpack.dev.js b/webpack/webpack.dev.js index ec5e10f..f7e3bd1 100644 --- a/webpack/webpack.dev.js +++ b/webpack/webpack.dev.js @@ -36,7 +36,7 @@ chokidar module.exports = merge(common, { devtool: 'eval-source-map', entry: { - show: ['@babel/polyfill', './src/i18n.ts', './src/index.ts'], + show: ['./src/i18n.ts', './src/index.ts'], }, output: { path: dirs.DEST, diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 0049917..d71dcd3 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -12,7 +12,7 @@ module.exports = merge.smart(common, { devtool: 'hidden-source-map', entry: { - show: ['@babel/polyfill', './src/modules/app.ts'], + show: ['./src/modules/app.ts'], }, output: { path: dirs.DEST,