mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Added Alert for ControlPanel and ChartContainer (#1626)
* Added Alert for ControlPanel and ChartContainer Done: - Add alert for Control Panel when fetch_datasource_metadata failes - Add alert for Chart Container when update_explore query fails * Changed color to warning-yellow * Solve linter issue * Fixed indent and delete error_redirect
This commit is contained in:
@@ -24,8 +24,8 @@ export function fetchSucceeded() {
|
||||
}
|
||||
|
||||
export const FETCH_FAILED = 'FETCH_FAILED';
|
||||
export function fetchFailed() {
|
||||
return { type: FETCH_FAILED };
|
||||
export function fetchFailed(error) {
|
||||
return { type: FETCH_FAILED, error };
|
||||
}
|
||||
|
||||
export function fetchFieldOptions(datasourceId, datasourceType) {
|
||||
@@ -35,18 +35,19 @@ export function fetchFieldOptions(datasourceId, datasourceType) {
|
||||
if (datasourceId) {
|
||||
const params = [`datasource_id=${datasourceId}`, `datasource_type=${datasourceType}`];
|
||||
const url = '/superset/fetch_datasource_metadata?' + params.join('&');
|
||||
|
||||
$.get(url, (data, status) => {
|
||||
if (status === 'success') {
|
||||
// populate options for select type fields
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url,
|
||||
success: (data) => {
|
||||
dispatch(setFieldOptions(data.field_options));
|
||||
dispatch(fetchSucceeded());
|
||||
} else if (status === 'error') {
|
||||
dispatch(fetchFailed());
|
||||
}
|
||||
},
|
||||
error(error) {
|
||||
dispatch(fetchFailed(error.responseJSON.error));
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// in what case don't we have a datasource id?
|
||||
dispatch(fetchFailed('Please select a datasource'));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -119,8 +120,8 @@ export function chartUpdateStarted() {
|
||||
}
|
||||
|
||||
export const CHART_UPDATE_FAILED = 'CHART_UPDATE_FAILED ';
|
||||
export function chartUpdateFailed() {
|
||||
return { type: CHART_UPDATE_FAILED };
|
||||
export function chartUpdateFailed(error) {
|
||||
return { type: CHART_UPDATE_FAILED, error };
|
||||
}
|
||||
|
||||
export function updateExplore(datasource_type, datasource_id, form_data) {
|
||||
@@ -139,9 +140,18 @@ export function updateExplore(datasource_type, datasource_id, form_data) {
|
||||
dispatch(updateChart(JSON.parse(data)));
|
||||
},
|
||||
error(error) {
|
||||
dispatch(chartUpdateFailed(error));
|
||||
dispatch(chartUpdateFailed(error.responseJSON.error));
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const REMOVE_CONTROL_PANEL_ALERT = 'REMOVE_CONTROL_PANEL_ALERT';
|
||||
export function removeControlPanelAlert() {
|
||||
return { type: REMOVE_CONTROL_PANEL_ALERT };
|
||||
}
|
||||
|
||||
export const REMOVE_CHART_ALERT = 'REMOVE_CHART_ALERT';
|
||||
export function removeChartAlert() {
|
||||
return { type: REMOVE_CHART_ALERT };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user