mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Make runQueries action independent from datasource loading
This commit is contained in:
parent
2ddccb4a21
commit
3c358e406e
@ -79,7 +79,15 @@ export function changeDatasource(exploreId: ExploreId, datasource: string): Thun
|
|||||||
await dispatch(importQueries(exploreId, modifiedQueries, currentDataSourceInstance, newDataSourceInstance));
|
await dispatch(importQueries(exploreId, modifiedQueries, currentDataSourceInstance, newDataSourceInstance));
|
||||||
|
|
||||||
dispatch(updateDatasourceInstance(exploreId, newDataSourceInstance));
|
dispatch(updateDatasourceInstance(exploreId, newDataSourceInstance));
|
||||||
dispatch(loadDatasource(exploreId, newDataSourceInstance));
|
|
||||||
|
try {
|
||||||
|
await dispatch(loadDatasource(exploreId, newDataSourceInstance));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(runQueries(exploreId));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +205,14 @@ export function initializeExplore(
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(updateDatasourceInstance(exploreId, instance));
|
dispatch(updateDatasourceInstance(exploreId, instance));
|
||||||
dispatch(loadDatasource(exploreId, instance));
|
|
||||||
|
try {
|
||||||
|
await dispatch(loadDatasource(exploreId, instance));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch(runQueries(exploreId, true));
|
||||||
} else {
|
} else {
|
||||||
dispatch(loadDatasourceMissing(exploreId));
|
dispatch(loadDatasourceMissing(exploreId));
|
||||||
}
|
}
|
||||||
@ -343,8 +358,8 @@ export function loadDatasource(exploreId: ExploreId, instance: DataSourceApi): T
|
|||||||
|
|
||||||
// Keep ID to track selection
|
// Keep ID to track selection
|
||||||
dispatch(loadDatasourcePending(exploreId, datasourceName));
|
dispatch(loadDatasourcePending(exploreId, datasourceName));
|
||||||
|
|
||||||
let datasourceError = null;
|
let datasourceError = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const testResult = await instance.testDatasource();
|
const testResult = await instance.testDatasource();
|
||||||
datasourceError = testResult.status === 'success' ? null : testResult.message;
|
datasourceError = testResult.status === 'success' ? null : testResult.message;
|
||||||
@ -354,7 +369,7 @@ export function loadDatasource(exploreId: ExploreId, instance: DataSourceApi): T
|
|||||||
|
|
||||||
if (datasourceError) {
|
if (datasourceError) {
|
||||||
dispatch(loadDatasourceFailure(exploreId, datasourceError));
|
dispatch(loadDatasourceFailure(exploreId, datasourceError));
|
||||||
return;
|
return Promise.reject(`${datasourceName} loading failed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datasourceName !== getState().explore[exploreId].requestedDatasourceName) {
|
if (datasourceName !== getState().explore[exploreId].requestedDatasourceName) {
|
||||||
@ -372,7 +387,7 @@ export function loadDatasource(exploreId: ExploreId, instance: DataSourceApi): T
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(loadDatasourceSuccess(exploreId, instance));
|
dispatch(loadDatasourceSuccess(exploreId, instance));
|
||||||
dispatch(runQueries(exploreId));
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,14 +587,14 @@ export function removeQueryRow(exploreId: ExploreId, index: number): ThunkResult
|
|||||||
/**
|
/**
|
||||||
* Main action to run queries and dispatches sub-actions based on which result viewers are active
|
* Main action to run queries and dispatches sub-actions based on which result viewers are active
|
||||||
*/
|
*/
|
||||||
export function runQueries(exploreId: ExploreId) {
|
export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const {
|
const {
|
||||||
datasourceInstance,
|
datasourceInstance,
|
||||||
modifiedQueries,
|
modifiedQueries,
|
||||||
// showingLogs,
|
showingLogs,
|
||||||
// showingGraph,
|
showingGraph,
|
||||||
// showingTable,
|
showingTable,
|
||||||
supportsGraph,
|
supportsGraph,
|
||||||
supportsLogs,
|
supportsLogs,
|
||||||
supportsTable,
|
supportsTable,
|
||||||
@ -596,7 +611,7 @@ export function runQueries(exploreId: ExploreId) {
|
|||||||
const interval = datasourceInstance.interval;
|
const interval = datasourceInstance.interval;
|
||||||
|
|
||||||
// Keep table queries first since they need to return quickly
|
// Keep table queries first since they need to return quickly
|
||||||
if (/*showingTable &&*/ supportsTable) {
|
if ((ignoreUIState || showingTable) && supportsTable) {
|
||||||
dispatch(
|
dispatch(
|
||||||
runQueriesForType(
|
runQueriesForType(
|
||||||
exploreId,
|
exploreId,
|
||||||
@ -611,7 +626,7 @@ export function runQueries(exploreId: ExploreId) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (/*showingGraph &&*/ supportsGraph) {
|
if ((ignoreUIState || showingGraph) && supportsGraph) {
|
||||||
dispatch(
|
dispatch(
|
||||||
runQueriesForType(
|
runQueriesForType(
|
||||||
exploreId,
|
exploreId,
|
||||||
@ -625,9 +640,10 @@ export function runQueries(exploreId: ExploreId) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (/*showingLogs &&*/ supportsLogs) {
|
if ((ignoreUIState || showingLogs) && supportsLogs) {
|
||||||
dispatch(runQueriesForType(exploreId, 'Logs', { interval, format: 'logs' }));
|
dispatch(runQueriesForType(exploreId, 'Logs', { interval, format: 'logs' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(stateSave());
|
dispatch(stateSave());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user