mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
* Wrap <LoadableRenderer /> with <ErrorBoundary /> It appears that since the introduction of <SuperChart />, errors in the visualization javascript (which are somewhat common and expected, especially as we'll support plugins) were not handled and the whole page would throw and go missing. Here I'm introducing a new <ErrorBoundary /> component that elegantly wraps other components and handles errors. It's inspired by: https://reactjs.org/docs/error-boundaries.html The default behavior of the component is to simply surface the error as an <Alert bsStyle="danger" /> and exposes the React stacktrace when clicking on the error. It's also possible to use component and pass an onError handler and not show the default message. This also fixes some minor bugs in TimeTable. * Addressing comments * Getting more stack traces * Adressing comments
32 lines
1010 B
Python
32 lines
1010 B
Python
# pylint: disable=R
|
|
import json
|
|
|
|
from flask import g, request
|
|
from flask_appbuilder import expose
|
|
from flask_appbuilder.security.decorators import has_access_api
|
|
|
|
from superset import appbuilder, security_manager
|
|
from superset.common.query_context import QueryContext
|
|
from superset.models.core import Log
|
|
from .base import api, BaseSupersetView, data_payload_response, handle_api_exception
|
|
|
|
|
|
class Api(BaseSupersetView):
|
|
@Log.log_this
|
|
@api
|
|
@handle_api_exception
|
|
@has_access_api
|
|
@expose('/v1/query/', methods=['POST'])
|
|
def query(self):
|
|
"""
|
|
Takes a query_obj constructed in the client and returns payload data response
|
|
for the given query_obj.
|
|
"""
|
|
query_context = QueryContext(**json.loads(request.form.get('query_context')))
|
|
security_manager.assert_datasource_permission(query_context.datasource, g.user)
|
|
payload_json = query_context.get_data()
|
|
return data_payload_response(payload_json)
|
|
|
|
|
|
appbuilder.add_view_no_menu(Api)
|