From 8867223a3166c9fef2ddb14b3f63406fd9936a5a Mon Sep 17 00:00:00 2001 From: alan Date: Wed, 15 May 2019 16:52:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E9=87=8D=E5=90=8D=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.constant.ts | 5 +++++ src/app/link_set/link-set.model.ts | 5 +++-- .../right/right_detail/right.detail.component.ts | 7 +++++-- src/app/link_set/select/select.component.ts | 4 ++-- src/app/link_set/select/select.constant.ts | 5 ----- src/app/link_set/select/select.service.ts | 14 ++++++++++---- 6 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 src/app/app.constant.ts delete mode 100644 src/app/link_set/select/select.constant.ts diff --git a/src/app/app.constant.ts b/src/app/app.constant.ts new file mode 100644 index 0000000..0c25e29 --- /dev/null +++ b/src/app/app.constant.ts @@ -0,0 +1,5 @@ +export const ConstantName = 'dec.constant.database.conf.connect.list'; +export const links = ['APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200']; +BI.constant(ConstantName, [ +]); +export default ConstantName; diff --git a/src/app/link_set/link-set.model.ts b/src/app/link_set/link-set.model.ts index 8c9cae3..f9761f0 100644 --- a/src/app/link_set/link-set.model.ts +++ b/src/app/link_set/link-set.model.ts @@ -67,7 +67,8 @@ const Model: ModelType = { }); }, copyLink(id: string) { - const name = getCnnectionName(this.model.linkList); + const connectionName = BI.find(this.model.linkList, (index: number, item: LinkType) => item.connectionId === id).connectionName; + const name = getCnnectionName(this.model.linkList, connectionName); let data = {}; this.model.linkList.forEach((item: LinkType) => { if (item.connectionId === id) { @@ -133,7 +134,7 @@ const Model: ModelType = { }); }, _setNewLink(value: string) { - const name = getCnnectionName(this.model.linkList); + const name = getCnnectionName(this.model.linkList, value); let data = {}; databaseTyle.forEach(item => { if (item.text === value) { diff --git a/src/app/link_set/right/right_detail/right.detail.component.ts b/src/app/link_set/right/right_detail/right.detail.component.ts index 04acb5c..c801ea1 100644 --- a/src/app/link_set/right/right_detail/right.detail.component.ts +++ b/src/app/link_set/right/right_detail/right.detail.component.ts @@ -5,14 +5,17 @@ import RightShow from '../right_show/right.show.component'; import RightEdit from '../right_edit/right.edit.component'; import RightEditMysql from '../right_edit/right.edit.mysql.component'; import {LinkType} from '@ui/type'; +import pluginListConstant from '../../../app.constant'; const className = 'fr.component.right.detail'; let rightDetail: any = null; const renderEdit = (linkSelected: LinkType): void => { + const plugins: string[] = BI.Constants.getConstant(pluginListConstant); + const isPlugin = BI.some(plugins, (index: number, item: string) => item === linkSelected.text); let typeEdit = linkSelected.databaseType === 'mysql' ? RightEditMysql : RightEdit; - if (!linkSelected.driver) { + if (isPlugin) { typeEdit = BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${linkSelected.text.toLowerCase()}.edit`); } - const showPage = linkSelected.driver ? RightShow : BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${linkSelected.text.toLowerCase()}.preview`); + const showPage = !isPlugin ? RightShow : BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${linkSelected.text.toLowerCase()}.preview`); rightDetail.populate(BI.createItems([ { type: Title, diff --git a/src/app/link_set/select/select.component.ts b/src/app/link_set/select/select.component.ts index adf1a9f..cdbe8e6 100644 --- a/src/app/link_set/select/select.component.ts +++ b/src/app/link_set/select/select.component.ts @@ -1,7 +1,7 @@ import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui'; import selectModel from '../link-set.model'; import {moreLink} from '../more/more.link.service'; -import connectList from './select.constant'; +import connectList, {links} from '../../app.constant'; const className = 'fr.linkset.select'; const Widget: WidgetType = { _store() { @@ -24,7 +24,7 @@ const Widget: WidgetType = { el: { type: ButtonGroup, cls:'database-link-items', - items: [...BI.map(BI.Constants.getConstant(connectList), (index: number, item: string) => { + items: [...BI.map([...links, ...BI.Constants.getConstant(connectList)], (index: number, item: string) => { return { type: TextItem, height: 24, diff --git a/src/app/link_set/select/select.constant.ts b/src/app/link_set/select/select.constant.ts deleted file mode 100644 index 164b958..0000000 --- a/src/app/link_set/select/select.constant.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const ConstantName = 'dec.constant.database.conf.connect.list'; -BI.constant(ConstantName, [ - 'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200', -]); -export default ConstantName; diff --git a/src/app/link_set/select/select.service.ts b/src/app/link_set/select/select.service.ts index 40f8e7d..37d2b08 100644 --- a/src/app/link_set/select/select.service.ts +++ b/src/app/link_set/select/select.service.ts @@ -1,4 +1,5 @@ import {LinkType} from '@ui/type'; +import pluginListConstant from '../../app.constant'; export const databaseTyle = [ { @@ -260,12 +261,17 @@ export const databaseTyle = [ }, ]; -export const getCnnectionName = (links: LinkType[]): string => { +export const getCnnectionName = (links: LinkType[], name: string): string => { + const plugins: string[] = BI.Constants.getConstant(pluginListConstant); 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 : '数据连接'; + links.forEach(link => { link.isSelected = false; - if (link.connectionName.startsWith('数据连接')) { - const name = link.connectionName.replace('数据连接', '0'); + if (link.connectionName.startsWith(startWith)) { + const name = link.connectionName.replace(startWith, '0'); const index = parseInt(name, 10) + 1; if (index > nameIndex) { nameIndex = index; @@ -273,5 +279,5 @@ export const getCnnectionName = (links: LinkType[]): string => { } }); - return `数据连接${nameIndex > 0 ? nameIndex : ''}`; + return `${startWith}${nameIndex > 0 ? nameIndex : ''}`; };