Skip to content

Commit

Permalink
About to start ajaxifying
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 14, 2015
1 parent a5b8964 commit 6daf92e
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 26 deletions.
4 changes: 2 additions & 2 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def dashboard_link(self):
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):
Expand Down
39 changes: 34 additions & 5 deletions panoramix/templates/panoramix/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

{% block head_css %}
{{ super() }}
{% for css in dashboard.css_files %}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename=css) }}">
{% endfor %}
<link rel="stylesheet" href="{{ url_for('static', filename="jquery.gridster.min.css") }}">
<style>
.gridster li {
list-style-type: none;
border: 1px solid gray;
background: #EEEEEE;
overflow: auto;
box-shadow: 2px 2px 2px #AAA;
border-radius: 5px;
Expand All @@ -25,6 +27,10 @@
div.gridster {
visibility: hidden
}
div.slice_content {
width: 100%;
height: 100%;
}
</style>
{% endblock %}

Expand All @@ -42,6 +48,7 @@
<div class="slice_title">
<h5>{{ slice.slice_name }}</h5>
</div>
<div id="slice_content_{{ slice.id }}"><img src="/static/loading.gif" class="loading"></div>
</li>
{% endfor %}
</ul>
Expand All @@ -50,18 +57,40 @@ <h5>{{ slice.slice_name }}</h5>

{% block tail %}
{{ super() }}
{% for js in dashboard.js_files %}
<script src="{{ url_for('static', filename=js) }}"></script>
{% endfor %}
<script src="{{ url_for("static", filename="jquery.gridster.with-extras.min.js") }}"></script>
<script src="{{ url_for("static", filename="d3.min.js") }}"></script>
<script>
f = d3.format(".4s");
</script>
<script>
//$(".gridster li").html('<img src="/static/loading.gif" class="loading">');

$( document ).ready(function() {
$(".gridster ul").gridster({
widget_margins: [5, 5],
widget_base_dimensions: [150, 150],
resize: {enabled: true}
});
$("#loadme1").load("/panoramix/table/2/?flt_col_0=gender&datasource_id=2&flt_op_0=in&viz_type=table&row_limit=50&since=50%20years%20ago&until=now&metrics=total&granularity=all&datasource_name=baby_names&slice_name=Top%2050%20table&where=&groupby=name&flt_eq_0=&datasource_type=table&standalone=true");
//$("#loadme2").load("/panoramix/table/2/?flt_col_0=gender&datasource_id=2&flt_op_0=in&viz_type=pie&since=50%20years%20ago&until=now&metrics=total&limit=10&granularity=one%20day&datasource_name=baby_names&slice_name=Pie&where=&groupby=name&flt_eq_0=&datasource_type=table&standalone=true");
//$("loadme3").html('<iframe src="http://localhost:8088/panoramix/table/2/?flt_col_0=gender&datasource_id=2&flt_op_0=in&viz_type=pie&since=50%20years%20ago&until=now&metrics=total&limit=10&granularity=one%20day&datasource_name=baby_names&slice_name=Pie&where=&groupby=name&flt_eq_0=&datasource_type=table&standalone=true"></iframe>');
var url = "/panoramix/table/2/?flt_col_0=gender&datasource_id=2&flt_op_0=in&viz_type=pie&since=50%20years%20ago&until=now&metrics=total&limit=10&granularity=one%20day&datasource_name=baby_names&slice_name=Pie&where=&groupby=name&flt_eq_0=&datasource_type=table&standalone=true&skip_libs=true";
$.ajax({
url: url,
success: function(result){
$("#slice_content_2").html(result);
},
async: true,
});
var url = "/panoramix/table/2/?flt_col_0=gender&rolling_periods=&datasource_id=2&flt_op_0=in&slice_name=Super%20Slice&viz_type=line&since=50%20years%20ago&groupby=name&metrics=total&limit=25&flt_eq_0=&granularity=one%20day&datasource_name=baby_names&where=&until=now&rolling_type=mean&datasource_type=table&standalone=true&skip_libs=true";
$.ajax({
url: url,
success: function(result){
$("#slice_content_3").html(result);
},
async: true,
});
$("div.gridster").css('visibility', 'visible');
});
</script>

{% endblock %}
Expand Down
4 changes: 2 additions & 2 deletions panoramix/templates/panoramix/datasource.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h3>{{ viz.verbose_name }}
{% endif %}
</h3>
<hr/>
<div class="viz" style="height: 600px;">
{% block viz %}
{% if viz.error_msg %}
<div class="alert alert-danger">{{ viz.error_msg }}</div>
Expand All @@ -120,6 +121,7 @@ <h3>{{ viz.verbose_name }}
<div class="alert alert-warning">{{ viz.warning_msg }}</div>
{% endif %}
{% endblock %}
</div>

{% if debug %}
<h3>Results</h3>
Expand Down Expand Up @@ -154,10 +156,8 @@ <h4 class="modal-title" id="myModalLabel">Query</h4>

{% block tail_js %}
{{ super() }}
<script src="{{ url_for("static", filename="d3.min.js") }}"></script>
<script>
$( document ).ready(function() {
f = d3.format(".4s");
function getParam(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
Expand Down
20 changes: 14 additions & 6 deletions panoramix/templates/panoramix/viz.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@

{% block head %}
{{super()}}
{% for css in viz.css_files %}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename=css) }}">
{% endfor %}
{% if not skip_libs %}
{% for css in viz.css_files %}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename=css) }}">
{% endfor %}
{% endif %}
{% endblock %}


{% block tail %}
{{super()}}
{% for js in viz.js_files %}
<script src="{{ url_for('static', filename=js) }}"></script>
{% endfor %}
<script src="{{ url_for("static", filename="d3.min.js") }}"></script>
<script>
f = d3.format(".4s");
</script>
{% if not skip_libs %}
{% for js in viz.js_files %}
<script src="{{ url_for('static', filename=js) }}"></script>
{% endfor %}
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion panoramix/templates/panoramix/viz_highcharts.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "panoramix/viz.html" %}
{% block viz %}
{{ super() }}
<div id="chart"></div>
<div id="chart" style="height:100%; width:100%;"></div>
{% endblock %}

{% block tail %}
Expand Down
19 changes: 12 additions & 7 deletions panoramix/templates/panoramix/viz_standalone.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% extends "appbuilder/baselayout.html" %}
{% block body %}
<html>
<head>
{% if not skip_libs %}
{% block head %}
<script src="{{url_for('appbuilder.static',filename='js/jquery-latest.js')}}"></script>
{% endblock %}
{% endif %}
{% block tail %}{% endblock %}
</head>
<body>
{% block viz %}
{% endblock %}
{% endblock %}
{% block tail %}
{{ super() }}
{% endblock %}

</body>
</html>
7 changes: 4 additions & 3 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from panoramix.forms import form_factory

CHART_ARGS = {
'height': 700,
#'height': 700,
'title': None,
'target_div': 'chart',
}
Expand Down Expand Up @@ -132,6 +132,7 @@ def render(self, *args, **kwargs):
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)


Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit 6daf92e

Please sign in to comment.