diff --git a/panoramix/forms.py b/panoramix/forms.py
index d9408f10b..198d77546 100644
--- a/panoramix/forms.py
+++ b/panoramix/forms.py
@@ -277,6 +277,8 @@ class FormFactory(object):
standalone = HiddenField()
async = HiddenField()
json = HiddenField()
+ slice_id = HiddenField()
+ slice_name = HiddenField()
previous_viz_type = HiddenField(default=viz.viz_type)
filter_cols = datasource.filterable_column_names or ['']
diff --git a/panoramix/models.py b/panoramix/models.py
index 336e55f75..21e0381f5 100644
--- a/panoramix/models.py
+++ b/panoramix/models.py
@@ -80,20 +80,21 @@ class Slice(Model, AuditMixinNullable):
@property
def datasource_id(self):
- datasource = self.datasource
- return datasource.id if datasource else None
+ return self.table_id or self.druid_datasource_id
@property
def slice_url(self):
try:
- d = json.loads(self.params)
+ slice_params = json.loads(self.params)
except Exception as e:
- d = {}
+ slice_params = {}
+ slice_params['slice_id'] = self.id
+ slice_params['slice_name'] = self.slice_name
from werkzeug.urls import Href
href = Href(
- "/panoramix/datasource/{self.datasource_type}/"
+ "/panoramix/explore/{self.datasource_type}/"
"{self.datasource_id}/".format(self=self))
- return href(d)
+ return href(slice_params)
@property
def edit_url(self):
@@ -250,7 +251,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
@property
def table_link(self):
- url = "/panoramix/datasource/{self.type}/{self.id}/".format(self=self)
+ url = "/panoramix/explore/{self.type}/{self.id}/".format(self=self)
return '{self.table_name}'.format(**locals())
@property
@@ -694,9 +695,7 @@ class Datasource(Model, AuditMixinNullable, Queryable):
@property
def datasource_link(self):
- url = (
- "/panoramix/datasource/"
- "{self.type}/{self.id}/").format(self=self)
+ url = "/panoramix/explore/{self.type}/{self.id}/".format(self=self)
return '{self.datasource_name}'.format(**locals())
def get_metric_obj(self, metric_name):
diff --git a/panoramix/static/panoramix.js b/panoramix/static/panoramix.js
index 79a989307..69903244f 100644
--- a/panoramix/static/panoramix.js
+++ b/panoramix/static/panoramix.js
@@ -78,14 +78,21 @@ function initializeDatasourceView() {
}
$("#plus").click(add_filter);
- $("#save").click(function () {
+ $("#btn_save").click(function () {
var slice_name = prompt("Name your slice!");
if (slice_name != "" && slice_name != null) {
$("#slice_name").val(slice_name);
$("#action").val("save");
druidify();
}
- })
+ });
+ $("#btn_overwrite").click(function () {
+ var flag = confirm("Overwrite slice [" + $("#slice_name").val() + "] !?");
+ if (flag) {
+ $("#action").val("overwrite");
+ druidify();
+ }
+ });
add_filter();
$(".druidify").click(druidify);
diff --git a/panoramix/templates/panoramix/datasource.html b/panoramix/templates/panoramix/explore.html
similarity index 92%
rename from panoramix/templates/panoramix/datasource.html
rename to panoramix/templates/panoramix/explore.html
index f94316695..dedad101e 100644
--- a/panoramix/templates/panoramix/datasource.html
+++ b/panoramix/templates/panoramix/explore.html
@@ -77,14 +77,21 @@
Slice!
-