Browse Source

fix: 修改插件接口,使用providew

research/10.0
alan 5 years ago
parent
commit
55ed0a0ec3
  1. 2
      src/modules/app.constant.ts
  2. 9
      src/modules/app.provider.ts
  3. 10
      src/modules/app.service.ts
  4. 1
      src/modules/app.ts
  5. 6
      src/modules/constants/constant.ts
  6. 3
      src/modules/constants/plugin.ts
  7. 2
      src/modules/pages/connection/connection_plugin/connection_plugin.ts
  8. 4
      src/modules/pages/maintain/forms/components/form.plugin.ts

2
src/modules/app.constant.ts

@ -0,0 +1,2 @@
export const CONSTANT_PLUGIN_TYPES = 'dec.constant.database.conf.connect.types';
BI.constant(CONSTANT_PLUGIN_TYPES, []);

9
src/modules/app.provider.ts

@ -0,0 +1,9 @@
import { CONSTANT_PLUGIN_TYPES } from './app.constant';
BI.provider('dec.connection.provider.datebase', function() {
this.registerDatabaseType = (config: any) => {
BI.config(CONSTANT_PLUGIN_TYPES, connections => BI.concat(connections, config));
};
this.$get = () => BI.inherit(BI.OB, {
});
});

10
src/modules/app.service.ts

@ -1,5 +1,5 @@
import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER, DESIGN_DRIVER_TYPE } from '@constants/constant';
import { CONSTANT_PLUGIN_TYPES, CONSTANT_PLUGIN_SHOW, CONSTANT_PLUGIN_EDIT } from '@constants/plugin';
import { CONSTANT_PLUGIN_TYPES } from './app.constant';
import { DatabaseType } from './app.typings';
import { Connection } from './crud/crud.typings';
export function getAllDatabaseTypes():DatabaseType[] {
@ -14,13 +14,15 @@ export function getAllDatabaseTypes():DatabaseType[] {
}),
];
}
function getPlugin(type: string) {
return BI.Constants.getConstant(CONSTANT_PLUGIN_TYPES).find(item => item.databaseType === type);
}
export function getPluginWidgetShow(plugin: string) {
return BI.Constants.getConstant(CONSTANT_PLUGIN_SHOW.replace('${databaseType}', plugin));
return BI.get(getPlugin(plugin), 'show');
}
export function getPluginWidgetEdit(plugin: string) {
return BI.Constants.getConstant(CONSTANT_PLUGIN_EDIT.replace('${databaseType}', plugin));
return BI.get(getPlugin(plugin), 'edit');
}
// 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型

1
src/modules/app.ts

@ -4,6 +4,7 @@ import { TitleXtype } from './title/title';
import { PAGE_INDEX } from './constants/constant';
import { ConnectionXtype, DatebaseXtype, MaintainXtype, ConnectionPoolXtype } from './pages';
import { AppModel, AppModelXtype } from './app.model';
import './app.provider';
import '../less/index.less';
export const AppXtype = 'dec.dcm.main';

6
src/modules/constants/constant.ts

@ -1,4 +1,4 @@
import { CONSTANT_PLUGIN_TYPES } from './plugin';
import { CONSTANT_PLUGIN_TYPES } from '../app.constant';
export const PAGE_INDEX = {
CONNECTION: 'connection',
@ -15,10 +15,6 @@ export const DATEBASE_FILTER_TYPE = {
OTHER: OTHER_JDBC,
};
BI.constant(CONSTANT_PLUGIN_TYPES, [
]);
export const DATA_BASE_TYPES_OTHER =
{
text: OTHER_JDBC,

3
src/modules/constants/plugin.ts

@ -1,3 +0,0 @@
export const CONSTANT_PLUGIN_TYPES = 'dec.constant.database.conf.connect.types';
export const CONSTANT_PLUGIN_SHOW = 'dec.constant.database.conf.connect.form.${databaseType}.show';
export const CONSTANT_PLUGIN_EDIT = 'dec.constant.database.conf.connect.form.${databaseType}.edit';

2
src/modules/pages/connection/connection_plugin/connection_plugin.ts

@ -12,7 +12,7 @@ export class ConnectionPlugin extends BI.Widget {
return {
type: getPluginWidgetShow(databaseType),
formData: this.model.connectionSelectedOne.connectionData,
value: this.model.connectionSelectedOne.connectionData,
};
}
}

4
src/modules/pages/maintain/forms/components/form.plugin.ts

@ -18,7 +18,7 @@ export class FormPlugin extends BI.Widget {
ref: (_ref: any) => {
this.plugin = _ref;
},
formData: this.options.formData.connectionData,
value: this.options.formData.connectionData,
};
}
@ -29,7 +29,7 @@ export class FormPlugin extends BI.Widget {
connectionId,
connectionType,
connectionName,
connectionData: this.plugin.getSubmitValue(),
connectionData: this.plugin.getValue(),
};
}
}

Loading…
Cancel
Save