chore: reloading status

This commit is contained in:
Chareice 2024-02-02 12:04:55 +08:00
parent 56be4a38c5
commit 411a174760
No known key found for this signature in database
2 changed files with 17 additions and 5 deletions

View File

@ -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;
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === 'loaded') {
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'reloading';
} else {
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = 'loading'; 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;
} }

View File

@ -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;
} }