mirror of
https://github.com/apache/superset.git
synced 2026-04-27 03:55:47 +00:00
* Allowing for templated urls in iFrame
This can allow for passing {{ width }} and {{ height }} as dynamic
attributes in the iFrame's URL.
The new method Slice.render_template method could do more eventually
exposing more variables to be used in dynamic strings.
* Passing function references
* js linting
27 lines
659 B
JavaScript
27 lines
659 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();
|
|
})
|
|
.fail(function (xhr) {
|
|
slice.error(xhr.responseText);
|
|
});
|
|
}
|
|
|
|
return {
|
|
render: refresh,
|
|
resize: refresh
|
|
};
|
|
}
|
|
|
|
module.exports = iframeWidget;
|