superset/caravel/assets/visualizations/iframe.js
x4base 40e1787948 Improve the error message in the slices (#555)
* Improve the error message in the slices

Let slice.error() accept msg and xhr

* Check error first in nvd3_vis.js
2016-06-21 09:42:44 -07:00

27 lines
671 B
JavaScript

var $ = window.$ || require('jquery');
function iframeWidget(slice) {
function refresh() {
$('#code').attr('rows', '15');
$.getJSON(slice.jsonEndpoint(), function (payload) {
var url = slice.render_template(payload.form_data.url);
slice.container.html('<iframe style="width:100%;"></iframe>');
var iframe = slice.container.find('iframe');
iframe.css('height', slice.height());
iframe.attr('src', url);
slice.done(payload);
})
.fail(function (xhr) {
slice.error(xhr.responseText, xhr);
});
}
return {
render: refresh,
resize: refresh
};
}
module.exports = iframeWidget;