From 062f2b81cf56e5c49453691fe800db2de8753e61 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 6 Apr 2016 08:23:27 -0700 Subject: [PATCH] Datasource dropdown in Explore view --- caravel/assets/javascripts/explore.js | 6 ++++++ caravel/models.py | 11 ++++++++--- caravel/templates/caravel/explore.html | 20 +++++++++----------- caravel/views.py | 13 ++++++++----- docs/installation.rst | 3 +++ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/caravel/assets/javascripts/explore.js b/caravel/assets/javascripts/explore.js index 81d79f597d8cd..5bf628d10503d 100644 --- a/caravel/assets/javascripts/explore.js +++ b/caravel/assets/javascripts/explore.js @@ -192,10 +192,16 @@ function initExploreView() { } }); }); + $("#viz_type").change(function () { $("#query").submit(); }); + $("#datasource_id").change(function () { + var url = $(this).find('option:selected').attr('url'); + window.location = url; + }); + var collapsed_fieldsets = get_collapsed_fieldsets(); for (var i = 0; i < collapsed_fieldsets.length; i++) { toggle_fieldset($('legend:contains("' + collapsed_fieldsets[i] + '")'), false); diff --git a/caravel/models.py b/caravel/models.py index 8bcfb6cce0026..1769daa965b8c 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -466,11 +466,16 @@ def html(self): def name(self): return self.table_name + @property + def explore_url(self): + if self.default_endpoint: + return self.default_endpoint + else: + return "/caravel/explore/{self.type}/{self.id}/".format(self=self) + @property def table_link(self): - url = "/caravel/explore/{self.type}/{self.id}/".format(self=self) - return '{self.table_name}'.format( - url=url, self=self) + return '{self.table_name}'.format(self=self) @property def metrics_combo(self): diff --git a/caravel/templates/caravel/explore.html b/caravel/templates/caravel/explore.html index d9ea3bb89c5ac..c6d5e3f67eaf2 100644 --- a/caravel/templates/caravel/explore.html +++ b/caravel/templates/caravel/explore.html @@ -29,18 +29,16 @@