superset/caravel/assets/visualizations/iframe.js
Maxime Beauchemin a8fd23dfa4 Linting JSX files (#941)
`.jsx` linting is now in-scope for the `npm run lint` command, and
I linted the base files and some of the viz, there's still quite a bit
of work there, but that's a first pass on it.
2016-08-22 13:21:30 -07:00

26 lines
651 B
JavaScript

const $ = require('jquery');
function iframeWidget(slice) {
function refresh() {
$('#code').attr('rows', '15');
$.getJSON(slice.jsonEndpoint(), function (payload) {
const url = slice.render_template(payload.form_data.url);
slice.container.html('<iframe style="width:100%;"></iframe>');
const 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;