From c7c0208c4afc2f65fdfb93b674dbbf4af279c48f Mon Sep 17 00:00:00 2001 From: Chareice Date: Thu, 25 Jan 2024 21:16:28 +0800 Subject: [PATCH] chore: load dataSource after start --- .../src/server/plugin.ts | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts index 559ca7d2fd..75d90c04d2 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts @@ -162,28 +162,26 @@ export class PluginDataSourceManagerServer extends Plugin { }); this.app.on('afterStart', async (app: Application) => { - const databaseConnections: DatabaseConnectionModel[] = await this.app.db - .getRepository('databaseConnections') - .find(); - - // load all connections - for (const databaseConnection of databaseConnections) { - await databaseConnection.loadIntoApplication({ + const dataSourcesRecords: DataSourceModel[] = await this.app.db.getRepository('dataSources').find(); + for (const dataSourceRecord of dataSourcesRecords) { + await dataSourceRecord.loadIntoApplication({ app, }); } + }); + this.app.on('afterStart', async (app: Application) => { // load roles - const rolesModel: ConnectionsRolesModel[] = await this.app.db.getRepository('connectionsRoles').find(); - const pluginACL: any = this.app.pm.get('acl'); - - for (const roleModel of rolesModel) { - await roleModel.writeToAcl({ - grantHelper: pluginACL.grantHelper, - associationFieldsActions: pluginACL.associationFieldsActions, - acl: this.app.acls.get(roleModel.get('connectionName')), - }); - } + // const rolesModel: ConnectionsRolesModel[] = await this.app.db.getRepository('connectionsRoles').find(); + // const pluginACL: any = this.app.pm.get('acl'); + // + // for (const roleModel of rolesModel) { + // await roleModel.writeToAcl({ + // grantHelper: pluginACL.grantHelper, + // associationFieldsActions: pluginACL.associationFieldsActions, + // acl: this.app.acls.get(roleModel.get('connectionName')), + // }); + // } }); this.app.db.on('connectionsRolesResources.afterSaveWithAssociations', async (model, options) => {