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

Iframe #121

Merged
merged 2 commits into from
Jan 19, 2016
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
2 changes: 2 additions & 0 deletions panoramix/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ def __init__(self, viz):
'Bubble Size',
default=default_metric,
choices=datasource.metrics_combo),
'url': TextField(
'URL', default='www.airbnb.com',),
'where': TextField(
'Custom WHERE clause', default='',
description=(
Expand Down
5 changes: 4 additions & 1 deletion panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ def url(self):

@property
def metadata_dejson(self):
return json.loads(self.json_metadata)
if self.json_metadata:
return json.loads(self.json_metadata)
else:
return {}

def dashboard_link(self):
return '<a href="{self.url}">{self.dashboard_title}</a>'.format(self=self)
Expand Down
22 changes: 22 additions & 0 deletions panoramix/static/widgets/viz_iframe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
px.registerViz('iframe', function(slice) {

function refresh() {
$('#code').attr('rows', '15')
$.getJSON(slice.jsonEndpoint(), function(payload) {
slice.container.html(
'<iframe style="width:100%;"></iframe>');
console.log(slice);
iframe = slice.container.find('iframe');
iframe.css('height', slice.height());
iframe.attr('src', payload.form_data.url);
slice.done();
})
.fail(function(xhr) {
slice.error(xhr.responseText);
});
};
return {
render: refresh,
resize: refresh,
};
});
15 changes: 14 additions & 1 deletion panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,18 @@ def get_json_data(self):
return dumps(d)


class IFrameViz(BaseViz):
viz_type = "iframe"
verbose_name = "iFrame"
is_timeseries = False
js_files = ['widgets/viz_iframe.js']
fieldsets = (
{
'label': None,
'fields': ('url',)
},)


viz_types_list = [
TableViz,
PivotTableViz,
Expand All @@ -1164,6 +1176,7 @@ def get_json_data(self):
SankeyViz,
WorldMapViz,
FilterBoxViz,
IFrameViz,
]
# This dict is used to

viz_types = OrderedDict([(v.viz_type, v) for v in viz_types_list])