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 : ''}`; };