diff --git a/.gitignore b/.gitignore
index 9c5db099181..82c7dc05f4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
.DS_Store
.coverage
_build
+_static
panoramix/bin/panoramixc
build
*.db
diff --git a/TODO.md b/TODO.md
index aabf40669df..378f5b29211 100644
--- a/TODO.md
+++ b/TODO.md
@@ -2,6 +2,7 @@
List of TODO items for Panoramix
## Features
+* **URL shortner**
* **Dashboard URL filters:** `{dash_url}#fltin__fieldname__value1,value2`
* **Browser history in explore.html:** use location.hash to manage query history
* **Default slice:** choose a default slice for the dataset instead of default endpoint
diff --git a/docs/img b/docs/img
new file mode 120000
index 00000000000..bf6c771eb20
--- /dev/null
+++ b/docs/img
@@ -0,0 +1 @@
+../panoramix/static/img/
\ No newline at end of file
diff --git a/docs/img/tux_panoramix.png b/docs/img/tux_panoramix.png
deleted file mode 100644
index 3e2d5f10256..00000000000
Binary files a/docs/img/tux_panoramix.png and /dev/null differ
diff --git a/panoramix/static/panoramix.js b/panoramix/static/panoramix.js
index d0aa9db6eca..5bb85e6be58 100644
--- a/panoramix/static/panoramix.js
+++ b/panoramix/static/panoramix.js
@@ -19,11 +19,19 @@ var px = (function() {
$('#timer').text(num.toFixed(2) + " sec");
}
var qrystr = '';
+ var always = function(data) {
+ //Private f, runs after done and error
+ clearInterval(timer);
+ $('#timer').removeClass('btn-warning');
+ }
slice = {
- jsonEndpoint: function() {
+ data: data,
+ container: container,
+ container_id: container_id,
+ selector: selector,
+ querystring: function(){
var parser = document.createElement('a');
parser.href = data.json_endpoint;
- // Shallow copy
if (dashboard !== undefined){
qrystr = parser.search + "&extra_filters=" + JSON.stringify(dashboard.filters);
}
@@ -33,7 +41,12 @@ var px = (function() {
else {
qrystr = '?' + $('#query').serialize();
}
- var endpoint = parser.pathname + qrystr + "&json=true";
+ return qrystr;
+ },
+ jsonEndpoint: function() {
+ var parser = document.createElement('a');
+ parser.href = data.json_endpoint;
+ var endpoint = parser.pathname + this.querystring() + "&json=true";
return endpoint;
},
done: function (data) {
@@ -45,21 +58,21 @@ var px = (function() {
$('#timer').removeClass('btn-warning');
$('#timer').addClass('btn-success');
$('span.query').removeClass('disabled');
+ $('#json').click(function(){window.location=data.json_endpoint()});
+ $('#standalone').click(function(){window.location=data.standalone_endpoint});
+ $('#csv').click(function(){window.location=data.csv_endpoint});
+ $('.btn-group.results span').removeAttr('disabled');
+ always(data);
},
error: function (msg) {
- clearInterval(timer);
token.find("img.loading").hide();
var err = '
' + msg + '
';
container.html(err);
container.show();
- $('#timer').removeClass('btn-warning');
$('span.query').removeClass('disabled');
$('#timer').addClass('btn-danger');
+ always(data);
},
- data: data,
- container: container,
- container_id: container_id,
- selector: selector,
width: function(){
return token.width();
},
@@ -67,6 +80,7 @@ var px = (function() {
return token.height();
},
render: function() {
+ $('.btn-group.results span').attr('disabled','disabled');
token.find("img.loading").show();
container.hide();
container.html('');
@@ -75,9 +89,6 @@ var px = (function() {
$('#timer').removeClass('btn-danger btn-success');
$('#timer').addClass('btn-warning');
viz.render();
- $('#json').click(function(){window.location=slice.jsonEndpoint()});
- $('#standalone').click(function(){window.location=slice.data.standalone_endpoint});
- $('#csv').click(function(){window.location=slice.data.csv_endpoint});
},
resize: function() {
token.find("img.loading").show();
@@ -146,11 +157,62 @@ var px = (function() {
}
function registerViz(name, initViz) {
-
visualizations[name] = initViz;
}
function initExploreView() {
+
+ function get_collapsed_fieldsets(){
+ collapsed_fieldsets = $("#collapsed_fieldsets").val();
+ if (collapsed_fieldsets != undefined && collapsed_fieldsets != "")
+ collapsed_fieldsets = collapsed_fieldsets.split('||');
+ else
+ collapsed_fieldsets = [];
+ return collapsed_fieldsets;
+ }
+
+ function toggle_fieldset(legend, animation) {
+ var parent = legend.parent();
+ fieldset = parent.find(".legend_label").text();
+ collapsed_fieldsets = get_collapsed_fieldsets();
+
+ if (!parent.hasClass("collapsed")){
+ if (animation)
+ parent.find(".fieldset_content").slideUp();
+ else
+ parent.find(".fieldset_content").hide();
+
+ parent.addClass("collapsed");
+ parent.find("span.collapser").text("[+]");
+ var index = collapsed_fieldsets.indexOf(fieldset);
+ if (index === -1 && fieldset !== "" && fieldset !== undefined) {
+ collapsed_fieldsets.push(fieldset);
+ }
+ } else {
+ if (animation)
+ parent.find(".fieldset_content").slideDown();
+ else
+ parent.find(".fieldset_content").show();
+ parent.removeClass("collapsed");
+ parent.find("span.collapser").text("[-]");
+
+ // removing from array, js is overcomplicated
+ var index = collapsed_fieldsets.indexOf(fieldset);
+ if (index !== -1) {
+ collapsed_fieldsets.splice(index, 1);
+ }
+ }
+ $("#collapsed_fieldsets").val(collapsed_fieldsets.join("||"));
+ }
+
+ $('legend').click(function () {
+ toggle_fieldset($(this), true);
+ });
+ $("#viz_type").change(function() {$("#query").submit();});
+ collapsed_fieldsets = get_collapsed_fieldsets();
+ for(var i=0; i < collapsed_fieldsets.length; i++){
+ toggle_fieldset($('legend:contains("' + collapsed_fieldsets[i] + '")'), false);
+ }
function getParam(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
@@ -205,10 +267,18 @@ var px = (function() {
i++;
});
}
+ $(window).bind("popstate", function(event) {
+ // Browser back button
+ var returnLocation = history.location || document.location;
+ // Could do something more lightweight here, but we're not optimizing
+ // for the use of the back button anyways
+ returnLocation.reload();
+ });
function druidify(){
prepForm();
$('div.alert').remove();
+ history.pushState({}, document.title, slice.querystring());
slice.render();
}
diff --git a/panoramix/static/widgets/viz_table.js b/panoramix/static/widgets/viz_table.js
index bbb17e04e94..f307acc1ccd 100644
--- a/panoramix/static/widgets/viz_table.js
+++ b/panoramix/static/widgets/viz_table.js
@@ -44,7 +44,8 @@ px.registerViz('table', function(slice) {
}
})
.attr('title', function(d){
- return fC(d.val);
+ if (!isNaN(d.val))
+ return fC(d.val);
})
.attr('data-sort', function(d){
if (d.isMetric)
diff --git a/panoramix/templates/panoramix/explore.html b/panoramix/templates/panoramix/explore.html
index c409fd65895..c064a0f11d4 100644
--- a/panoramix/templates/panoramix/explore.html
+++ b/panoramix/templates/panoramix/explore.html
@@ -17,6 +17,8 @@
{% endmacro %}
+{% block title %}TEST{% endblock %}
+