From 6daf92e3c1fdbd76079bbeb4dd6f8790f6551871 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 14 Sep 2015 08:04:32 -0700 Subject: [PATCH] About to start ajaxifying --- panoramix/models.py | 4 +- panoramix/templates/panoramix/dashboard.html | 39 ++++++++++++++++--- panoramix/templates/panoramix/datasource.html | 4 +- panoramix/templates/panoramix/viz.html | 20 +++++++--- .../templates/panoramix/viz_highcharts.html | 2 +- .../templates/panoramix/viz_standalone.html | 19 +++++---- panoramix/viz.py | 7 ++-- 7 files changed, 69 insertions(+), 26 deletions(-) diff --git a/panoramix/models.py b/panoramix/models.py index 4eb47a5a9..575764dc7 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -96,8 +96,8 @@ class Dashboard(Model, AuditMixin): def js_files(self): l = [] for o in self.slices: - l += o.js_files - return list(set(l)) + l += [f for f in o.js_files if f not in l] + return l @property def css_files(self): diff --git a/panoramix/templates/panoramix/dashboard.html b/panoramix/templates/panoramix/dashboard.html index ad8dfa0e8..d56ea6f8c 100644 --- a/panoramix/templates/panoramix/dashboard.html +++ b/panoramix/templates/panoramix/dashboard.html @@ -2,12 +2,14 @@ {% block head_css %} {{ super() }} + {% for css in dashboard.css_files %} + + {% endfor %} {% endblock %} @@ -42,6 +48,7 @@
{{ slice.slice_name }}
+
{% endfor %} @@ -50,18 +57,40 @@ {% block tail %} {{ super() }} + {% for js in dashboard.js_files %} + + {% endfor %} + + {% endblock %} diff --git a/panoramix/templates/panoramix/datasource.html b/panoramix/templates/panoramix/datasource.html index aae04dfdf..257dd77ef 100644 --- a/panoramix/templates/panoramix/datasource.html +++ b/panoramix/templates/panoramix/datasource.html @@ -112,6 +112,7 @@ form input.form-control { {% endif %}
+
{% block viz %} {% if viz.error_msg %}
{{ viz.error_msg }}
@@ -120,6 +121,7 @@ form input.form-control {
{{ viz.warning_msg }}
{% endif %} {% endblock %} +
{% if debug %}

Results

@@ -154,10 +156,8 @@ form input.form-control { {% block tail_js %} {{ super() }} - - {% endfor %} + + + {% if not skip_libs %} + {% for js in viz.js_files %} + + {% endfor %} + {% endif %} {% endblock %} diff --git a/panoramix/templates/panoramix/viz_highcharts.html b/panoramix/templates/panoramix/viz_highcharts.html index 5d815d464..6ec6f8fed 100644 --- a/panoramix/templates/panoramix/viz_highcharts.html +++ b/panoramix/templates/panoramix/viz_highcharts.html @@ -1,7 +1,7 @@ {% extends "panoramix/viz.html" %} {% block viz %} {{ super() }} -
+
{% endblock %} {% block tail %} diff --git a/panoramix/templates/panoramix/viz_standalone.html b/panoramix/templates/panoramix/viz_standalone.html index 3e8c32dbe..64adf199f 100644 --- a/panoramix/templates/panoramix/viz_standalone.html +++ b/panoramix/templates/panoramix/viz_standalone.html @@ -1,9 +1,14 @@ -{% extends "appbuilder/baselayout.html" %} -{% block body %} + + + {% if not skip_libs %} + {% block head %} + + {% endblock %} + {% endif %} + {% block tail %}{% endblock %} + + {% block viz %} {% endblock %} -{% endblock %} -{% block tail %} - {{ super() }} -{% endblock %} - + + diff --git a/panoramix/viz.py b/panoramix/viz.py index 4a38b8f79..08cb114d9 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -11,7 +11,7 @@ from panoramix.highchart import Highchart, HighchartBubble from panoramix.forms import form_factory CHART_ARGS = { - 'height': 700, + #'height': 700, 'title': None, 'target_div': 'chart', } @@ -132,6 +132,7 @@ class BaseViz(object): self.template, form=form, viz=self, datasource=self.datasource, results=self.results, standalone=request.args.get('standalone') == 'true', + skip_libs=request.args.get('skip_libs') == 'true', *args, **kwargs) @@ -169,7 +170,7 @@ class HighchartsViz(BaseViz): stacked = False chart_type = 'not_stock' compare = False - js_files = ['highcharts.js'] + js_files = ['highstock.js'] class BubbleViz(HighchartsViz): @@ -179,7 +180,7 @@ class BubbleViz(HighchartsViz): form_fields = [ 'viz_type', 'since', 'until', 'series', 'entity', 'x', 'y', 'size', 'limit'] - js_files = ['highcharts.js', 'highcharts-more.js'] + js_files = ['highstock.js', 'highcharts-more.js'] def query_obj(self): d = super(BubbleViz, self).query_obj()