diff --git a/src/modules/app.constant.ts b/src/modules/app.constant.ts new file mode 100644 index 0000000..ebb5253 --- /dev/null +++ b/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, []); diff --git a/src/modules/app.provider.ts b/src/modules/app.provider.ts new file mode 100644 index 0000000..af4542a --- /dev/null +++ b/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, { + }); +}); diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index d37c088..a7fe9be 100644 --- a/src/modules/app.service.ts +++ b/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来判断数据库类型 diff --git a/src/modules/app.ts b/src/modules/app.ts index e2b4927..3dd69aa 100644 --- a/src/modules/app.ts +++ b/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'; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 019cf43..863c4f7 100644 --- a/src/modules/constants/constant.ts +++ b/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, diff --git a/src/modules/constants/plugin.ts b/src/modules/constants/plugin.ts deleted file mode 100644 index 6037508..0000000 --- a/src/modules/constants/plugin.ts +++ /dev/null @@ -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'; diff --git a/src/modules/pages/connection/connection_plugin/connection_plugin.ts b/src/modules/pages/connection/connection_plugin/connection_plugin.ts index af6968a..14e6990 100644 --- a/src/modules/pages/connection/connection_plugin/connection_plugin.ts +++ b/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, }; } } diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index a25b9d3..6774bca 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/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(), }; } }