diff --git a/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx b/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx index d55f337dc3da8..449e30cbeaa28 100644 --- a/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx +++ b/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx @@ -4,6 +4,7 @@ import { Alert, Button, Col, Modal } from 'react-bootstrap'; import Select from 'react-select'; import { Table } from 'reactable'; import shortid from 'shortid'; +import $ from 'jquery'; const CHART_TYPES = [ { value: 'dist_bar', label: 'Distribution - Bar Chart', requiresTime: false }, @@ -105,7 +106,17 @@ class VisualizeModal extends React.PureComponent { sql: this.props.query.sql, dbId: this.props.query.dbId, }; - window.open('/superset/sqllab_viz/?data=' + JSON.stringify(vizOptions)); + $.ajax({ + type: 'POST', + url: '/superset/sqllab_viz/', + async: false, + data: { + data: JSON.stringify(vizOptions), + }, + success: (url) => { + window.open(url); + }, + }); } changeDatasourceName(event) { this.setState({ datasourceName: event.target.value }); diff --git a/superset/views.py b/superset/views.py index 78bf906b0ea1b..cf06776c98730 100755 --- a/superset/views.py +++ b/superset/views.py @@ -2222,10 +2222,10 @@ def sync_druid_source(self): return Response(status=201) @has_access - @expose("/sqllab_viz/") + @expose("/sqllab_viz/", methods=['POST']) @log_this def sqllab_viz(self): - data = json.loads(request.args.get('data')) + data = json.loads(request.form.get('data')) table_name = data.get('datasourceName') viz_type = data.get('chartType') table = ( @@ -2283,8 +2283,7 @@ def sqllab_viz(self): 'limit': '0', } params = "&".join([k + '=' + v for k, v in params.items() if v]) - url = '/superset/explore/table/{table.id}/?{params}'.format(**locals()) - return redirect(url) + return '/superset/explore/table/{table.id}/?{params}'.format(**locals()) @has_access @expose("/table////")