Browse Source

Merge pull request #121 in DEC/decision-webui-dcm from release/10.0 to feature/10.0

* commit '5528ebec423260dafb6088352dd87db4aeed6072':
  fix: DEC-10788 密码输入框也改为圆角
  fix: 去掉 bi-border-radius 改为在fineui中统一改
  fix: DEC-10788 根据视觉文档调整细节
  fix: update
  fix: 改成和bi同样的逻辑
  fix: BI-54743 修改数据连接自动命名的逻辑
  fix: 改成encodeURIComponent
  fix: DEC-10620 另一个地方也要改成encodeURI
  fix: 修改代理地址
  fix: 使用fineui.min.
  build: 去掉babel/polyfill
  fix: 无jira任务,修复babel/polyfill 被多次引用的问题
  fix: KERNEL-1655 兼容旧版数据连接数据
  fix: DEC-10620 改成用原生的encodeURI
  fix: DEC-10494 国际化错误提示
  fix: DEC-10479 输入数字的地方不可以为空
  fix: DEC-10466 加入title提示
  undefined([object Object]):
  fix: DEC-10299 解决新建插件数据连接,名称重复时的问题
  fix: 适配插件创建者字段
research/11.0
parent
commit
9120eb8f03
  1. 3
      assets/scripts/dec.js
  2. 1
      i18n/zh_cn.properties
  3. 4
      index.html
  4. 1
      package.json
  5. 1
      private/i18n.ts
  6. 9
      src/modules/app.service.ts
  7. 3
      src/modules/constants/constant.ts
  8. 13
      src/modules/constants/env.ts
  9. 34
      src/modules/crud/crud.service.ts
  10. 2
      src/modules/crud/decision.api.ts
  11. 3
      src/modules/pages/connection/components/form_item/form_item.ts
  12. 8
      src/modules/pages/connection/connection.ts
  13. 1
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  14. 11
      src/modules/pages/connection/connection_jndi/connection_jndi.ts
  15. 84
      src/modules/pages/connection/list/list_item/list_item.ts
  16. 1
      src/modules/pages/connection_pool/list_item/list_item.ts
  17. 5
      src/modules/pages/maintain/components/form_item/form_item.ts
  18. 30
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  19. 11
      src/modules/pages/maintain/forms/components/form.jndi.ts
  20. 56
      src/modules/pages/maintain/forms/form.ts
  21. 9
      src/modules/pages/maintain/maintain.ts
  22. 2
      webpack/webpack.dev.js
  23. 2
      webpack/webpack.prod.js

3
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: {

1
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= 年月日

4
index.html

@ -14,7 +14,7 @@
<link
rel="stylesheet"
type="text/css"
href="./node_modules/fineui/dist/fineui.css"
href="./node_modules/fineui/dist/fineui.min.css"
/>
<link
rel="stylesheet"
@ -25,7 +25,7 @@
<body id="body">
<div id="wrapper"></div>
<script src="./node_modules/fineui/dist/fineui.js"></script>
<script src="./node_modules/fineui/dist/fineui.min.js"></script>
<script src="./node_modules/fineui/i18n/i18n.cn.js"></script>
<script src="./node_modules/fineui-materials/docs/materials.js"></script>
<script src="./assets/scripts/dec.js"></script>

1
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",

1
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': '年月日',

9
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;

3
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,
};

13
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;

34
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<ResultType> {
const { url, type, headers, data, params } = reqOptions;
@ -57,15 +77,7 @@ export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType>
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);
});

2
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<SocketResult> {

3
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,
},

8
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;
},

1
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) => {

11
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;

84
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,
}],
};
}

1
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',
},

5
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,

30
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'),
},
],

11
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;

56
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);
});
}
}

9
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,

2
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,

2
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,

Loading…
Cancel
Save