mirror of https://github.com/apache/superset.git
Datasource dropdown in Explore view
This commit is contained in:
parent
65e72d0d07
commit
062f2b81cf
|
@ -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);
|
||||
|
|
|
@ -466,11 +466,16 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
|||
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 '<a href="{url}">{self.table_name}</a>'.format(
|
||||
url=url, self=self)
|
||||
return '<a href="{self.explore_url}">{self.table_name}</a>'.format(self=self)
|
||||
|
||||
@property
|
||||
def metrics_combo(self):
|
||||
|
|
|
@ -29,18 +29,16 @@
|
|||
<div class="datasource container-fluid">
|
||||
<form id="query" method="GET" style="display: none;">
|
||||
<div class="header">
|
||||
<span class="btn btn-default notbtn" title="datasource" data-toggle="tooltip">
|
||||
{{ datasource.full_name }}
|
||||
{% if datasource.description %}
|
||||
<a data-toggle="modal" data-target="#sourceinfo_modal">
|
||||
<i class="fa fa-info-circle" data-toggle="tooltip" data-placement="bottom" title="{{ datasource.description }}"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="" href="/{{ datasource.baselink }}/edit/{{ datasource.id }}" data-toggle="tooltip" title="Edit">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
<span title="Data Source" data-toggle="tooltip">
|
||||
<select id="datasource_id" class="select2">
|
||||
{% for ds in datasources %}
|
||||
<option url="{{ ds.explore_url }}" {{ "selected" if ds.id == datasource.id }} value="{{ ds.id }}">{{ ds.full_name }}<i class="fa fa-info"></i></option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</span>
|
||||
<span title="Visualization Type" data-toggle="tooltip">
|
||||
{{ form.get_field("viz_type")(class_="select2") }}
|
||||
</span>
|
||||
<span>{{ form.get_field("viz_type")(class_="select2") }}</span>
|
||||
{% if slice %}
|
||||
<span class="btn btn-default notbtn" title="Slice" data-toggle="tooltip" data-placement="bottom">
|
||||
<span class="favstar" class_name="Slice" obj_id="{{ slice.id }}"></span>
|
||||
|
|
|
@ -435,12 +435,14 @@ class Caravel(BaseView):
|
|||
def explore(self, datasource_type, datasource_id):
|
||||
datasource_class = models.SqlaTable \
|
||||
if datasource_type == "table" else models.DruidDatasource
|
||||
datasource = (
|
||||
datasources = (
|
||||
db.session
|
||||
.query(datasource_class)
|
||||
.filter_by(id=datasource_id)
|
||||
.first()
|
||||
.all()
|
||||
)
|
||||
datasources = sorted(datasources, key=lambda ds: ds.full_name)
|
||||
datasource = [ds for ds in datasources if int(datasource_id) == ds.id]
|
||||
datasource = datasource[0] if datasource else None
|
||||
slice_id = request.args.get("slice_id")
|
||||
slc = None
|
||||
if slice_id:
|
||||
|
@ -450,7 +452,7 @@ class Caravel(BaseView):
|
|||
.first()
|
||||
)
|
||||
if not datasource:
|
||||
flash("The datasource seem to have been deleted", "alert")
|
||||
flash("The datasource seems to have been deleted", "alert")
|
||||
|
||||
all_datasource_access = self.appbuilder.sm.has_access(
|
||||
'all_datasource_access', 'all_datasource_access')
|
||||
|
@ -503,7 +505,8 @@ class Caravel(BaseView):
|
|||
else:
|
||||
template = "caravel/explore.html"
|
||||
|
||||
resp = self.render_template(template, viz=obj, slice=slc)
|
||||
resp = self.render_template(
|
||||
template, viz=obj, slice=slc, datasources=datasources)
|
||||
try:
|
||||
pass
|
||||
except Exception as e:
|
||||
|
|
|
@ -44,6 +44,9 @@ attempt it: ::
|
|||
C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE%
|
||||
C:\> pip install cryptography
|
||||
|
||||
# You may also have to create C:\Temp
|
||||
C:\> md C:\Temp
|
||||
|
||||
|
||||
Caravel installation and initialization
|
||||
---------------------------------------
|
||||
|
|
Loading…
Reference in New Issue