Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard]Add timeout message on Dashboard view #2910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions superset/assets/javascripts/modules/superset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Mustache from 'mustache';
import vizMap from '../../visualizations/main';
import { getExploreUrl } from '../explore/exploreUtils';
import { applyDefaultFormData } from '../explore/stores/store';
import { QUERY_TIMEOUT_THRESHOLD } from '../constants';

const utils = require('./utils');

Expand Down Expand Up @@ -123,9 +124,6 @@ const px = function () {
controller.done(this);
},
getErrorMsg(xhr) {
if (xhr.statusText === 'timeout') {
return 'The request timed out';
}
let msg = '';
if (!xhr.responseText) {
const status = xhr.status;
Expand Down Expand Up @@ -158,9 +156,14 @@ const px = function () {
errHtml += `<div class="alert alert-danger">${errorMsg}</div>`;
}
if (xhr) {
const extendedMsg = this.getErrorMsg(xhr);
if (extendedMsg) {
errHtml += `<div class="alert alert-danger">${extendedMsg}</div>`;
if (xhr.statusText === 'timeout') {
errHtml += '<div class="alert alert-warning">' +
`Query timeout - visualization query are set to time out at ${QUERY_TIMEOUT_THRESHOLD / 1000} seconds.</div>`;
} else {
const extendedMsg = this.getErrorMsg(xhr);
if (extendedMsg) {
errHtml += `<div class="alert alert-danger">${extendedMsg}</div>`;
}
}
}
container.html(errHtml);
Expand Down Expand Up @@ -205,15 +208,20 @@ const px = function () {
token.find('img.loading').show();
container.fadeTo(0.5, 0.25);
container.css('height', this.height());
$.getJSON(this.jsonEndpoint(), (queryResponse) => {
try {
vizMap[formData.viz_type](this, queryResponse);
this.done(queryResponse);
} catch (e) {
this.error('An error occurred while rendering the visualization: ' + e);
}
}).fail((err) => {
this.error(err.responseText, err);
$.ajax({
url: this.jsonEndpoint(),
timeout: QUERY_TIMEOUT_THRESHOLD,
success: (queryResponse) => {
try {
vizMap[formData.viz_type](this, queryResponse);
this.done(queryResponse);
} catch (e) {
this.error('An error occurred while rendering the visualization: ' + e);
}
},
error: (err) => {
this.error(err.responseText, err);
},
});
},
resize() {
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/visualizations/filter_box.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
border: 1px superset black;
}

.dashboard .filter_box .slice_container > div {
.dashboard .filter_box .slice_container > div:not(.alert) {
padding-top: 0;
}

Expand Down