mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 15:37:36 +00:00
chore: reloading status
This commit is contained in:
parent
56be4a38c5
commit
411a174760
@ -52,7 +52,11 @@ export class DataSourceModel extends Model {
|
||||
|
||||
const pluginDataSourceManagerServer = app.pm.get('data-source-manager') as PluginDataSourceManagerServer;
|
||||
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'loading';
|
||||
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === 'loaded') {
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'reloading';
|
||||
} else {
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'loading';
|
||||
}
|
||||
|
||||
const loadRoleIntoDataSource = async (model: DataSourcesRolesModel, dataSource: DataSource) => {
|
||||
const pluginACL: any = app.pm.get('acl');
|
||||
@ -108,7 +112,14 @@ export class DataSourceModel extends Model {
|
||||
} catch (e) {
|
||||
app.logger.error(`load data source failed, ${e.message}`);
|
||||
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'failed';
|
||||
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === 'loading') {
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'loading-failed';
|
||||
}
|
||||
|
||||
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === 'reloading') {
|
||||
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'reloading-failed';
|
||||
}
|
||||
|
||||
pluginDataSourceManagerServer.dataSourceErrors[dataSourceKey] = e;
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import { DataSourcesRolesResourcesActionModel } from './models/connections-roles
|
||||
import { DataSourceModel } from './models/data-source';
|
||||
import lodash from 'lodash';
|
||||
|
||||
type DataSourceState = 'loading' | 'loaded' | 'failed';
|
||||
type DataSourceState = 'loading' | 'loaded' | 'loading-failed' | 'reloading' | 'reloading-failed';
|
||||
|
||||
export class PluginDataSourceManagerServer extends Plugin {
|
||||
public dataSourceErrors: {
|
||||
@ -102,9 +102,10 @@ export class PluginDataSourceManagerServer extends Plugin {
|
||||
const dataSourceStatus = this.dataSourceStatus[item.get('key')];
|
||||
data['status'] = dataSourceStatus;
|
||||
|
||||
if (dataSourceStatus === 'failed') {
|
||||
if (dataSourceStatus === 'loading-failed' || dataSourceStatus === 'reloading-failed') {
|
||||
data['errorMessage'] = this.dataSourceErrors[item.get('key')].message;
|
||||
}
|
||||
|
||||
return data;
|
||||
}),
|
||||
);
|
||||
@ -129,7 +130,7 @@ export class PluginDataSourceManagerServer extends Plugin {
|
||||
status: dataSourceStatus,
|
||||
};
|
||||
|
||||
if (dataSourceStatus === 'failed') {
|
||||
if (dataSourceStatus === 'loading-failed' || dataSourceStatus === 'reloading-failed') {
|
||||
item['errorMessage'] = plugin.dataSourceErrors[dataSourceModel.get('key')].message;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user