Browse Source

fix: 修复插件数据连接重名的bug

master
alan 6 years ago
parent
commit
8867223a31
  1. 5
      src/app/app.constant.ts
  2. 5
      src/app/link_set/link-set.model.ts
  3. 7
      src/app/link_set/right/right_detail/right.detail.component.ts
  4. 4
      src/app/link_set/select/select.component.ts
  5. 5
      src/app/link_set/select/select.constant.ts
  6. 14
      src/app/link_set/select/select.service.ts

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

5
src/app/link_set/link-set.model.ts

@ -67,7 +67,8 @@ const Model: ModelType = {
}); });
}, },
copyLink(id: string) { 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 = {}; let data = {};
this.model.linkList.forEach((item: LinkType) => { this.model.linkList.forEach((item: LinkType) => {
if (item.connectionId === id) { if (item.connectionId === id) {
@ -133,7 +134,7 @@ const Model: ModelType = {
}); });
}, },
_setNewLink(value: string) { _setNewLink(value: string) {
const name = getCnnectionName(this.model.linkList); const name = getCnnectionName(this.model.linkList, value);
let data = {}; let data = {};
databaseTyle.forEach(item => { databaseTyle.forEach(item => {
if (item.text === value) { if (item.text === value) {

7
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 RightEdit from '../right_edit/right.edit.component';
import RightEditMysql from '../right_edit/right.edit.mysql.component'; import RightEditMysql from '../right_edit/right.edit.mysql.component';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import pluginListConstant from '../../../app.constant';
const className = 'fr.component.right.detail'; const className = 'fr.component.right.detail';
let rightDetail: any = null; let rightDetail: any = null;
const renderEdit = (linkSelected: LinkType): void => { 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; 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`); 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([ rightDetail.populate(BI.createItems([
{ {
type: Title, type: Title,

4
src/app/link_set/select/select.component.ts

@ -1,7 +1,7 @@
import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui'; import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui';
import selectModel from '../link-set.model'; import selectModel from '../link-set.model';
import {moreLink} from '../more/more.link.service'; import {moreLink} from '../more/more.link.service';
import connectList from './select.constant'; import connectList, {links} from '../../app.constant';
const className = 'fr.linkset.select'; const className = 'fr.linkset.select';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -24,7 +24,7 @@ const Widget: WidgetType = {
el: { el: {
type: ButtonGroup, type: ButtonGroup,
cls:'database-link-items', 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 { return {
type: TextItem, type: TextItem,
height: 24, height: 24,

5
src/app/link_set/select/select.constant.ts

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

14
src/app/link_set/select/select.service.ts

@ -1,4 +1,5 @@
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import pluginListConstant from '../../app.constant';
export const databaseTyle = [ 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; 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 => { links.forEach(link => {
link.isSelected = false; link.isSelected = false;
if (link.connectionName.startsWith('数据连接')) { if (link.connectionName.startsWith(startWith)) {
const name = link.connectionName.replace('数据连接', '0'); const name = link.connectionName.replace(startWith, '0');
const index = parseInt(name, 10) + 1; const index = parseInt(name, 10) + 1;
if (index > nameIndex) { if (index > nameIndex) {
nameIndex = index; nameIndex = index;
@ -273,5 +279,5 @@ export const getCnnectionName = (links: LinkType[]): string => {
} }
}); });
return `数据连接${nameIndex > 0 ? nameIndex : ''}`; return `${startWith}${nameIndex > 0 ? nameIndex : ''}`;
}; };

Loading…
Cancel
Save