Skip to content

Commit

Permalink
Getting browser history to work on the explore view
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 11, 2016
1 parent af55285 commit f0cdf43
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.coverage
_build
_static
panoramix/bin/panoramixc
build
*.db
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/img
Binary file removed docs/img/tux_panoramix.png
Binary file not shown.
23 changes: 16 additions & 7 deletions panoramix/static/panoramix.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ var px = (function() {
container: container,
container_id: container_id,
selector: selector,
jsonEndpoint: function() {
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);
}
Expand All @@ -43,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) {
Expand All @@ -68,7 +71,6 @@ var px = (function() {
container.show();
$('span.query').removeClass('disabled');
$('#timer').addClass('btn-danger');
$('.btn-group.results span').attr('disabled','disabled');
always(data);
},
width: function(){
Expand All @@ -78,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('');
Expand All @@ -86,7 +89,6 @@ var px = (function() {
$('#timer').removeClass('btn-danger btn-success');
$('#timer').addClass('btn-warning');
viz.render();
console.log(slice);
},
resize: function() {
token.find("img.loading").show();
Expand Down Expand Up @@ -155,7 +157,6 @@ var px = (function() {
}

function registerViz(name, initViz) {

visualizations[name] = initViz;
}

Expand Down Expand Up @@ -266,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();
}

Expand Down
2 changes: 2 additions & 0 deletions panoramix/templates/panoramix/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
</div>
{% endmacro %}

{% block title %}TEST{% endblock %}

<div class="datasource">
<form id="query" method="GET" style="display: none;">
<div class="header">
Expand Down
1 change: 0 additions & 1 deletion panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def reassignments(self):

def get_url(self, **kwargs):
d = self.orig_form_data.copy()
d = self.form_data.copy()
if 'action' in d:
del d['action']
d.update(kwargs)
Expand Down

0 comments on commit f0cdf43

Please sign in to comment.