mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Fixing bug when datasource has been deleted
This commit is contained in:
parent
ef45c20558
commit
aec3c0b358
@ -21,12 +21,17 @@ var Dashboard = function (dashboardData) {
|
||||
var sliceObjects = [],
|
||||
dash = this;
|
||||
dashboard.slices.forEach(function (data) {
|
||||
var slice = px.Slice(data, dash);
|
||||
$("#slice_" + data.slice_id).find('a.refresh').click(function () {
|
||||
slice.render(true);
|
||||
});
|
||||
sliceObjects.push(slice);
|
||||
slice.render();
|
||||
if (data.error) {
|
||||
var html = '<div class="alert alert-danger">' + data.error + '</div>';
|
||||
$("#slice_" + data.slice_id).find('.token').html(html);
|
||||
} else {
|
||||
var slice = px.Slice(data, dash);
|
||||
$("#slice_" + data.slice_id).find('a.refresh').click(function () {
|
||||
slice.render(true);
|
||||
});
|
||||
sliceObjects.push(slice);
|
||||
slice.render();
|
||||
}
|
||||
});
|
||||
this.slices = sliceObjects;
|
||||
},
|
||||
|
@ -151,10 +151,8 @@ class Slice(Model, AuditMixinNullable):
|
||||
@utils.memoized
|
||||
def viz(self):
|
||||
d = json.loads(self.params)
|
||||
viz = viz_types[self.viz_type](
|
||||
self.datasource,
|
||||
form_data=d)
|
||||
return viz
|
||||
viz_class = viz_types[self.viz_type]
|
||||
return viz_class(self.datasource, form_data=d)
|
||||
|
||||
@property
|
||||
def description_markeddown(self):
|
||||
@ -166,7 +164,13 @@ class Slice(Model, AuditMixinNullable):
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
d = self.viz.data
|
||||
d = {}
|
||||
self.token = ''
|
||||
try:
|
||||
d = self.viz.data
|
||||
self.token = d.get('token')
|
||||
except Exception as e:
|
||||
d['error'] = str(e)
|
||||
d['slice_id'] = self.id
|
||||
return d
|
||||
|
||||
|
@ -72,17 +72,17 @@
|
||||
<ul>
|
||||
{% for slice in dashboard.slices %}
|
||||
{% set pos = pos_dict.get(slice.id, {}) %}
|
||||
{% set viz = slice.viz %}
|
||||
|
||||
|
||||
<li
|
||||
id="slice_{{ slice.id }}"
|
||||
slice_id="{{ slice.id }}"
|
||||
class="widget {{ slice.viz.viz_type }}"
|
||||
class="widget {{ slice.viz_type }}"
|
||||
data-row="{{ pos.row or 1 }}"
|
||||
data-col="{{ pos.col or loop.index }}"
|
||||
data-sizex="{{ pos.size_x or 4 }}"
|
||||
data-sizey="{{ pos.size_y or 4 }}">
|
||||
|
||||
|
||||
<div class="chart-header">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center header">
|
||||
@ -124,9 +124,9 @@
|
||||
</div>
|
||||
<div class="row chart-container">
|
||||
<input type="hidden" slice_id="{{ slice.id }}" value="false">
|
||||
<div id="{{ viz.token }}" class="token col-md-12">
|
||||
<div id="{{ slice.token }}" class="token col-md-12">
|
||||
<img src="{{ url_for("static", filename="assets/images/loading.gif") }}" class="loading" alt="loading">
|
||||
<div class="slice_container" id="{{ viz.token }}_con"></div>
|
||||
<div class="slice_container" id="{{ slice.token }}_con"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -633,7 +633,6 @@ class Caravel(BaseView):
|
||||
qry = qry.filter_by(slug=dashboard_id)
|
||||
|
||||
templates = session.query(models.CssTemplate).all()
|
||||
|
||||
dash = qry.first()
|
||||
|
||||
# Hack to log the dashboard_id properly, even when getting a slug
|
||||
|
@ -43,6 +43,8 @@ class BaseViz(object):
|
||||
|
||||
def __init__(self, datasource, form_data, slice=None):
|
||||
self.orig_form_data = form_data
|
||||
if not datasource:
|
||||
raise Exception("Viz is missing a datasource")
|
||||
self.datasource = datasource
|
||||
self.request = request
|
||||
self.viz_type = form_data.get("viz_type")
|
||||
|
Loading…
Reference in New Issue
Block a user