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