mirror of https://github.com/apache/superset.git
[Explore] Save url parameters when user save slices
This commit is contained in:
parent
42ebcaad40
commit
8e0ba8dbdc
|
@ -293,6 +293,13 @@ ExploreViewContainer.propTypes = propTypes;
|
||||||
|
|
||||||
function mapStateToProps({ explore, charts, impressionId }) {
|
function mapStateToProps({ explore, charts, impressionId }) {
|
||||||
const form_data = getFormDataFromControls(explore.controls);
|
const form_data = getFormDataFromControls(explore.controls);
|
||||||
|
// fill in additional params stored in form_data but not used by control
|
||||||
|
Object.keys(explore.rawFormData)
|
||||||
|
.forEach((key) => {
|
||||||
|
if (form_data[key] === undefined) {
|
||||||
|
form_data[key] = explore.rawFormData[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
const chartKey = Object.keys(charts)[0];
|
const chartKey = Object.keys(charts)[0];
|
||||||
const chart = charts[chartKey];
|
const chart = charts[chartKey];
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -25,6 +25,7 @@ initJQueryAjax();
|
||||||
const exploreViewContainer = document.getElementById('app');
|
const exploreViewContainer = document.getElementById('app');
|
||||||
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap'));
|
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap'));
|
||||||
const controls = getControlsState(bootstrapData, bootstrapData.form_data);
|
const controls = getControlsState(bootstrapData, bootstrapData.form_data);
|
||||||
|
const rawFormData = { ...bootstrapData.form_data };
|
||||||
delete bootstrapData.form_data;
|
delete bootstrapData.form_data;
|
||||||
delete bootstrapData.common.locale;
|
delete bootstrapData.common.locale;
|
||||||
delete bootstrapData.common.language_pack;
|
delete bootstrapData.common.language_pack;
|
||||||
|
@ -32,6 +33,7 @@ delete bootstrapData.common.language_pack;
|
||||||
// Initial state
|
// Initial state
|
||||||
const bootstrappedState = Object.assign(
|
const bootstrappedState = Object.assign(
|
||||||
bootstrapData, {
|
bootstrapData, {
|
||||||
|
rawFormData,
|
||||||
controls,
|
controls,
|
||||||
filterColumnOpts: [],
|
filterColumnOpts: [],
|
||||||
isDatasourceMetaLoading: false,
|
isDatasourceMetaLoading: false,
|
||||||
|
|
|
@ -109,6 +109,13 @@ export function applyDefaultFormData(form_data) {
|
||||||
formData[k] = form_data[k];
|
formData[k] = form_data[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// fill in additional params stored in form_data but not used by control
|
||||||
|
Object.keys(form_data)
|
||||||
|
.forEach((key) => {
|
||||||
|
if (formData[key] === undefined) {
|
||||||
|
formData[key] = form_data[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import inspect
|
import inspect
|
||||||
|
import json
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -30,15 +31,22 @@ BASE_CONTEXT.update(config.get('JINJA_CONTEXT_ADDONS', {}))
|
||||||
|
|
||||||
|
|
||||||
def url_param(param, default=None):
|
def url_param(param, default=None):
|
||||||
"""Get a url paramater
|
"""Get a url or post data parameter
|
||||||
|
|
||||||
:param param: the url parameter to lookup
|
:param param: the parameter to lookup
|
||||||
:type param: str
|
:type param: str
|
||||||
:param default: the value to return in the absence of the parameter
|
:param default: the value to return in the absence of the parameter
|
||||||
:type default: str
|
:type default: str
|
||||||
"""
|
"""
|
||||||
print(request.args)
|
print('request args', request.args)
|
||||||
return request.args.get(param, default)
|
print('request form', request.form)
|
||||||
|
if request.args.get(param):
|
||||||
|
return request.args.get(param, default)
|
||||||
|
# Supporting POST as well as get
|
||||||
|
if request.form.get('form_data'):
|
||||||
|
form_data = json.loads(request.form.get('form_data'))
|
||||||
|
return form_data.get(param, default)
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
def current_user_id():
|
def current_user_id():
|
||||||
|
|
|
@ -1255,6 +1255,14 @@ class Superset(BaseSupersetView):
|
||||||
# On explore, merge extra filters into the form data
|
# On explore, merge extra filters into the form data
|
||||||
merge_extra_filters(form_data)
|
merge_extra_filters(form_data)
|
||||||
|
|
||||||
|
# merge request url params
|
||||||
|
if request.method == 'GET':
|
||||||
|
url_params = request.args
|
||||||
|
for key, value in url_params.items():
|
||||||
|
if key == 'form_data':
|
||||||
|
continue
|
||||||
|
form_data[key] = value
|
||||||
|
|
||||||
# handle save or overwrite
|
# handle save or overwrite
|
||||||
action = request.args.get('action')
|
action = request.args.get('action')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue