From 5f9f95b717ee54f20e43e72a1e2d87a888e04c8a Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 19 Jan 2016 00:38:15 -0800 Subject: [PATCH] Adding a basic ifram viz --- panoramix/forms.py | 2 ++ panoramix/static/widgets/viz_iframe.js | 20 ++++++++++++++++++++ panoramix/viz.py | 15 ++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 panoramix/static/widgets/viz_iframe.js diff --git a/panoramix/forms.py b/panoramix/forms.py index d999a4fefa9..dc71eb747fb 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -288,6 +288,8 @@ class FormFactory(object): 'Bubble Size', default=default_metric, choices=datasource.metrics_combo), + 'url': TextField( + 'URL', default='www.airbnb.com',), 'where': TextField( 'Custom WHERE clause', default='', description=( diff --git a/panoramix/static/widgets/viz_iframe.js b/panoramix/static/widgets/viz_iframe.js new file mode 100644 index 00000000000..74a1da35506 --- /dev/null +++ b/panoramix/static/widgets/viz_iframe.js @@ -0,0 +1,20 @@ +px.registerViz('iframe', function(slice) { + + function refresh() { + $('#code').attr('rows', '15') + $.getJSON(slice.jsonEndpoint(), function(payload) { + slice.container.html( + ''); + console.log(slice); + slice.container.find('iframe').attr('src', payload.form_data.url); + slice.done(); + }) + .fail(function(xhr) { + slice.error(xhr.responseText); + }); + }; + return { + render: refresh, + resize: refresh, + }; +}); diff --git a/panoramix/viz.py b/panoramix/viz.py index 9e513be6667..87829807b55 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -1146,6 +1146,18 @@ class FilterBoxViz(BaseViz): 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, @@ -1164,6 +1176,7 @@ viz_types_list = [ SankeyViz, WorldMapViz, FilterBoxViz, + IFrameViz, ] -# This dict is used to + viz_types = OrderedDict([(v.viz_type, v) for v in viz_types_list])